32

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
Clock ZHONG
  • 103
  • 4
crodjer
  • 443
  • 1
  • 4
  • 9
  • 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 Dec 01 '10 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 Dec 01 '10 at 21:07
  • The command does not work with the shortcut icon. – crodjer Dec 01 '10 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 Dec 02 '10 at 16:54
  • no, I cant execute two commands directly frm a shortcut, will try creating a script. – crodjer Dec 02 '10 at 19:21
  • I have this problem and I'm not even using Ubuntu. I'm using EndeavourOS with `i3`. I've tried everything I could think of, but nothing I did worked. – Anthony Nov 16 '22 at 05:48

10 Answers10

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.

djeikyb
  • 348
  • 1
  • 10
Bibek Shrestha
  • 221
  • 1
  • 3
8

Try adding a sleep:

$ sleep 1; xset dpms force off
Michael Mrozek
  • 91,316
  • 38
  • 238
  • 232
e3pk
  • 104
  • 1
  • 1
  • 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 Aug 03 '14 at 23:36
  • 1
    this does not work for me – Tropilio Feb 03 '20 at 16:25
  • 1
    Doesn't work for me. – Marcus Sep 06 '22 at 14:53
  • 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: https://unix.stackexchange.com/a/720365/451738 – Jakob Jan 19 '23 at 20:32
5

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.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Vijay Prema
  • 151
  • 1
  • 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 Aug 30 '22 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 Aug 30 '22 at 21:02
  • Intesting attempt! Didn't work on my system. – Marcus Sep 06 '22 at 14:57
2

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.

AdminBee
  • 21,637
  • 21
  • 47
  • 71
maciejwww
  • 121
  • 6
  • 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 Jan 19 '23 at 12:25
  • Thanks for for being meticulous and making the edit! – maciejwww Jan 19 '23 at 15:57
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.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
  • 2
    [`select` at `perldoc.perl.org`](http://perldoc.perl.org/functions/select.html) 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_ Apr 13 '12 at 11:13
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

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.

OneOfOne
  • 1,375
  • 9
  • 16
  • 1
    @oneofone...This can't be the problem in mycase. I have a laptop, hence no mouse. – crodjer Dec 02 '10 at 04:04
  • 1
    +1 to neutralize the down vote. Though this answer wasn't applicable to my problem, still needn't be negatively voted. – crodjer Nov 12 '14 at 07: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
slm
  • 363,520
  • 117
  • 767
  • 871
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
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

AdminBee
  • 21,637
  • 21
  • 47
  • 71
Arash
  • 11
  • 3