Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have Ubuntu 11.10 with Gnome 3 (no Unity), gnome-screen-saver has been removed and replaced with xscreensaver. The screensaver stuff all works fine -- no complaints there. When I close my laptop lid, even for a second, the screen locks (and the dialog box asking for my password is xscreensaver's). I'd like for this not to happen...

Things I've tried/looked at already:

  • xscreensaver settings - the "Lock Screen After" checkbox is not checked (though I've also tried it checked and set to 720 minutes)
  • gconf-editor - apps -> gnome-screensaver -> lock_enabled is not checked
  • System Settings -> Power - "When the lid is closed" is set to "Do nothing" for both battery and A/C
  • System Settings -> Screen - Lock is "off"
  • gconf-editor - apps -> gnome-power-manager -> buttons -> lid_ac && lid_battery are both set to "nothing"

  • dconf-editor - apps -> org -> gnome -> desktop -> screensaver -> lock_enabled is not checked

Output from: gsettings list-recursively org.gnome.settings-daemon.plugins.power:

org.gnome.settings-daemon.plugins.power active true
org.gnome.settings-daemon.plugins.power button-hibernate 'hibernate'
org.gnome.settings-daemon.plugins.power button-power 'suspend'
org.gnome.settings-daemon.plugins.power button-sleep 'suspend'
org.gnome.settings-daemon.plugins.power button-suspend 'suspend'
org.gnome.settings-daemon.plugins.power critical-battery-action 'hibernate'
org.gnome.settings-daemon.plugins.power idle-brightness 30
org.gnome.settings-daemon.plugins.power idle-dim-ac false
org.gnome.settings-daemon.plugins.power idle-dim-battery true
org.gnome.settings-daemon.plugins.power idle-dim-time 10
org.gnome.settings-daemon.plugins.power lid-close-ac-action 'nothing'
org.gnome.settings-daemon.plugins.power lid-close-battery-action 'nothing'
org.gnome.settings-daemon.plugins.power notify-perhaps-recall true
org.gnome.settings-daemon.plugins.power percentage-action 2
org.gnome.settings-daemon.plugins.power percentage-critical 3
org.gnome.settings-daemon.plugins.power percentage-low 10
org.gnome.settings-daemon.plugins.power priority 1
org.gnome.settings-daemon.plugins.power sleep-display-ac 600
org.gnome.settings-daemon.plugins.power sleep-display-battery 600
org.gnome.settings-daemon.plugins.power sleep-inactive-ac false
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-timeout 0
org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'suspend'
org.gnome.settings-daemon.plugins.power sleep-inactive-battery true
org.gnome.settings-daemon.plugins.power sleep-inactive-battery-timeout 0
org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'suspend'
org.gnome.settings-daemon.plugins.power time-action 120
org.gnome.settings-daemon.plugins.power time-critical 300
org.gnome.settings-daemon.plugins.power time-low 1200
org.gnome.settings-daemon.plugins.power use-time-for-policy true

gnome-settings-daemon is running:

<~> $ ps -ef | grep gnome-settings-daemon
1000      1719  1645  0 19:37 ?        00:00:01 /usr/lib/gnome-settings-daemon/gnome-settings-daemon
1000      1726     1  0 19:37 ?        00:00:00 /usr/lib/gnome-settings-daemon/gsd-printer
1000      1774  1645  0 19:37 ?        00:00:00 /usr/lib/gnome-settings-daemon/gnome-fallback-mount-helper

Anything else I can check? Thanks!

share|improve this question
    
Have a try with dconf-editor to see if there are any options there. –  Zoke Jan 14 '12 at 3:31
    
Looked at dconf-editor, posted gsettings output -- doesn't seem to be anything in either of them... –  Joe Casadonte Jan 16 '12 at 20:43
    
is your gnome-settings-daemon running - n.b. this should display two /usr/lib entries ps -ef | grep gnome-settings-daemon –  fossfreedom Jan 16 '12 at 22:57
    
@fossfreedom -- yes, the gnome-settings-daemon is running. –  Joe Casadonte Jan 18 '12 at 1:12
    
I have the same problem. Maybe this is a bug? bugs.launchpad.net/ubuntu/+source/xscreensaver/+bug/994754 –  Aibara Iduas May 14 '12 at 15:27

8 Answers 8

up vote 7 down vote accepted

I managed to figure out a workaround, though I imagine there's a better solution out there. I looked at what was happening when my lid was closed and opened in /etc/acpi/lid.sh and found that xscreensaver was being called upon automatically. Not sure if different laptops have different settings and whatnot - I really don't know too much about this stuff.

In any case, I tried to make it simply obey its config file and not lock, but couldn't figure it out, so I ended up simply deleting the lines that involved xscreensaver. Now everything works great: no locking, and if the lid is closed passed the amount of time which you have set for xscreensaver to start, it'll start normally (and not lock).

I'm still not sure why xscreensaver is set up to be called automatically when the lid is closed or why it ignores its settings and locks when the lid is opened. I also don't get why with my older laptop this only happens sporadically (sometimes it locks every time, sometimes not at all), despite having the same lid.sh file.

I should also note that I'm using Ubuntu 12.04 with Unity, though I don't think that'll make any difference.

share|improve this answer
    
Thank you! Thank you thank you thank you thank you THANK YOU! –  Joe Casadonte Jul 1 '12 at 15:12
    
No problem! It was driving me insane too. –  Aibara Iduas Jul 1 '12 at 22:00
    
Cool solution. I'm having a look in my /etc/acpi/lid.sh at the moment, and I'm not sure which xscreensaver call to comment out - there's an -unthrottle, and a -deactivate. I tried typing 'xscreensaver --help' into command line to see what these do, but it told me that actually 'xscreensaver' is not installed - does that mean I have a different problem? I'm also on Ubuntu 12.04 Unity, but I guess it could be a laptop specific thing: I'm using a lenovo ThinkPad T420s. –  Alex Mar 8 '13 at 0:13
    
Hm, unless you manually installed xscreensaver, you probably don't have it. It is not the default. –  Aibara Iduas Mar 14 '13 at 20:58

Since GTK3 i have used

gsettings set org.gnome.desktop.lockdown disable-lock-screen 'true'

This will prevent all lock-screens. If you still want to be able to lock the screen you can use 'Switch User Account...' as a substitute. For 11.10, just set up a keyboard shortcut for the command

gdmflexiserver -xnest

For 12.04+ its

dm-tool switch-to-greeter
share|improve this answer
    
This works with gnome-screen-saver, but unfortunately not xscreensaver. –  Aibara Iduas May 14 '12 at 15:26
    
The first command alone works in 12.10 –  alfC Nov 19 '12 at 0:38
    
Wonderful, works great on 13.04! For those who want to know what theirs is set to just use "gsettings get org.gnome.desktop.lockdown disable-lock-screen", it will most likely say false. –  Elijah Lynn Jun 7 '13 at 11:34

I am running Gnome Classic on 12.04, and Aibara Iduas's answer didn't work for me, but lead me to the answer. I had to edit /usr/share/acpi-support/screenblank, removing references in it to xscreensaver.

share|improve this answer

In order to disable screen locking on resume set LOCK_SCREEN=false in /etc/default/acpi-support

Running (as root or sudo) this command:

sed -i.bak s/'LOCK_SCREEN=true'/'LOCK_SCREEN=false'/ /etc/default/acpi-support

Will create a backup of the file (/etc/default/acpi-support.bak) and change the required LOCK_SCREEN option to false.

share|improve this answer

I want my screen to be locked when suspending, hibernating, when the screensaver becomes active because of being idle the configured time or when I lock manually.
I don't want the screen to be locked when I close the lid for a short time (while I am transporting my laptop). When closing the lid I want only to switch off the display.
All this can be configured via GUI-utils, except not locking the screen when the lid is closed — this feature seems to be missing in current GNOME :(

Nevertheless, the following script is doing the job for me

=== /etc/acpi/local/lid.sh.pre ===

#!/bin/bash

. /etc/default/acpi-support  ## in this file: LOCK_SCREEN_LID=false

function fail () {
  echo $@ >> /tmp/lid_no_screensaver.log
  beep
}

function screensaver_disable () {
  export DISPLAY=$1
  USER=$2
  if sudo -u $USER LANG=C gnome-screensaver-command -q | grep -q 'screensaver is active' ; then
    TIME_ACTIVE=$(DISPLAY=':0' sudo -u joe LANG=C gnome-screensaver-command --time | sed -r -e 's/The screensaver has been active for ([[:digit:]]*) seconds./\1/')
    [ $TIME_ACTIVE -ge 10 ] && return  ## we don't stop the screensaver when he should lock
  fi

  sudo -u $USER gnome-screensaver-command --deactivate
  ( sleep 1
    sudo -u $USER LANG=C gnome-screensaver-command -q | grep -q 'screensaver is inactive' || fail 'Unable to deactivate screensaver :('
  ) &
}

if [ "$LOCK_SCREEN_LID" = false ] ; then
  for DISPLAY in $(ps aux | grep X | grep -v grep | sed -e 's|^[^/]*||' | cut -d' ' -f2) ; do
    for USER in $(ps aux | grep gnome-screensaver | grep -v grep | cut -d' ' -f1) ; do
      if ! grep -q open /proc/acpi/button/lid/*/state; then
        screensaver_disable $DISPLAY $USER
      fi
    done
  done
fi

=== /etc/default/acpi-support ===

LOCK_SCREEN_LID=false

Tested with gnome-screensaver + GNOME 3.4.2 + Debian Wheezy

share|improve this answer

None of the answers above worked for me. I had to do this:

sudo vim /etc/UPower/UPower.conf

# <snip> ...

ignoreLid=true

# <snip> ...

It required a reboot to take effect. And your other Ubuntu/GNOME settings respecting Lid events are probably nuked.

share|improve this answer

I'm running Ubuntu 12.04 Classic (meaning Unity, I think), and had the same trouble. Here's what I wanted: When the screen is not locked, closing and reopening the lid should not cause the screen to lock.

This is easily achievable by dconf-editor; simply browse to org > gnome > desktop > screensaver and uncheck the lock-enabled entry.

PS: It seems easy to do, but the answer was hard to find.

share|improve this answer

Install gnome-tweak-tool Install gnome-tweak-tool. Click on "Shell" on the right and there you can choose what to do with or without the battery.

share|improve this answer
    
Sadly they both said "do nothing". –  Joe Casadonte Jan 21 '12 at 0:43
    
These options don't seem to do what is being asked for; at least on Ubuntu 12.04. –  Gurjeet Singh Feb 10 at 20:53

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.