Polkit: Difference between revisions

imported>Mweinelt
imported>Lumarius
Added a note about lxqt-policykit
(6 intermediate revisions by 4 users not shown)
Line 9: Line 9:
== Reboot/poweroff for unprivileged users ==
== Reboot/poweroff for unprivileged users ==


With the following rule, we can grant the permissions `reboot` and `poweroff` a machine to users in the <code>
With the following rule, we can grant the permissions <code>reboot</code> and <code>poweroff</code> a machine to users in the <code>
users</code> group.
users</code> group.
This is useful on a multi-user machine. It may also be of particular importance when using XRDP or other similar [[Remote Desktop]] solutions.


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
Line 21: Line 23:
             action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
             action.id == "org.freedesktop.login1.reboot-multiple-sessions" ||
             action.id == "org.freedesktop.login1.power-off" ||
             action.id == "org.freedesktop.login1.power-off" ||
             action.id == "org.freedesktop.login1.power-off-multiple-sessions" ||
             action.id == "org.freedesktop.login1.power-off-multiple-sessions"
           )
           )
         )
         )
Line 56: Line 58:
};
};
</syntaxhighlight>
</syntaxhighlight>
Another option is <code>lxqt.lxqt-policykit</code>, which can be launched on login through the command <code>lxqt-policykit-agent</code> on e.g. Hyprland.


== Start the authentication agent in dwm ==
== Start the authentication agent in dwm ==
Line 61: Line 65:
If you use dwm patched with [https://dwm.suckless.org/patches/autostart/dwm-autostart-20210120-cb3f58a.diff dwm-autostart-20210120-cb3f58a.diff], you can add a command into <code>~/.dwm/autostart.sh</code> to start a polkit agent. Here take <code>mate.mate-polkit</code> for example:
If you use dwm patched with [https://dwm.suckless.org/patches/autostart/dwm-autostart-20210120-cb3f58a.diff dwm-autostart-20210120-cb3f58a.diff], you can add a command into <code>~/.dwm/autostart.sh</code> to start a polkit agent. Here take <code>mate.mate-polkit</code> for example:


<syntaxhighlight>
<syntaxhighlight lang=bash>
#!/bin/sh
#!/bin/sh
# General stuff
# General stuff
Line 71: Line 75:


Use this method, you won't need to change the codes even <code>mate.mate-polkit</code> gets an update.
Use this method, you won't need to change the codes even <code>mate.mate-polkit</code> gets an update.
<syntaxhighlight lang=bash>
#!/bin/sh
...
/nix/store/$(ls -la /nix/store | grep polkit-kde-agent | grep '^d' | awk '{print $9}')/libexec/polkit-kde-authentication-agent-1 &
...
</syntaxhighlight>
The same but for <code>polkit-kde-agent</code>