You are not logged in.
hello,
my laptop can successfully hibernate and suspend using systemctl as a user. Now i want that my screen is locked when i wake up my laptop.
Most people use the following systemd-service to achieve this, here is my version of it:
[Unit]
Description=i3lock
Before=sleep.target
[Service]
User=corn
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock
[Install]
WantedBy=sleep.target(Yes, im using i3 as my wm). This does not work and i have no idea why. Does anyone of you have a idea?
Offline
Try removing the Before= setting. I use the following one which runs fine:
~ cat /etc/systemd/system/xtrlock-on-suspend.service
[Unit]
Description=Lock X session using xtrlock
[Service]
Environment=DISPLAY=:0
User=orschiro
ExecStart=/usr/bin/xtrlock
[Install]
WantedBy=sleep.targetOffline
The changes did not change my situation
Since this is somekind of a user-service what rights does the file have?
Also to eliminate any fails on my side:
/usr/lib/system/user/i3lock.service is readably by anyone and writeable by only root. Also its owned by root.
When i enable the service i run as a user: "systemctl enable i3lock.service --user"
Then i run "systemctl suspend" as a user, and then, when i wake up my laptop, the lockscreen is not shown.
Offline
The changes did not change my situation
Since this is somekind of a user-service what rights does the file have?
It's not a user service. Or at least I tend to think of service files used with a systemd/user instance as user services. This is a system-wide service that is only useful to one user while that user is running an X session. That's not a very clean solution, but I guess it's acceptable for a single-user system and plenty of people seem to use it.
Also to eliminate any fails on my side:
/usr/lib/system/user/i3lock.service is readably by anyone and writeable by only root. Also its owned by root.
You should put that under /etc/systemd and as mentioned before it is not a user service (else why would you put the User= line in there?) so it should be in the "system" directory. Also, sleep.target is a special system unit, so hooking into that target with a user service won't accomplish much.
When i enable the service i run as a user: "systemctl enable i3lock.service --user"
Then i run "systemctl suspend" as a user, and then, when i wake up my laptop, the lockscreen is not shown.
See above regarding the --user part.
Offline
I use xss-lock to manage my screenlocker. It does everything I need like lock on idle, suspend and hibernate.
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |
Offline
I moved the service file now to /etc/systemd/system/i3lock.service and enabled it as root. But still my problem is not solved. I type "systemctl suspend" and when i wake up no lockscreen appears.
Changing "ExecStart" to "/usr/bin/i3lock" also did not change anything ![]()
Last edited by s0ftcorn (2014-06-03 11:44:00)
Offline
Tried your file, even gave it the same name
But it didnt work. Executing i3lock from a terminal works also fine :S
Offline
[corn@brain ~]$ sudo systemctl status -l xtrlock-on-suspend.service
[sudo] password for corn:
● xtrlock-on-suspend.service - Lock X session using xtrlock
Loaded: loaded (/etc/systemd/system/xtrlock-on-suspend.service; enabled)
Active: failed (Result: exit-code) since Di 2014-06-03 16:41:43 CEST; 22min ago
Process: 7592 ExecStart=/usr/bin/xtrlock (code=exited, status=203/EXEC)
Main PID: 7592 (code=exited, status=203/EXEC)
Jun 03 16:41:43 brain systemd[1]: Started Lock X session using xtrlock.
Jun 03 16:41:43 brain systemd[1]: xtrlock-on-suspend.service: main process exited, code=exited, status=203/EXEC
Jun 03 16:41:43 brain systemd[1]: Unit xtrlock-on-suspend.service entered failed state.If this helps anyone understanding my problem, please tell me what kind of magic you used to extract useful information from this ![]()
Offline
Sorry for writing in your topic, but i have the same problem. I wanted to lock screen when resume from suspend to disk (s2disk), and on my new Arch install (64 bits) it just won't work. I created this:
[firekage@arch_desktop /etc/systemd/system]$ sudo cat systemd-i3lock.service
[Unit]
Description=i3lock
Before=sleep.target
[Service]
User=<user>
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock -c 000000
[Install]
WantedBy=sleep.targetbut no luck. After resume, no asks for password.
Offline
[corn@brain ~]$ sudo systemctl status -l xtrlock-on-suspend.service [sudo] password for corn: ● xtrlock-on-suspend.service - Lock X session using xtrlock Loaded: loaded (/etc/systemd/system/xtrlock-on-suspend.service; enabled) Active: failed (Result: exit-code) since Di 2014-06-03 16:41:43 CEST; 22min ago Process: 7592 ExecStart=/usr/bin/xtrlock (code=exited, status=203/EXEC) Main PID: 7592 (code=exited, status=203/EXEC) Jun 03 16:41:43 brain systemd[1]: Started Lock X session using xtrlock. Jun 03 16:41:43 brain systemd[1]: xtrlock-on-suspend.service: main process exited, code=exited, status=203/EXEC Jun 03 16:41:43 brain systemd[1]: Unit xtrlock-on-suspend.service entered failed state.If this helps anyone understanding my problem, please tell me what kind of magic you used to extract useful information from this
AFAIK that 203/EXEC indicates some problem executing the ExecStart command. I don't think xtrlock is the problem (it does work when you manually run xtrlock?), so the only thing I can think of is that you forgot to change the User or you made a typo when you did.
@firekage: at least post systemctl status output.
Last edited by Raynman (2014-06-03 18:01:03)
Offline
Oh. Yeah... i installed "pyxtrlock" not "xtrlock"... With xtrlock everything workes fine. Thanks! But why is i3lock a problem? I really like the style of it so i would be glad to use it ![]()
EDIT:
[corn@brain ~]$ sudo systemctl status -l i3lock.service
● i3lock.service - i3lock for hibernate
Loaded: loaded (/etc/systemd/system/i3lock.service; enabled)
Active: inactive (dead) since Di 2014-06-03 21:45:40 CEST; 1s ago
Process: 15130 ExecStart=/usr/bin/i3lock (code=exited, status=0/SUCCESS)
Main PID: 15130 (code=exited, status=0/SUCCESS)
Jun 03 21:45:33 brain systemd[1]: Started i3lock for hibernate.Soo... i3lock gets started properly but i cannot see it?
Last edited by s0ftcorn (2014-06-03 19:47:16)
Offline
Well, I'm not sure what's going with your setup, but this setup works for me (_not_ using systemd user, but using a suspend@.service enabled as suspend@firecat53.service).
/etc/systemd/system/suspend@.service:
[Unit]
Description=User suspend actions
Before=sleep.target
[Service]
User=firecat53
Type=forking
Environment=DISPLAY=:0
Environment=HOME=/home/firecat53
ExecStartPre= -/usr/bin/mysql -e 'slave stop' ; -/home/firecat53/.local/bin/music.sh stop ; -/usr/bin/pkill -9 unison
ExecStart=/usr/bin/i3lock -i /tmp/wall.png
[Install]
WantedBy=sleep.target# systemctl enable suspend@firecat53.service
# systemctl daemon-reload (just to be sure because you've been messing with the files a bunch)I haven't got around to setting up the systemd user sessions, but this has worked for me for a long time now.
Scott
Edit: just an idiot check: make sure your X session $DISPLAY is actually on :0 !
Last edited by firecat53 (2014-06-03 20:07:46)
Offline
I did "systemctl daemon-reload" after each change of the file, so this should not be a problem. Also if i do "echo $DISPLAY" it outputs :0.0, after changing environment to "DISPLAY=:0.0" (from "DISPLAY=:0"), nothing changes.
Offline
@firekage: at least post systemctl status output.
ok, sorry:
firekage@arch_desktop /etc/systemd/system]$ sudo systemctl status -l i3lock.service sudo systemctl status i3lock.service
● i3lock.service - i3lock
Loaded: loaded (/etc/systemd/system/i3lock.service; enabled)
Active: inactive (dead)
cze 04 15:31:02 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:32:10 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:32:11 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:32:55 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:32:55 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:33:13 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:33:16 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:33:16 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:33:21 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
● sudo.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
● systemctl.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
● status.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
● i3lock.service - i3lock
Loaded: loaded (/etc/systemd/system/i3lock.service; enabled)
Active: inactive (dead)
cze 04 15:31:02 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:32:10 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:32:11 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:32:55 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:32:55 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:33:13 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:33:16 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:33:16 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:33:21 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
cze 04 15:33:21 arch_desktop systemd[1]: [/etc/systemd/system/i3lock.service:4] Failed to add dependency on setting, ignoring: Invalid argument
[firekage@arch_desktop /etc/systemd/system]$ The one thing that is bugging me is why default screen locker for KDE doesen't work, on x32 Arch under AMD it worked, with x64 and Intel, it won't.
Another one
[firekage@arch_desktop /etc/systemd/system]$ sudo systemctl status -l i3lock.service
● i3lock.service - i3lock
Loaded: loaded (/etc/systemd/system/i3lock.service; enabled)
Active: failed (Result: exit-code) since śro 2014-06-04 17:23:44 CEST; 2min 22s ago
Process: 7015 ExecStart=/usr/bin/i3lock -c 000000 (code=exited, status=1/FAILURE)
cze 04 17:23:44 arch_desktop i3lock[7015]: i3lock: Cannot grab pointer/keyboard
cze 04 17:23:44 arch_desktop systemd[1]: i3lock.service: control process exited, code=exited status=1
cze 04 17:23:44 arch_desktop systemd[1]: Failed to start i3lock.
cze 04 17:23:44 arch_desktop systemd[1]: Unit i3lock.service entered failed state.
[firekage@arch_desktop /etc/systemd/system]$ Last edited by firekage (2014-06-04 15:29:48)
Offline
Edit: just an idiot check: make sure your X session $DISPLAY is actually on :0 !
Sorry for nobish question - how to check it? How to change it?
Offline
@firekage
$ echo $DISPLAY
Thanks,
[firekage@arch_desktop ~]$ echo $DISPLAY
:0
[firekage@arch_desktop ~]$ If i would like to change it, where i should do it?
Offline
I checked one thing - strange. When i put in terminal: sudo systemctl restart systemd-hibernate.service, after resume my screen was locked by i3lock. This won't work when use normal suspend, by kde buttons in K>FINISH(or END/CLODE)>HIBERNATION. When i used this, with addes systemd config (copied from //usr/lib/systemd/system/systemd-suspend.service and edited it according to ArchWiki to use systemd and s2disk/s2ram to /etc/systemd/system/systemd-suspend.service) the screen was locked (yes, im glad with at least this) default KDE screen locker, but i liked the i3lock, would like to use it.
Edit: it works!
I disabled default kde screen locker. I think that in order to i3lock work under kde we have to have in system systemd config files.
[firekage@arch_desktop ~]$ sudo systemctl status -l i3lock.service
[sudo] password for firekage:
Niestety, proszę spróbować ponownie.
[sudo] password for firekage:
● i3lock.service - i3lock
Loaded: loaded (/etc/systemd/system/i3lock.service; enabled)
Active: inactive (dead) since śro 2014-06-04 17:45:21 CEST; 2min 32s ago
Process: 1773 ExecStart=/usr/bin/i3lock -c 000000 (code=exited, status=0/SUCCESS)
Main PID: 1776 (code=exited, status=0/SUCCESS)
cze 04 17:43:30 arch_desktop systemd[1]: Started i3lock.
[firekage@arch_desktop ~]$ I use hibernation with uswsusp - suspend to ram on my machine doesen't work at all, it freezes computer.
Last edited by firekage (2014-06-04 15:50:41)
Offline
@s0ftcorn: Had the same problem. I changed sleep.target to suspend.target in the "WantedBy=" field. My service file looks like this
/etc/systemd/system/i3lock.service:
[Unit]
Description=Lock X session using i3lock
[Service]
User=<username>
Type=forking
Environment=DISPLAY=:0
ExecStart=/bin/bash -c "/usr/bin/i3lock -i /home/<username>/path/to/wallpaper.png"
[Install]
WantedBy=suspend.targetHope this helps.
Offline
Mine looks like this:
[firekage@arch_desktop ~]$ cat /etc/systemd/system/i3lock.service
[Unit]
Description=i3lock
Before=sleep.target
#Before=setting
[Service]
User=firekage
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock -c 111111
[Install]
WantedBy=sleep.target
[firekage@arch_desktop ~]$ I did not change "wantedby="
Offline