Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a low power PC as a updating status screen, using firefox at fullscreen mode and a plugin called "Reload Every".

M-F from 8 AM to 6 PM, I need the app set to no-screensaver and no-screenlock

Every other time I want the screen locked.

The purpose is basic security when no one else is around. I don't have to use gnome-screensaver to accomplish these goals. I just want to disable and enable the keyboard, mouse and screen without entering in a password, automatically.

I was thinking of using cron and a shell script or python to swap a config file, but the gnome-screensaver man page is a bit lacking, and I have no idea what it uses for configuration.

share|improve this question
ah, never mind, but I'll keep the question up for google's sake. .... to lock from the command line: .... gnome-screensaver-command -l .... To unlock .... gnome-screensaver-command -d .... I should be able to stick this into crontab and test it shortly. – user886694 Mar 14 '12 at 23:05
Could you answer your own question with "Post Your Answer" please. It will be useful for people searching for an answer in the future. – Jjed Mar 14 '12 at 23:25
love to, except that askubuntu does not allow that at my experiance level for likew 72 hours, plus I need to test it in crontab anyway – user886694 Mar 15 '12 at 14:40
@user886694 Quite some time has passed, so you should be able to post your own answer now. I highly recommend doing so! – Eliah Kagan Oct 1 '12 at 2:57
If you have solved the issue could you post the answer, otherwise I might have a go at solving it – Marwan Alsabbagh Oct 4 '12 at 18:54

For those who want to use a GUI, this can quite easily be done with Cuttlefish, a "reaction based tool" that changes Ubuntu settings/appearance based on the environment (time of day, plugged in/out, connected to the internet, etc).

Two things need to be done. First, choose the environment when the action should take place. In this case the date & time.

enter image description here

Then choose which settings should change. In this case unlocking the screen and turning off the screensaver.

enter image description here

Cuttlefish is probably not the most resource-efficient option for this particular task but it's the easiest way I know of.

share|improve this answer

user886694's solution above is not complete. You need to include 'export DISPLAY=:0.0' before your unlock and lock commands like this:

To lock the screen add this to crontab...

export DISPLAY=:0.0 && gnome-screensaver-command -l

And to unlock...

export DISPLAY=:0.0 && gnome-screensaver-command -d

The best GUI tool I've found for adding crons through an interface is gnome-schedule which can be installed using:

sudo apt-get install gnome-schedule

Once installed, the program will be called "Scheduled Tasks" in your 'Dash Home'. To use it, simply add a new task and enter a brief description, the command and time you want the lock or unlock to run.

share|improve this answer

Your Answer


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.