3

I recently made the switch to dwm as the default window-manager on my laptop. It being a no frills software, I had to configure a few things that I usually don't have to worry about.

While I got most things to work, I can't seem to figure out a foolproof way to lock the screen on the laptop. Currently, I have a partially working solution using a program called xautolock. Which manages to lock the screen after a specified timeout. But it fails to lock the screen after wake-up. Which is important to me.

 xautolock -time 10 -locker slock

Any ideas?

6
  • have you tried xssstate or xss (links available on suckless.org) Commented Oct 15, 2015 at 12:20
  • 1
    If you use systemd, you can have a service file that locks the screen on wakeup. Commented Oct 15, 2015 at 20:53
  • and if you don't use systemd, you can run a script on suspend/hibernate using the pm-utils package. Commented Oct 17, 2015 at 14:24
  • @jasonwryan Yup. Creating a systemd service fixed the problem. Commented Oct 17, 2015 at 19:38
  • You should post your service as an answer and accept it: it will help someone else who stumbles on this via a search. Commented Oct 17, 2015 at 19:42

3 Answers 3

2

You can use xss-lock and it works without a systemd unit. It listens to DPMS as well.

You can add these lines to your $HOME/.xinitrc right before starting dwm.

xset dpms 180 &
xss-lock -- slock &
exec dwm
1
  • Welcome to the site. You may want to add some explanation on where these commands shoud be located, so that users reading your answer know more easily how to apply it. Commented Jan 16, 2020 at 8:29
1

Creating a separate systemd service seems like a clean way to solve the problem. Also on a system running sysinit one can launch slock using suspend/resume hooks.

[Unit]
Description=Lock the screen on resume from suspend

[Service]
User=jason
Environment=DISPLAY=:0
ExecStart=/usr/bin/slock

[Install]
WantedBy=suspend.target
1
  • 1
    Nice username :) Commented Oct 17, 2015 at 19:47
0

You can use suckless's own lock tool called slock. it in my opinion is the best paring with dwm because it has the same minimalist design. you can download the source code from here: https://tools.suckless.org/slock/

all you need to do after is go in to the config.h file and change:

static const char *user  = "nobody";
static const char *group = "nogroup";

To this:

static const char *user  = "<USERNAME>";
static const char *group = "wheel";

Change to your username of computer.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.