Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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