Linux turn monitor off

How to turn off the display via the command line?

Is there a way to turn off the display (enter power saving mode) using a command? For example, when the computer is inactive for a specific interval, the screen turns off to conserve energy. Is there a way to manually turn off the screen, yet keep the computer running normally? This is a notebook, so there’s no ‘power-off’ button on the monitor itself.

6 Answers 6

I think you are looking for

However, you need to make sure that your acpi is enabled. You can check this with

setterm -powersave powerdown 

Sometimes the Enter keypress as you execute the command can be enough to immediately wake the computer back up again. I usually go with sleep 0.2s && xset dpms force off just to be safe. Also, this makes for a nice replacement for locking your screen: gnome-screensaver-command —lock && sleep 2s && xset dpms force off

I just did the same thing in kubuntu using info from this answer: xdg-screensaver activate && sleep 2s && xset dpms force off

I’m running Ubuntu Server without X on a 2007 MacBook Pro. The display is sleeping by itself but won’t reactivate when a key is pressed on the keyboard. At this point my fix is to use vbetool . Install using apt-get :

sudo apt-get install vbetool 

Then use to turn display on via SSH from a different machine:

vbetool is what I search for exactly! It turn the monitor off completely via BIOS VESA drivers/tools. Just like turning off by using hard key of the monitor!

doesn’^t work (macbook air old) mmap /dev/zero: Operation not permitted Failed to initialise LRMI (Linux Real-Mode Interface).

I have made a unity launcher to turn off the LCD

sudo apt-get install --no-install-recommends gnome-panel gnome-desktop-item-edit ~/Desktop/ --create-new 

It will open a small windows. Enter the following:

Command: gnome-screensaver-command —lock && sleep 2s && xset dpms force off

You can also choose an icon by clicking the icon on the left .

(sleep 10; xset dpms force suspend) & xdg-screensaver lock 

This starts the screen saver in locked mode and then puts your display in standby. Ubuntu Mate 15.10

xset dpms force off worked only for 5 seconds.

I searched the internet and found the following script, and after a small change it worked perfectly.

#!/usr/bin/python import time import subprocess from Xlib import X from Xlib.display import Display display = Display(':0') root = display.screen().root root.grab_pointer(True, X.ButtonPressMask | X.ButtonReleaseMask | X.PointerMotionMask, X.GrabModeAsync, X.GrabModeAsync, 0, 0, X.CurrentTime) root.grab_keyboard(True, X.GrabModeAsync, X.GrabModeAsync, X.CurrentTime) subprocess.call('xset dpms force off'.split()) #original #p = subprocess.Popen('gnome-screensaver-command -a'.split()) #changed p = subprocess.Popen('xset dpms force off'.split()) time.sleep(1) while True: print display.next_event() p.terminate() break 

Источник

How to turn off screen with shortcut in Linux?

Since my monitor takes an awful lot of time to turn back on after being physically turned off, I’m looking for a command or a simple utility to turn off my screen with a shortcut. Setting a black screensaver is not satisfactory; I want the screen to «hibernate» (the same effect I would get by turning off the computer while leaving the screen physically on). The same question for Windows: How can I make my screen blank by a shortcut?

Читайте также:  Linux image amd64 packages

6 Answers 6

to force the screen to turn off.

That’s really great. For the OP though, when a key is pressed, it turns the screen back on. I’m not sure if that’s desirable.

Sometimes works better if you do sleep 1 ; xset dpms force off otherwise remnants of the last keyboard activity (I guess) sometimes turns the screen back on immediately.

This is exactly what I’ve been looking for. Thanks @siva-charan. The only thing I was wondering is how I could ask for a password when I wake the screen. I’m basically using a shortcut to turn off my screen and I would like it to ask for password on wake.

I made a file called /home/me/bin/blank and made it executable chmod +x blank with the following in it:

#!/bin/bash sleep 1; xset dpms force off 

Then I set a shortcut in Gnome3 application «keyboard» ( gnome-control-center keyboard ) to run that script when I push CTRL+ALT+Q.

I liked this 🙂 Just as a little addendum, take a look at systembash.com/… to see how you could set up a timed use of this trick and turn your monitor on/off at specified time

I created a launcher icon on my taskbar that runs the following command: bash -c «sleep 1; xset dpms force off»

I use Alex Cabal script to turn my two monitors screens off and on and it works very fine for me.

#!/bin/bash # turn screens off/on # (ɔ) alex cabal screenOffLockFile=/tmp/screen-off-lock if [ -f $screenOffLockFile ]; then rm $screenOffLockFile notify-send "Screen on." -i /usr/share/icons/gnome/48x48/devices/display.png else touch $screenOffLockFile sleep .5 while [ -f $screenOffLockFile ] do xset dpms force off sleep 2 done xset dpms force on fi 

Источник

Manually turn off monitor

Can I turn off my laptop monitor manually and instantly with just a click or a simple terminal command? I just want to turn off my monitor not locking my machine. There is no dedicated turn off monitor button on my machine.

6 Answers 6

  • To turn off the monitor $ xset dpms force off
  • To turn on the monitor $ xset dpms force on

Pressing a key or moving the mouse will also switch the monitor on if it has been turned off. You can assign the command to a key if you like using shortcuts.

It works, thanks.. I’m just wondering, can I make it to slowly fade off just like when my computer about to sleep?

Is there a way to use this commant with locking my screen? When I lock my screen my monitors don’t turn off, just go black. I want to save power by turning them off while also locking my session. Any ideas?

xset dpms force standby seems to be more reliable and doesn’t need the sleep 1 ; xset dpms force off trick.

Is there any way to apply this only one of two screens? I have multiple displays setup and would like to turn off only one of them e.g. when I watch a movie…

To add on to the other answer, I found that when I entered xset dpms force off and pressed the Enter key, my screen would turn off and turn on again. By running the command below, I was able to get the screen to turn off without turning on.

sleep 3; xset dpms force off 

This method should work everywhere since DPMS or Display Power Management System has appeared in 1993 and by now is integral part of X. If it doesn’t work, that probably means there’s hardware issue, or some really serious bug.

Читайте также:  Linux real time user time

Just to add more options. You can run

xrandr --output --brightness 0 

To determine your display name, simply run xrandr . It will provide you with information on connected displays, so you can actually turn on and off any of them

Beware though, after running this command, you won’t be able to turn your screen on by moving your mouse or using a keyboard. You will have to either use second monitor or blindly type

xrandr --output --brightness 1 

So, X RandR provides you with better control over your screens, but it does what it does. It can also be used for other things, like changing resolution, orientation, rate, etc. It is also very easy to run it inside scripts. If you want, you can write a script to make your screen nicely fade to black. Brightness parameter can take fractions

Note that —brightness option doesn’t actually affect hardware, it only colorizes screen in such way that it becomes dark. Quote from the manual on —brightness option: However, this is a software only modification, if your hardware has support to actually change the brightness, you will probably prefer to use xbacklight .

In Ubuntu 18.04, dpms not working properly with GNOME Wayland

$ xset -q DPMS (Energy Star): Display is not capable of DPMS 

You can try the command below,
to turn off monitor:

busctl --user set-property org.gnome.Mutter.DisplayConfig /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig PowerSaveMode i 1 
busctl --user set-property org.gnome.Mutter.DisplayConfig /org/gnome/Mutter/DisplayConfig org.gnome.Mutter.DisplayConfig PowerSaveMode i 0 

I found the xset dpms force off command works well. However, when assigning a hot key to this command, I ran into trouble: my screen would turn off and back on again.

I found the reason for this was the hot key combo I was using for no particular reason. I discovered the hot key combo «Mod2+Mod4+Super+Hyper+Left shift» assigned to the xset dpms force off command turns the screen off and the screen will not turn on again until a key is pressed or the mouse is used. Exactly what I wanted! That hot key combo is simply the Super (Windows key) used in conjunction with the left shift key. I’m running Ubuntu 16.04 and this is working on my systems.

If you want to do this remotely over an SSH session, you’ll need to specify the DISPLAY number, e.g.,

DISPLAY=:1 xset dpms force off 

If you want to do it for the login screen,

sudo -u gdm env XAUTHORITY=/run/user/$(id -u gdm)/gdm/Xauthority DISPLAY=:0 xset dpms force off 

Without the XAUTHORITY bit you’ll get the mysterious error

No protocol specified xset: unable to open display ":0" 

In general, if some program is using the display, you can figure out how it’s talking to the display server by looking at its environment variables:

$ ps aux | grep gd[m] … gdm 1643 0.1 0.2 3784328 164396 tty1 Sl+ 08:59 0:01 /usr/bin/gnome-shell … $ sudo cat /proc/1643/environ | tr '\0' '\n' … DISPLAY=:0 … XAUTHORITY=/run/user/126/gdm/Xauthority … 

I happened to recognize these specific environment variables as critical, but in a pinch you could use binary search to narrow down the relevant ones. Try running xset with all the environment variables copied over, and if that works, comment out half of them to see if it still works without, and so on.

Источник

Turn off monitor using command line

I am runnning Ubuntu Server on my laptop. There is really no reason for the screen to be on. I have been trying to use this command to turn the screen off:

sleep 1 && xset dpms force off 

11 Answers 11

To turn off monitor in console, the command is the following:

Читайте также:  Отключение графической оболочки linux

To regain control of the console on pressing Enter key, I suggest

sudo sh -c 'vbetool dpms off; read ans; vbetool dpms on' 

Ubuntu 20.04 LTS: vbetool dpms off does not work and says mmap /dev/zero: Operation not permitted and then Failed to initialise LRMI (Linux Real-Mode Interface). . Tried on X11 as root and via ssh as root and on text console as root.

Try these commands.

xset -display :0.0 dpms force off 
xset -display :0.0 dpms force on 

If your display turns off and then immediately back on then try the following which adds a delay of 1 second before turning the screen off. This give a chance for all events to be processed by the X server before turning the display off.

sleep 1 && xset -display :0.0 dpms force off 

The following worked for me (also partially inspired by @enzotib’s answer): xset -display $DISPLAY dpms force off; read temp; xset -display $DISPLAY dpms force on

Be careful with this. I’m unable to turn my monitor back on with a test machine after issuing force off

Update: Pulling out and replugging all cables (including power) on the monitor has remedied the situation.

Ubuntu 20.04 LTS does not work: server does not have extension for dpms option . Blanking via keyboard shortcut (Fn+F6 in my case) works (a bit unreliable, releasing Fn often unblanks screen again). But I need a solution which works via ssh when the Laptop’s keyboard is out of reach. (It’s really annoying if you wake up in bed because the Laptop lights the room. Just a short voice command could invoke ssh to stop the Laptop burning! Note that I disable screensavers on consoles, as there is only one thing which is even more annoying than wrong time console blanking: CapsLock!)

The xset command mentioned in other answers will turn off all the monitors if you have multiple monitor setup. However if you want turn off only one or some of the monitor you should use xrandr .

First run xrandr -q command, which will list all the monitors and its current display settings. At the start of each monitor details you will find monitor name set by the system. You have to keep track of that.

I have two monitors (one is connected to DVI port and other to VGA port) and when I run the command I see this:

Screen 0: minimum 320 x 200, current 1360 x 768, maximum 2726 x 2726 DFP1 connected 1360x768+0+0 (normal left inverted right x axis y axis) 304mm x 228mm 1360x768 59.7*+ . (more details are shown here, but I have hidden it) CRT1 connected 1360x768+0+0 (normal left inverted right x axis y axis) 410mm x 230mm 1360x768 59.8*+ 60.0 . (more details are shown here, but I have hidden it) 

In this output, DVI port connected monitor is labelled as DFP1 and other one as CRT1 . So if I want turn off the secondary monitor(i.e., CRT1 ) I have run this command:

if you want switch on that monitor again then you have run this command:

Источник

Оцените статью
Adblock
detector