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?
相关问题
- How to get the return code of a shell script in lu
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Invoking Mirth Connect CLI with Powershell script
- Error building gcc 4.8.3 from source: libstdc++.so
You can get some info using the xrandr command-line utility, if your video driver supports this extension.
When using xset it always returns xset: unable to open display ""
However, "xset dpms force off" & "xset dpms force off" commands actually turn my monitor off and on. I am using the script outlined here -
http://systembash.com/content/how-to-turn-off-your-monitor-via-command-line-in-ubuntu/
From systembash.com, here is the code taken from the link, in case it will be down some day:
Not all monitors support vesa DDC. Thing might got even more complicated if you use a dock.
On the other hand, there is a way to check whether your actions are detected by monitoring the kernel/udev events. To do this, for Fedora and RHEL, type following command:
It will display every kernel and udev events it detected. From that, you can try plug/unplug the monitor data cable; plug/unplug the monitor power cable; toggle the stand-by/on states by pressing the power button.
If no output is generated after an action, then your system cannot detect it.
You might want to look at the output of
I'm not sure if it will work but I think the line " Monitor is (on|off)" should tell you the answer.
xset -q
is the way to go for a raspberry pi. A check to see if the reply contains 'Monitor is On' is a great way to use a gpio pin to turn off an LCD Backlight;