3

I have a laptop that runs Debian Jessie with only the Linux console - no X server installed.

A recent dist-upgrade replaced sysvinit with systemd.

Now I'm trying to get systemd to lock the console when the computer sleeps (this was previously handled by a script in /etc/pm/sleep.d.)

I've tried this:

/etc/systemd/system/screenlock.service:

[Unit]
Description=Lock X session using slock
Before=sleep.target

[Service]
User=<username>
ExecStart=/usr/bin/vlock -ans

[Install]
WantedBy=sleep.target

And then:

systemctl enable screenlock.service

A similar solution works for me on another computer with X but this isn't working in the console.

How can that be?

  • You don't need that. Look at the Systemd Sleep.service – eyoung100 Oct 1 '14 at 18:28
  • The point is that I want my machine locked it suspends or hibernates ... – MajorBriggs Oct 1 '14 at 18:33
  • apt-cache search vlock – eyoung100 Oct 1 '14 at 18:41
  • Yep, vlock is a console screen locking program - I want systemd to lock my consoæle with it on hibernate and suspend ... – MajorBriggs Oct 1 '14 at 18:59
  • The reason its not Working is because the real terminal uses the ACPI sleep function in your BIOS, where as the one working uses the Timer set in your DE. I dunno of any service that interfaces with ACPI so we will wait... – eyoung100 Oct 1 '14 at 19:06
1

Scripts in /usr/lib/systemd/system-sleep/ will be executed pre and post suspension|hibernation when using systemctl suspend, so you can add a script to start vlock from there. Lots of detail here in the ArchLinux Systemd Wiki page.

1

I got it working by using physlock instead of vlock with the /etc/systemd/system/screenlock.service file like this:

[Unit]
Description=Lock X session using slock
Before=sleep.target

[Service]
User=<username>
ExecStart=/usr/local/bin/physlock -d

[Install]
WantedBy=sleep.target

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.