Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Determine if LCD Monitor is Turned on From Linux Command Line

How do you tell if a computer's monitor(s) are turned on/off from the command line in Linux? I've traditionally thought of monitors as output-only devices, but I've noticed the Gnome Monitor Preferences dialog has a "detect monitor" function. Can this be generalized to determine if a monitor is physically turned off?

like image 463
Cerin Avatar asked Aug 08 '10 05:08

Cerin


People also ask

What is the Linux command to display?

OVERVIEW. The display program is a member of the ImageMagick(1) suite of tools. Use it to isplay an image or image sequence on any X server. For more information about the display command, point your browser to file:///usr/share/doc/ImageMagick-6.2.8/www/display.html or http://www.imagemagick.org/script/display.php.

How do I find my display name in Linux?

DISPLAY NAMES From the user's perspective, every X server has a display name of the form: hostname:displaynumber. screennumber [...] displaynumber [...] To avoid confusion, each display on a machine is assigned a display number (beginning at 0) when the X server for that display is started.

How do I switch displays in Linux?

When you do a nested screen, you can switch between screens using keys “Ctrl-A” and “n“. It will move to the next screen. When you need to go to the previous screen, just press “Ctrl-A” and “p“. To create a new screen window, just press “Ctrl-A” and “c“.


2 Answers

The VESA DDC connection is an I2C connection that can be used to query the presence of the monitor.

Linux exposes the I2C device and userland programs can communicate directly with the monitor with code such as that at http://jaffar.cs.msu.su/oleg/ddcci/

Notice this below: Control 0xe1: +/1/1 [SAM: Power control (0 - off/1 - on)]

# ddcci-tool /dev/i2c-2 -e -c -d   ddcci-tool version 0.03  Reading EDID : 0x50@/dev/i2c-2     Plug and Play ID: SAM00BA     Input type: Analog  Using ddc/ci : 0x37@/dev/i2c-2  Capabilities: (type(LCD)vcp(04 05 10 12 60(1 3) B0(1 2) B6 C6 C8 C9 D6(1 4) DC(1 2 3 4) DF))  Controls (valid/current/max): Control 0x04: +/0/1 [Reset Factory Defaults] Control 0x05: +/0/1 [SAM: Reset Brightness and Contrast] Control 0x06: +/0/1 [Reset Factory Geometry] Control 0x08: +/0/1 [Reset Factory Default Color] Control 0x0e: +/60/120 [SAM: Image Lock Coarse] Control 0x10: +/0/100 [Brightness] Control 0x12: +/50/100 [Contrast] Control 0x16: +/8/16 [Red Video Gain] Control 0x18: +/8/16 [Green Video Gain] Control 0x1a: +/8/16 [Blue Video Gain] Control 0x1e: +/0/2 [SAM: Auto Size Center] Control 0x20: +/50/100 [Horizontal Position] Control 0x30: +/25/54 [Vertical Position] Control 0x3e: +/39/50 [SAM: Image Lock Fine] Control 0x60: +/1/3 [Input Source Select] Control 0x62: +/0/100 [Audio Speaker Volume Adjust] Control 0x6c: +/140/255 [Red Video Black Level] Control 0x6e: +/127/255 [Green Video Black Level] Control 0x70: +/121/255 [Blue Video Black Level] Control 0xb0: +/0/2 [Settings] Control 0xb6: +/3/8 [???] Control 0xc6: +/1/1 [???] Control 0xc8: +/5/16 [???] Control 0xc9: +/1/0 [???] Control 0xca: +/2/2 [On Screen Display] Control 0xcc: +/2/11 [SAM: On Screen Display Language] Control 0xd6: +/1/4 [SAM: DPMS control (1 - on/4 - stby)] Control 0xdc: +/4/4 [SAM: MagicBright (1 - text/2 - internet/3 - entertain/4 - custom)] Control 0xdf: +/512/0 [VCP Version] Control 0xe0: +/0/2 [SAM: Color preset (0 - normal/1 - warm/2 - cool)] Control 0xe1: +/1/1 [SAM: Power control (0 - off/1 - on)] Control 0xe2: +/0/1 [???] Control 0xed: +/108/255 [SAM: Red Video Black Level] Control 0xee: +/101/255 [SAM: Green Video Black Level] Control 0xef: +/103/255 [SAM: Blue Video Black Level] 

An interesting question is whether or not your monitor returns that piece of data, and if not, whether it responds at all if it's currently turned off.

like image 108
Joe Koberg Avatar answered Oct 06 '22 10:10

Joe Koberg


From systembash.com, here is the code taken from the link, in case it will be down some day:

#!/bin/bash export DISPLAY=:0.0  if [ $# -eq 0 ]; then   echo usage: $(basename $0) "on|off|status"   exit 1 fi  if [ $1 = "off" ]; then   echo -en "Turning monitor off..."   xset dpms force off   echo -en "done.\nCheck:"   xset -q|grep "Monitor is" elif [ $1 = "on" ]; then   echo -en "Turning monitor on..."   xset dpms force on   echo -en "done.\nCheck:"   xset -q|grep "Monitor is" elif [ $1 = "status" ]; then   xset -q|sed -ne 's/^[ ]*Monitor is //p' else    echo usage: $(basename $0) "on|off|status" fi 
like image 23
0x90 Avatar answered Oct 06 '22 09:10

0x90