Polkit 笔记

为了弹出提权 GUI 窗口,创建 /usr/share/polkit-1/actions/org.my.policy

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
  <action id="org.my.run-gedit">
    <icon_name>folder</icon_name>
    <description>Run Gedit</description>
    <message>Authentication is required to run Gedit</message>
    <defaults>
      <allow_any>no</allow_any>
      <allow_inactive>no</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/gedit</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
  </action>
</policyconfig>

然后执行 pkexec gedit 即可。

参考

猜你喜欢

转载自blog.csdn.net/kencaber/article/details/107985487