You are not logged in.
I just switched from sysvinit to systemd on my ThinkPad X220 and tried to use most of its features. Thereby, I used its capability to handle sleep key events and suspend to RAM which beforehead has been done by acpid+pm. If I put my notebook to sleep I want xlock to be started. I don't care if that takes place before or after sleep mode is entered. I just want my notebook to be locked after wake up. For this purpose I had a hook in /etc/acpi/actions/sleep-button.sh:
...
export DISPLAY=:0
xhost +
su -c "DISPLAY=:0; xlock" fixje 2>> /tmp/udev.log &
#suspend
/usr/sbin/pm-suspend
Moving to systemd I created a hook in /usr/lib/systemd/system-sleep/lock-screen.sh
if [ "$1" = "pre" ]
then
export DISPLAY=:0
xhost +
su -c "DISPLAY=:0; xlock -mode blank -bg black -fg green" fixje >> /tmp/udev.log &
fi
Now the problems are as follows:
1. Using the hook stated above, my screen wents black after wakeup and xlock takes 100% of one CPU core. I have to login on a TTY and kill X
2. If I switched "pre" to "post" nothing happened at all. I don't even get any output in the log. I know the hook is executed, because I tested it with some "echo" statements.
P.S.: I'm using awesome wm, acpid is disabled and not running.
Any ideas?
Last edited by fixje (2012-09-12 20:48:37)
Offline
Problem is, that scripts in /usr/lib/systemd/system-sleep/ must exit before the sleep process can continue. The alternative is to create xlock.service with the following (and run 'systemctl enable xlock.service of course):
[Install]
WantedBy=sleep.target
However, I've encountered some problems with xlock starting as daemon, so now I'm using slimlock with following slimlock.service:
[Unit]
Description=Lock X session using slimlock
[Service]
User=lahwaacz
ExecStart=/usr/bin/slimlock
[Install]
WantedBy=sleep.target
Offline
Thank you for the input, lahwaacz. I took your simlock.service and adjusted it to use xlock, which works like a charm.
[Unit]
Description=Lock X session using xlock
[Service]
User=fixje
Environment=DISPLAY=:0
ExecStart=/usr/bin/xlock -mode blank -bg black -fg green
[Install]
WantedBy=sleep.target
Creating a service seems to be the most elegant solution as you don't have to fiddle around in /usr/lib.
Offline
In case anyone's interested, the solution above also works with slock, for those of us who don't need all the bells and whistles that xlock provides.
Unfortunately, it doesn't work with i3lock, which I like because it lets me use an image for the lock screen, instead a solid colour.
Offline
In case anyone's interested, the solution above also works with slock, for those of us who don't need all the bells and whistles that xlock provides.
Unfortunately, it doesn't work with i3lock, which I like because it lets me use an image for the lock screen, instead a solid colour.
works fine for me...
[Unit]
Description=i3lock
Before=sleep.target
[Service]
User=<user>
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock -c 000000
[Install]
WantedBy=sleep.target
Offline
oooh.... thanks, let's try that. Have to admit I've been trying to shortcut the learning curve here, by copy/pasting stuff before I know what it does.
Yeah, that's awesome, working perfectly. Thanks 65kid.
Last edited by tomk (2012-09-15 15:20:32)
Offline
I use xtrlock and my service looks like this:
[Unit]
Description=Lock X session using xtrlock
[Service]
User=jakob
Environment=DISPLAY=:0
ExecStart=/usr/bin/xtrlock
[Install]
WantedBy=sleep.target
I wonder whether it would be wise to create a lock-session@.service and activate it via "systemctl enable lock-session@{xtrlock,slimlock,xlock}.service and have a line calling
ExecStart=/usr/bin/%i
Probably not, as some of the lockers seem to need arguments and one needs to adjust user & display variables as well…
Last edited by jakob (2012-10-31 00:17:02)
Offline
Thanks for this!
Just to save a look to the wiki for some... this file should be created in /etc/systemd/system
Offline
slimlock with following slimlock.service:
[Unit] Description=Lock X session using slimlock [Service] User=lahwaacz ExecStart=/usr/bin/slimlock [Install] WantedBy=sleep.target
Perfect, THANK you. Been messing with it for an hour. This should go in the wiki.
this file should be created in /etc/systemd/system
Extra thanks, that was my first question.
Offline