Is there a way of making Ubuntu (through the command line) to lock the screen after X minutes?
I need to do so for example:
- I'm watching a two-hours movie, so I need to make Ubuntu lock the screen that after 123 minutes.
Use:
gnome-screensaver-command --lock
So you could run, for example, ((sleep $[123*60]; gnome-screensaver-command -l)&)
to run gnome-screensaver-command
after 123 minutes (123*60 seconds).
But there is a more convenient way:
Remember that you can simplify that command. gnome-screensaver-command --lock
is quite a long command to write, so you can make it easier by creating an alias for it.
Simply run
gedit ~/.bashrc
Now scroll down to the end of the file and add the following line
alias lock='gnome-screensaver-command --lock'
After having saved the file, whenever you run the command lock
it actually executes gnome-screensaver-command --lock
. Remember that .bashrc isn't a file you would normally see in your home folder because it is hidden by default. If you want it to pop into view just browse to your home folder in nautilus and press Ctrl + H.