Hi,

Am 27.03.23 um 12:21 schrieb SeerLite:
Hi! Is it maybe Polkit? Polkit was stopping me from suspending my laptop via 
SSH. The exact same behavior as you: no output and error code 1.

Since the only `loginctl` command I cared about was `suspend`, I added my user 
to the `power` group, added the `power` group to `operating-system`, defined 
the following extension:

     ; Rule template stolen from from gnu/services/desktop.scm: polkit-wheel
     ; and rule itself stolen from https://askubuntu.com/a/992878
     (define polkit-power-rules
       (file-union
        "polkit-power"
        `(("share/polkit-1/rules.d/power.rules"
           ,(plain-file
             "power.rules"
             "polkit.addRule(function(action, subject) {
         if (action.id == \"org.freedesktop.login1.suspend\" &&
             subject.isInGroup(\"power\")) {
             return polkit.Result.YES;
         }
     });")))))


and added the above to my services like:

     (simple-service 'polkit-power-rules polkit-service-type (list 
polkit-power-rules))

You'd have to do something but I'm guessing for `login1.poweroff` instead.

Thank you, that works. I think this kind of rule should be expected on most systems. It would be nice if this kind of polkit rule was predefined as a variable in guix, or the manual (or at least the cookbook) should give this as an example.

Reply via email to