33

I am using xset dpms force off to manually turn my screen off to save power. However, it turns back on after some time (20 - 40 seconds).

Distro: Ubuntu-Lucid

Graphics: Intel 4500 MHD

Trying steps in this solution (Turning off screensaver or wireless) did not work. Can it be due to any other reasons like network (magic packet) or usb devices?

Result of xset -q:

Keyboard Control:
  auto repeat:  on    key click percent:  0    LED mask:  00000000
  XKB indicators:
    00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off
    03: Compose:     off    04: Kana:        off    05: Sleep:       off
    06: Suspend:     off    07: Mute:        off    08: Misc:        off
    09: Mail:        off    10: Charging:    off    11: Shift Lock:  off
    12: Group 2:     off    13: Mouse Keys:  off
  auto repeat delay:  500    repeat rate:  30
  auto repeating keys:  00ffffffdffffbbf
                        fadfffefffedffff
                        9fffffffffffffff
                        fff7ffffffffffff
  bell percent:  50    bell pitch:  400    bell duration:  100
Pointer Control:
  acceleration:  2/1    threshold:  4
Screen Saver:
  prefer blanking:  yes    allow exposures:  yes
  timeout:  0    cycle:  0
Colors:
  default colormap:  0x20    BlackPixel:  0    WhitePixel:  16777215
Font Path:
  /usr/share/fonts/X11/misc,/usr/share/fonts/X11/100dpi/:unscaled,/usr/share/fonts/X11/75dpi/:unscaled,/usr/share/fonts/X11/Type1,/usr/share/fonts/X11/100dpi,/usr/share/fonts/X11/75dpi,/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType,built-ins
DPMS (Energy Star):
  Standby: 0    Suspend: 0    Off: 0
  DPMS is Enabled
  Monitor is On
6
  • 1
    You're using it manually from command line or xset is binded to some keyboard shortcut? On my brother laptop this command was binded to some keys and after that monitor was turned off and on again, because when he was releasing key next event was emitted. Turning it off after quick sleep solved problem: perl -e 'select(undef,undef,undef,.1)' && xset dpms force off - this perl expression do sleep for 0.1 sec.
    – pbm
    Commented Dec 1, 2010 at 20:40
  • I used to have the shortcut key problem too thats why created an icon. Your perl -e 'select(undef,undef,undef,.1)' && xset dpms force off command when typed in terminal did the work. Now trying this with the shortcut icon.
    – crodjer
    Commented Dec 1, 2010 at 21:07
  • The command does not work with the shortcut icon.
    – crodjer
    Commented Dec 1, 2010 at 21:24
  • Maybe increase the sleep (also I would use the command "sleep n" to sleep n seconds); it might be that your clicking the icon and moving the mouse(sliding your fingers over the touchpad) sends later events.
    – kasterma
    Commented Dec 2, 2010 at 16:54
  • no, I cant execute two commands directly frm a shortcut, will try creating a script.
    – crodjer
    Commented Dec 2, 2010 at 19:21

12 Answers 12

12

This seems to be a known bug and you can read more detail on launchpad as well as on ubuntuforums. The issue is that somehow gnome-power-manager and the xset commands conflict with each other.

The solution is to run xset dpms force off in a loop, a python script pretty much works for most of us.

Give it a try, and see how it goes.

8

Try adding a sleep:

$ sleep 1; xset dpms force off
4
  • 1
    One-line answers are often not the most helpful since they offer little explanation. Consider expanding your answer to elaborate on why your solution works or with documentation that supports your suggestion.
    – HalosGhost
    Commented Aug 3, 2014 at 23:36
  • 1
    this does not work for me
    – Tropilio
    Commented Feb 3, 2020 at 16:25
  • 1
    Doesn't work for me.
    – Marcus
    Commented Sep 6, 2022 at 14:53
  • 1
    For a keyboard shortcut combining two commands in this way does not work, but combining these two commands with the help of bash -c worked for me as describe in this answer: unix.stackexchange.com/a/720365/451738
    – Jakob
    Commented Jan 19, 2023 at 20:32
7

Don't know if this is still an issue in Gnome in 2022, but I noticed I had this exact problem when I have my Dell monitor plugged in through HDMI but not when I am just using the laptop by itself.

For me it was actually the Input Source Auto-select function on my Dell monitor that caused the monitor to wake back up again 5 seconds after sleep. I simply disabled this on the monitor's OSD and it was fine after that.

You can test whether it is specific to your laptop display or your monitor by seeing whether it works fine with one or the other disabled/disconnected.

4
  • Thank you! This had been driving me bonkers on a Raspberry Pi. Unfortunately, I have an HP monitor and cannot disable Input Source Auto-select. I hope someone finds a workaround which can fix the HDMI side which is triggering this.
    – hackerb9
    Commented Aug 30, 2022 at 20:49
  • You may want to add this to your answer: Even without a second monitor you can test whether this is the issue by using xset s noblank s 10 . That uses the old X Windowing System screen saver from the time before monitors could be put to sleep via the "vblank" signal. It will show the X crosshatch pattern after ten seconds of being idle. If it wakes up shortly afterward, this is not your problem. If it continues to show the crosshatch, then you have found your bug (and hopefully, solution).
    – hackerb9
    Commented Aug 30, 2022 at 21:02
  • Intesting attempt! Didn't work on my system.
    – Marcus
    Commented Sep 6, 2022 at 14:57
  • 1
    @hackerb9 I have an HP monitor and, for me, the thing to toggle is the "Auto-Switch Source" option in the "Source Control" menu (i.e. the source selector) brought up by pressing the Source/+ button when no OSD is visible.
    – ssokolow
    Commented Oct 12, 2023 at 11:05
3

I've tried many solutions but in the end, this worked:

bash -c 'sleep 0.1 && xset dpms force off'

It's short and precise, also there are no loops.

How this works

In my case releasing the key after the shortcut triggered the screen to wake up again. sleep 0.1 delays the execution of xset dpms force off by 0.1 second (bash -c allows to run both commands together). So if you release the buttons faster than 0.1 seconds after you pressed them it works. If you are slower replace 0.1 by a larger number, e.g. 0.5.

2
  • 1
    bash -c 'sleep 0.1 && xset dpms force off' solved the problem for me. Don't forget the quotation mark ' at the end! (bash -c needs to get a string surrounded by quotation marks)
    – Jakob
    Commented Jan 19, 2023 at 12:25
  • Thanks for for being meticulous and making the edit!
    – maciejwww
    Commented Jan 19, 2023 at 15:57
1

I've had that problem before, basically my mouse was causing it, flip the side on it's back when you aren't using it.

2
  • 1
    @oneofone...This can't be the problem in mycase. I have a laptop, hence no mouse.
    – crodjer
    Commented Dec 2, 2010 at 4:04
  • 1
    +1 to neutralize the down vote. Though this answer wasn't applicable to my problem, still needn't be negatively voted.
    – crodjer
    Commented Nov 12, 2014 at 7:32
1

I assume that loop has a sleep otherwise I wouldn't use it. I used cron with this set to run every 5 mins (enter crontab -e from the command-line as your X11 logged in user):

*/5 * * * * /usr/bin/env DISPLAY=:0.0 xset -dpms
1

For me, i was playing a video in the background, causing screen to always re-turn on after 5 seconds ... I added sleep before command and stopped video and it worked.

1

Had this problem on AMD/HP laptop. Also running 10.04.3/32, same problem. Got this solution from another forum:

#!/bin/sh  
perl -e 'select(undef,undef,undef,.1)' && xset dpms force off

I put that in a sh file, set it executable, and linked that to the panel shortcut. Worked like a charm, monitor stays off. I've got no idea what the hell that weird perl script does.

1
  • 2
    select at perldoc.perl.org reveals it's a way to sleep 100ms. Depending on your /bin/sleep, sleep 0.1 could achieve the same. (Not that I understand why this sleep is there at all.)
    – sr_
    Commented Apr 13, 2012 at 11:13
0

If non of the above worked for you. I had the same problem on a 64bit linux mint machine. The only thing that worked for me was this python script :

import sys, select, subprocess
while True:
    p = subprocess.Popen(['xset', 'dpms', 'force', 'off'], 
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    if sys.stdin in select.select([sys.stdin], [], [], 0)[0]:
        break
1
  • this works but the screen does not turn on when moving the mouse or pressing a button
    – Tropilio
    Commented Feb 3, 2020 at 16:32
0

I tried all the solutions above; the only thing that worked for me was to kill kscreen_backend_launcher process and disable it. See here

0

I think that the sleep thing will solve it for me too, however, generally, I use xscreensaver and it's been configured to turn off the display after 30 minutes. I've had it set like that for years and it worked. But now it stopped working. My displays remain on.

I have a script called lightsout.sh which turns off the monitors and I can use that but this is a manual thing where xscreensaver used to handle this automatically.

0

I wanted to turn the screen off while listening to music to preserve battery power.

I was using mplayer initially and the screen kept turning back on after a few seconds. I switched to a command line audio player (MOC - console audio player).

Just wanted to share that option. It works for me for the moment.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .