Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 2088  / 1 Year ago, mon, april 24, 2023, 12:48:24

I'm looking for a scripted way to check if the external monitor is on and connected.


My Ubuntu laptop often fails to turn on the external monitor after sleep or a blank screen. I've long since solved the problem using xset dpms force on; xset dpms force off;.


This solution is less than perfect because the monitor goes through a cycle of black screen / blue screen, and the xset operation must be executed while the monitor is in the black screen state. I often repeat the command multiple times until it works.


If I could check if the monitor is properly connected I could better automate the script that re-engages the monitor using xset dpms force on|off.


More From » nvidia

 Answers
0

You could filter (grep, awk, sed, etc.) the output of several commands that provide info on screens/monitors.
If you only need to know if the external monitor is connected, more than one of them are possibly enough.
I am listing below a few examples of what I see. I don't have an external monitor to test, but I guess you can work out the details.



  1. xrandr.


    Screen 0: minimum 320 x 200, current 1344 x 744, maximum 8192 x 8192
    LVDS connected primary 1344x744+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
    1344x744_60.00 59.90*+
    ...
    HDMI-0 disconnected (normal left inverted right x axis y axis)
    VGA-0 disconnected (normal left inverted right x axis y axis)


  2. xdpyinfo


    ...
    default screen number: 0
    number of screens: 1

    screen #0:
    ... (a lot of useful information)


  3. inxi -aG


    As per man page, it can give info on the real monitor/s (e.g., "the real monitor size, not the Xorg full Screen diagonal size, which can be quite different"), although I am not seeing that.



  4. hwinfo | grep -i -B 3 -A 3 monitor


     ...
    37: None 00.0: 10002 LCD Monitor
    [Created at monitor.125]
    Unique ID: rdCR.0BRfQK9ozR8
    Parent ID: vSkL.mJc3+3Ia6n4
    Hardware Class: monitor
    Model: "AUO LCD Monitor"
    Vendor: AUO "AUO"
    Device: eisa 0x20ec
    Resolution: 1366x768@60Hz
    ...



[#703] Monday, April 24, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
atelti

Total Points: 194
Total Questions: 129
Total Answers: 110

Location: North Korea
Member since Tue, Jun 16, 2020
4 Years ago
;