You are not logged in.

#1 2017-08-20 14:05:14

Mladia
Member
Registered: 2016-04-30
Posts: 59

[Solved] Adding a resume hook

My libinput option for the Touchpad aren't read properly from the conf files, so I made a simple script to fine-tune some more of the options there.

I run the script automatically at startup and everything is fine. The problem is when I suspend the computer and resume again, this configuration that I've made before at startup, doesn't stay. What I did do solve that, is I made a hook with systemd resume and called my script from there. But that does not work. After I looked into the journal, I saw that the script was being run properly, but I get

"Unable to connect to X server". 

Than I get some more errors:

Aug 20 16:53:10 best-pc systemd[1]: resume@nmlad.service: Main process exited, code=exited, status=1/FAILURE
Aug 20 16:53:10 best-pc systemd[1]: resume@nmlad.service: Unit entered failed state.
Aug 20 16:53:10 best-pc systemd[1]: resume@nmlad.service: Failed with result 'exit-code'.

Something that also might be relevant is another error in the journal:

Aug 20 16:53:09 best-pc systemd[1]: suspend.target: Bound to unit systemd-suspend.service, but unit isn't active.
Aug 20 16:53:09 best-pc systemd[1]: Dependency failed for Suspend.
Aug 20 16:53:09 best-pc systemd[1]: suspend.target: Job suspend.target/start failed with result 'dependency'.

The scirpt for the options looks like this

/home/nmlad/bin/non-e/resume

#!/bin/bash

echo "Changing options"  #debug

xinput --set-prop "ETPS/2 Elantech Touchpad" "libinput Natural Scrolling Enable$
xinput --set-prop "ETPS/2 Elantech Touchpad" "libinput Tapping Enabled" 1

and the resume and suspend files:

suspend@.service

[Unit]
Description=User suspend actions
Before=sleep.target

[Service]
User=%I
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock -c 9966ff
ExecStartPost=/usr/bin/sleep 1

[Install]
WantedBy=sleep.target


resume@.service

[Unit]
Description=User resume actions
After=suspend.target

[Service]
User=%I
Type=simple
ExecStart=/home/nmlad/bin/non-e/resume

[Install]
WantedBy=suspend.target

Last edited by Mladia (2017-08-21 10:31:32)

Offline

#2 2017-08-21 09:17:17

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,304

Re: [Solved] Adding a resume hook

What happens if you add:

Environment=DISPLAY=:0

in resume@.service, like you did in suspend@.service?

Because your script uses xinput which is an X command.

Offline

#3 2017-08-21 10:31:13

Mladia
Member
Registered: 2016-04-30
Posts: 59

Re: [Solved] Adding a resume hook

It didn't fix it. I get again "Unable to connect to X server"
...

I tried a lot of things. In the end It runs properly like this:

#!/bin/bash

sleep 1
DISPLAY=:0.0
export DISPLAY
#script for changing touchpad controls...

Offline

Board footer

Powered by FluxBB