You are not logged in.

#1 2016-11-04 09:09:33

javadme
Member
Registered: 2016-11-04
Posts: 13

Cannot start i3lock when waking from suspend

Hello folks,
I'm kinda new to ArchLinux, recently installed it on my HP Stream 11 laptop, everything working great so far.
Except I cannot get the screen locker to lock the screen after suspend.
I found this on ArchLinux site:


Suspend/resume service files
Service files can be hooked into suspend.target, hibernate.target and sleep.target to execute actions before or after suspend/hibernate. Separate files should be created for user actions and root/system actions. Enable the suspend@user and resume@user services to have them started at boot. Examples:
/etc/systemd/system/suspend@.service
[Unit]
Description=User suspend actions
Before=sleep.target

[Service]
User=%I
Type=simple
Environment=DISPLAY=:0
ExecStartPre= -/usr/bin/pkill -u %u unison ; /usr/local/bin/music.sh stop ; /usr/bin/mysql -e 'slave stop'
ExecStart=/usr/bin/sflock
ExecStartPost=/usr/bin/sleep 1

[Install]
WantedBy=sleep.target
/etc/systemd/system/resume@.service
[Unit]
Description=User resume actions
After=suspend.target

[Service]
User=%I
Type=simple
ExecStartPre=/usr/local/bin/ssh-connect.sh
ExecStart=/usr/bin/mysql -e 'slave start'

[Install]
WantedBy=suspend.target

But no matter what I could not get it to work.
Any help appreciated.
Thanks.

Offline

#2 2016-11-04 15:33:40

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 79,182

Re: Cannot start i3lock when waking from suspend

Those are executed as UID 1, but you need (and want!) to run i3lock as the user which presently holds the XAUTHORITY and also must tell it which DISPLAY (usually an environment variable) to use.

Also, i suggest you run i3lock right *before* going STR (same problem, though)

Offline

#3 2016-11-06 07:14:46

javadme
Member
Registered: 2016-11-04
Posts: 13

Re: Cannot start i3lock when waking from suspend

seth wrote:

Those are executed as UID 1, but you need (and want!) to run i3lock as the user which presently holds the XAUTHORITY and also must tell it which DISPLAY (usually an environment variable) to use.

Also, i suggest you run i3lock right *before* going STR (same problem, though)


Do you mean:

# systemctl enable suspend@javad.service

Alse I think the DISPLAY variable is ok because when I run the service manually it does some flashing on the display.

Offline

#4 2016-11-06 07:57:45

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 79,182

Re: Cannot start i3lock when waking from suspend

Probably, could you please post (in code tags) the actual service file(s) you've created (ie. not the wiki example) and their status?

Offline

#5 2016-11-06 09:05:29

javadme
Member
Registered: 2016-11-04
Posts: 13

Re: Cannot start i3lock when waking from suspend

seth wrote:

Probably, could you please post (in code tags) the actual service file(s) you've created (ie. not the wiki example) and their status?

Sure:

[Unit]
Description=User suspend actions
Before=sleep.target
[Service]
User=%I
Type=simple
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock
ExecStartPost=/usr/bin/sleep 1
[Install]
WantedBy=sleep.target
[javad@hp_arch system]$ sudo systemctl status suspend@javad.service
● suspend@javad.service - User suspend actions
   Loaded: loaded (/etc/systemd/system/suspend@.service; enabled; vendor preset: di
   Active: inactive (dead)

Nov 06 12:49:09 hp_arch systemd[1]: Starting User suspend actions...
Nov 06 12:49:10 hp_arch systemd[1]: Started User suspend actions.
Nov 06 13:00:45 hp_arch systemd[1]: Starting User suspend actions...
Nov 06 13:00:46 hp_arch systemd[1]: Started User suspend actions.

Inactive(dead)?

Offline

#6 2016-11-06 09:09:31

javadme
Member
Registered: 2016-11-04
Posts: 13

Re: Cannot start i3lock when waking from suspend

Also, my

$ journalctl -xe
-- The system clock has been changed to REALTIME microseconds after January 1st, 19
Nov 06 13:06:33 hp_arch systemd-sleep[1174]: System resumed.
-- Subject: System sleep state suspend left
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- The system has now left the suspend sleep state.
Nov 06 13:06:33 hp_arch systemd[1]: Started Suspend.
-- Subject: Unit systemd-suspend.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit systemd-suspend.service has finished starting up.
-- 
-- The start-up result is done.
Nov 06 13:06:33 hp_arch systemd[1]: sleep.target: Unit not needed anymore. Stopping
Nov 06 13:06:33 hp_arch systemd[1]: Stopped target Sleep.
-- Subject: Unit sleep.target has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit sleep.target has finished shutting down.
Nov 06 13:06:33 hp_arch systemd[1]: Reached target Suspend.
-- Subject: Unit suspend.target has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit suspend.target has finished starting up.
-- 
-- The start-up result is done.
Nov 06 13:06:33 hp_arch systemd[1]: suspend.target: Unit is bound to inactive unit 
Nov 06 13:06:33 hp_arch systemd[1]: Stopped target Suspend.
-- Subject: Unit suspend.target has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit suspend.target has finished shutting down.
Nov 06 13:06:33 hp_arch systemd-logind[283]: Operation 'sleep' finished.
Nov 06 13:06:33 hp_arch kernel: mmc1: cannot verify signal voltage switch
Nov 06 13:06:36 hp_arch kernel: wlan0: authenticate with 30:a8:db:bc:bc:10
Nov 06 13:06:36 hp_arch kernel: wlan0: send auth to 30:a8:db:bc:bc:10 (try 1/3)
Nov 06 13:06:37 hp_arch kernel: wlan0: authenticated

Offline

#7 2016-11-06 10:15:58

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Cannot start i3lock when waking from suspend

javadme wrote:
Type=simple

i3lock forks.

Offline

#8 2016-11-06 10:22:21

javadme
Member
Registered: 2016-11-04
Posts: 13

Re: Cannot start i3lock when waking from suspend

Raynman wrote:
javadme wrote:
Type=simple

i3lock forks.

Haha, using

ExecStart=/usr/bin/i3lock --nofork

solved the issue.
Thank you very much. smile
Should I close the thread or smth?

Offline

Board footer

Powered by FluxBB