19

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?

Thomas Ward
  • 74,764
Quejio
  • 203
  • Did you tick the Lock Screen when screensaver is active option in Screensaver preferences? – Nitin Venkatesh Oct 06 '11 at 15:46
  • there's no screensaver preferences in ubuntu 11.10, it must be with the gnome-settings-daemon, but if there's no way to config... only it locks when the screen is shut down, no when i close the lid – Quejio Oct 06 '11 at 16:27
  • Have a look at this link.. It should help your question

    http://askubuntu.com/questions/2970/where-can-i-change-the-automatic-lock-screen-preference

    – b-ak Oct 06 '11 at 16:32
  • nope, there's no screensaver settings and no gnome-power-manager... ubuntu 11.10 uses now GNOME 3... – Quejio Oct 06 '11 at 16:34
  • It must be with the gsettings command, but org.gnome.desktop.screensaver lock-enabled IS true... – Quejio Oct 06 '11 at 16:45

3 Answers3

5

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:

  1. 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
  2. You should create a directory and a new script file:
    mkdir /etc/acpi/local
    gksudo gedit /etc/acpi/local/lid.sh.post
  3. 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!

  4. 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!

ulidtko
  • 5,782
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.

RolandiXor
  • 51,541
  • well, as I searched I think that you have reason, I think there must be an option like "lockscreen" when you choose the action when closing lid... I hate when I'm at the library, leave my laptop alone for a while, and when I came back I see it trolled by one of my "friends"... ¬¬ and surely i'll not remember always to do Ctrl+Alt+L when the gesture of closing the lid is a better way to do it – Quejio Oct 06 '11 at 18:09
  • @Quejio: I'm sorry but there is nothing I can do for you. The best you can do is have the system suspend when the lid is closed. – RolandiXor Oct 06 '11 at 18:12
  • but when it's supend I lose conversations, stop internet connection if I'm downloading anything... I don't want to stop all the programs because of that – Quejio Oct 06 '11 at 18:24
  • I've added the idea at http://brainstorm.ubuntu.com/idea/28632/ If you want support it, you'll be welcome – Quejio Oct 06 '11 at 18:24
0

Disabling the lock screen using the "Screen" dialog does not always work.

However, this "excessive force" solution does:

sudo mv /usr/bin/gnome-screensaver /usr/bin/gnome-screensaver.disabled

The lock screen is implemented by gnome-screensaver, so if we disable gnome-screensaver, we can never get the lock screen.

Basharat Sialvi
  • 24,046
  • 8
  • 62
  • 82