Xmonad idle lock after X minutes

9

4

Using Ubuntu 10.10. I use XMonad window manager as primary. I have CommandKey+S mapped to a bash file that shows a screensaver and locks, and puts the PC to sleep (on resume I have to enter password).

#/bin/bash

gnome-screensaver-command -a
gnome-screensaver-command -l
dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

This works fine. However I'd like XMonad to automatically run that script (i.e. lock screen and suspend) after X minutes of no keyboard/mouse activity.

I've taken it (basic screensaver/lock/suspend) for granted in other desktops/windows managers.

Mâtt Frëëman

Posted 2011-04-17T03:32:21.560

Reputation: 559

Answers

11

You can use xautolock to do this. For example,

xautolock -time 1 -locker "gnome-screensaver-command -l" -notify 10 \
  -notifier "notify-send -t 5000 -i gtk-dialog-info 'Locking in 10 seconds'"

This will lock your screen after 1 minute of idle time and will give you a notification (lasting 5 seconds) 10 seconds before it locks. This works fine for me in Xmonad.

To use notify-send you may need to

sudo apt-get install libnotify-bin

or something like that. I'm sure you could also substitute out gnome-screensaver for xscreensaver or something else.

Jacob

Posted 2011-04-17T03:32:21.560

Reputation: 211