You are not logged in.

#1 2022-01-10 22:05:39

Allexj
Member
Registered: 2015-07-11
Posts: 73

[SOLVED]Why I cant do a command via systemd/acpid?Only on terminal can

I followed this guide: https://wiki.archlinux.org/title/Power_ … leep_hooks
So I created the file /etc/systemd/system/resume@.service with the following content:
[Unit]
Description=User resume actions
After=suspend.target

[Service]
User=%I
Type=simple
ExecStart=/usr/bin/libinput-gestures-setup restart

[Install]
WantedBy=suspend.target
and then I enabled it with sudo systemctl enable --now resume@allexj
But it simply does not work after wake up from suspend. I always have to write manually every time libinput-gestures-setup restart on a terminal after I wake up my laptop.
Also, if I do systemctl status resume@allexj , I see:
Jan 10 20:26:05 Archy systemd[1]: Started User resume actions
Jan 10 20:26:05 Archy systemd[1]: resume@allexj.service: Deactivated successfully.So no errors...
Could it be a environment problem? How to fix?
UPDATE:
I realized, running in a clean environment without any variables set (using env -i) and testing the variables, that to run libinput-gestures-setup, were needed two env variables, USER=allexj XDG_RUNTIME_DIR=/run/user/1000 but even if I add it in the systemd file like this:
[Unit] Description=User resume actions
After=suspend.target

[Service]
Environment="USER=allexj"
Environment="XDG_RUNTIME_DIR=/run/user/1000"
User=%I
Type=simple
ExecStart=/usr/bin/libinput-gestures-setup restart

[Install]
WantedBy=suspend.target
it still does not work.
Also, if I do systemctl status suspend@allexj I see something different:
Jan 10 21:04:43 Archy systemd[1]: Started User resume actions.
Jan 10 21:04:45 Archy libinput-gestures-setup[34757]: libinput-gestures started as a desktop application.
Jan 10 21:04:45 Archy systemd[1]: resume@allexj.service: Deactivated successfully.

UPDATE2:
I even tried doing this job with acpid. I edited /etc/acpi/handler.sh this way:
   button/lid)
       case "$3" in
           close)
               systemctl suspend
               logger 'LID closed'
               ;;
           open)
               USER=allexj XDG_RUNTIME_DIR=/run/user/1000 sudo -u allexj libinput-gestures-setup restart
               logger 'LID opened'
               ;;
           *)
               logger "ACPI action undefined: $3"
               ;;
   esac
   ;;


I get this from systemctl status acpid.service:
Jan 10 23:02:56 Archy acpid[39117]: waiting for events: event logging is off
Jan 10 23:03:04 Archy sudo[39242]:     root : PWD=/ ; USER=allexj ; COMMAND=/usr/bin/libinput-gestures-setup restart
Jan 10 23:03:04 Archy sudo[39242]: pam_systemd_home(sudo:session): systemd-homed is not available: Unit dbus-org.freedesktop.home1.service not found.
Jan 10 23:03:04 Archy sudo[39242]: pam_unix(sudo:session): session opened for user allexj(uid=1000) by (uid=0)
Jan 10 23:03:06 Archy acpid[39249]: libinput-gestures stopped desktop application.
Jan 10 23:03:06 Archy sudo[39242]: pam_unix(sudo:session): session closed for user allexj Jan 10 23:03:06 Archy root[39284]: LID opened
Jan 10 23:03:06 Archy root[39290]: ACPI action undefined: ACPI0003:00
Jan 10 23:03:06 Archy root[39292]: ACPI action undefined: PNP0C0A:00
Jan 10 23:03:06 Archy root[39296]: ACPI action undefined: PNP0C0A:00











UPDATE: I FOUND THE REASON, acpid is not needed: I had a config in /etc/UPower/UPower.conf that didn't allow KDE to suspend. IgnoreLid=true . I have set it to "false" and now it WORKS. The reason why it was set on true (I completely forgot it) it was to workaround a suspend issue on external monitor that I had under GNOME.
So, again, this is not KDE fault.

Last edited by Allexj (2022-01-23 22:56:51)

Offline

#2 2022-01-10 23:28:17

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: [SOLVED]Why I cant do a command via systemd/acpid?Only on terminal can

For the love of $DEITY, edit your post and add code tags.  You've been around here long enough to know this.  Your commentary is just flowing in and overlapping with apparent content of scripts and files.

From the looks of if you are trying to run some script/program that is not provided in the repos.  What is "/usr/bin/libinput-gestures-setup"?

Last edited by Trilby (2022-01-12 14:22:12)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2022-01-11 07:48:00

seth
Member
Registered: 2012-09-03
Posts: 49,981

Re: [SOLVED]Why I cant do a command via systemd/acpid?Only on terminal can

Trilby wrote:

For the love of $DIETY

Somebody ate to much over the holidays? smile

and then I enabled it with sudo systemctl enable --now resume@allexj

https://wiki.archlinux.org/title/Systemd/User

USER=allexj XDG_RUNTIME_DIR=/run/user/1000 sudo -u allexj libinput-gestures-setup restart

Sudo doesn't preserve the environment by default and for good reasons, https://man.archlinux.org/man/core/sudo … e-env=list
Also it would not be required here

sudo -u allexj env USER=allexj XDG_RUNTIME_DIR=/run/user/1000 libinput-gestures-setup restart

Edit: https://github.com/bulletmark/libinput-gestures/ ?

Last edited by seth (2022-01-11 07:54:48)

Offline

#4 2022-01-12 08:33:14

Allexj
Member
Registered: 2015-07-11
Posts: 73

Re: [SOLVED]Why I cant do a command via systemd/acpid?Only on terminal can

seth wrote:
Trilby wrote:

For the love of $DIETY

Somebody ate to much over the holidays? smile

and then I enabled it with sudo systemctl enable --now resume@allexj

https://wiki.archlinux.org/title/Systemd/User

USER=allexj XDG_RUNTIME_DIR=/run/user/1000 sudo -u allexj libinput-gestures-setup restart

Sudo doesn't preserve the environment by default and for good reasons, https://man.archlinux.org/man/core/sudo … e-env=list
Also it would not be required here

sudo -u allexj env USER=allexj XDG_RUNTIME_DIR=/run/user/1000 libinput-gestures-setup restart

Edit: https://github.com/bulletmark/libinput-gestures/ ?

THANKS! Editing

USER=allexj XDG_RUNTIME_DIR=/run/user/1000 sudo -u allexj libinput-gestures-setup restart

to

sudo -u allexj env USER=allexj XDG_RUNTIME_DIR=/run/user/1000 libinput-gestures-setup restart

FIXED it big_smile thanks a lot!!

Last edited by Allexj (2022-01-12 08:33:47)

Offline

#5 2022-01-12 08:34:49

seth
Member
Registered: 2012-09-03
Posts: 49,981

Re: [SOLVED]Why I cant do a command via systemd/acpid?Only on terminal can

You really want to look into user services, though.

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

#6 2022-01-12 08:45:22

Allexj
Member
Registered: 2015-07-11
Posts: 73

Re: [SOLVED]Why I cant do a command via systemd/acpid?Only on terminal can

seth wrote:

You really want to look into user services, though.

Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Yeah you are right. One last question, why you said to add "env" word? If I remove it

sudo -u allexj USER=allexj XDG_RUNTIME_DIR=/run/user/1000 libinput-gestures-setup restart

, works anyway, so is there a reason why you wrote it?

Offline

#7 2022-01-12 12:19:10

seth
Member
Registered: 2012-09-03
Posts: 49,981

Re: [SOLVED]Why I cant do a command via systemd/acpid?Only on terminal can

More generic/robust

man sudo wrote:

Environment variables to be set for the command may also be passed on the command line in the form of VAR=value, e.g., LD_LIBRARY_PATH=/usr/local/pkg/lib.  Variables passed on the command line are subject to restrictions imposed by the security policy plugin.  The sudoers policy subjects variables passed on the command line to the same restrictions as normal environment variables with one important exception.  If the setenv option is set in sudoers, the command to be run has the SETENV tag set or the command matched is ALL, the user may set variables that would otherwise be forbidden.

"env" simply sets an environment and runs a process

Offline

#8 2022-01-12 13:07:25

Allexj
Member
Registered: 2015-07-11
Posts: 73

Re: [SOLVED]Why I cant do a command via systemd/acpid?Only on terminal can

seth wrote:

More generic/robust

man sudo wrote:

Environment variables to be set for the command may also be passed on the command line in the form of VAR=value, e.g., LD_LIBRARY_PATH=/usr/local/pkg/lib.  Variables passed on the command line are subject to restrictions imposed by the security policy plugin.  The sudoers policy subjects variables passed on the command line to the same restrictions as normal environment variables with one important exception.  If the setenv option is set in sudoers, the command to be run has the SETENV tag set or the command matched is ALL, the user may set variables that would otherwise be forbidden.

"env" simply sets an environment and runs a process

ok thanks smile

Offline

#9 2022-01-12 14:22:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: [SOLVED]Why I cant do a command via systemd/acpid?Only on terminal can

So you editted your post and didn't add code tags.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#10 2022-01-23 22:55:41

Allexj
Member
Registered: 2015-07-11
Posts: 73

Re: [SOLVED]Why I cant do a command via systemd/acpid?Only on terminal can

UPDATE: I FOUND THE REASON, acpid is not needed: I had a config in /etc/UPower/UPower.conf that didn't allow KDE to suspend. IgnoreLid=true . I have set it to "false" and now it WORKS. The reason why it was set on true (I completely forgot it) it was to workaround a suspend issue on external monitor that I had under GNOME.
So, again, this is not KDE fault.

Last edited by Allexj (2022-01-23 22:56:40)

Offline

#11 2022-01-23 22:58:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,444
Website

Re: [SOLVED]Why I cant do a command via systemd/acpid?Only on terminal can

Trilby wrote:

So you editted your post and didn't add code tags.

Again ...


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB