15

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!

8 Answers8

7

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.

Fern Moss
  • 8,785
  • Thank you! Thank you thank you thank you thank you THANK YOU! – Joe Casadonte Jul 01 '12 at 15:12
  • No problem! It was driving me insane too. – Fern Moss Jul 01 '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 08 '13 at 00:13
  • Hm, unless you manually installed xscreensaver, you probably don't have it. It is not the default. – Fern Moss Mar 14 '13 at 20:58
  • 2
    Hey, I'm having the same issue on Ubuntu 14.04 but apparently there is no /etc/acpi/lid.sh file. Is it the same for you? do you have another solution? – Yekhezkel Yovel Sep 06 '14 at 13:47
  • @Yekhezkel Yovel - Hm, I'm not sure. I no longer have that file either, so something must have changed with 14.04. But I also no longer have the problem, so I can't test things out. This answer might give you a clue: http://askubuntu.com/questions/517683/laptop-doesnt-hibernate-when-i-close-the-lid-in-ubuntu-14-04. If not, maybe ask a new question. – Fern Moss Sep 08 '14 at 16:10
  • I used to have this issue but it is gone now. I am using Ubuntu 16.04 - did they fix it? – Adam Apr 25 '17 at 07:49
  • @Adam I assume so? I haven't had this issue for years. – Fern Moss May 02 '17 at 01:26
4

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.

  • BTW: This is the same setting that is in Settings->Brightness and Lock->Lock. Confirmed working in Ubuntu 14.04, closing the lid doesn't lock the system anymore. Probably this was a bug in earlier versions of Ubuntu. – jmiserez Feb 15 '15 at 09:09
  • That solved the problem in Ubuntu MATE, however I had to navigate to org-mate-screensaver to uncheck the entry. – Muzaffar Mar 18 '16 at 01:36
  • Works for me on Ubuntu 20.04 with Unity. – Garrett Aug 06 '21 at 21:05
  • Works for me on Ubuntu 22.04 with Unity. – Garrett May 08 '23 at 06:09
3

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
edm
  • 4,005
1

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.

0

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.

pl1nk
  • 6,399
0

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

0

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.

pztrick
  • 412
  • 4
  • 10
-1

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.

rockr101
  • 1,421