How do I configure the screen to lock when I close the lid?
I've configured Ubuntu to put the screen in black when I close the lid of the laptop, but I want that, when I open it again, it demand the password like blocking the screen with Ctrl+Alt+L, but I can't find the correct option. Could you tell me?
Solution 1:
I am having the same problem in my laptop with Ubuntu 11.10... While a "full" solution is not developed by the community (i.e., adding a 'lock' option in the power manager), I have implemented my own solution. In order to implement my solution, you have to do the following steps:
- Using the "Power manager" or "Gnome Tweak Tool" you should configure your laptop to "do nothing" when lid is closed. If you want to install the Gnome Tweak tool, you should use the following command:
sudo apt-get install gnome-tweak-tool
- You should create a directory and a new script file:
mkdir /etc/acpi/local
gksudo gedit /etc/acpi/local/lid.sh.post
- The new file should contain the following code:
#!/bin/sh ######################################################################### ## Script written by Rafael Fernandes Lopes and Thyago Mendes Neves ## ## Twitter: @rafaelf_l and @ThyagoNeves ## ## ## ## Description: This script locks the screen when the laptop lid is ## ## closed in Ubuntu 11.10 (Oneiric Ocelot). ## ## ## ## This script can be freely redistributed, modified and used. ## ## Any redistribution must include the information of authors. ## ## ## ## THIS SCRIPT HAS NO WARRANTY! ## ######################################################################### grep -q close /proc/acpi/button/lid/*/state if [ $? = 0 ]; then # Some system process is used to verify who is the current logged user. PROCESS_PID=`pidof gnome-session` CURRENT_USER=`ps up $PROCESS_PID | awk '{if ($1 != "USER") { print $1 }}'` DBUS_SESSION_BUS_ADDRESS=`grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PROCESS_PID/environ | sed -e 's/DBUS_SESSION_BUS_ADDRESS=//'` export DBUS_SESSION_BUS_ADDRESS su -c "gnome-screensaver-command -l" $CURRENT_USER fi
Save it! - After saving and closing the created script, you must set the execution permission:
sudo chmod +x /etc/acpi/local/lid.sh.post
Ok! Now, you can test the script closing your laptop!
Solution 2:
To my knowledge, this is no longer possible, because of the limited options available in GNOME 3.x as of now. You can report a bug on launchpad or upstream about it, but I'm not sure if the option will be added, as such bugs often end up just devolving into endless discussion with no actual solution (being honest here).
The best you can do is have the system suspend when the lid is closed.