How do I detect when a monitor is plugged in or unplugged without acpi, xrandr, /sys and udev?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I've read the answers to this question but I don't have ACPI, the /sys/class/drm/card0-socket/status method does not work and the xrandr method chokes my CPU. udevadm monitor shows nothing when (un)plugging the monitor.



I've got a circa 2013 Lenovo ThinkPad w530 with nVidia quadro something. I'm running Lubuntu 18.04 with the nouveau driver. The monitor is a 27" Philips 271S. I'm using a VGA cable.



How do I do detect monitor (un)plugging?










share|improve this question









New contributor




White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    Are you running nvidia or nouveau? Depending on that, you may also get "files" with EDID entries under /sys or /proc. Also, it's interesting that xrandr "chokes your CPU', while read-edid, which calls the BIOS and has to do some extremely complicated things to do that, does not. xrandr really should just call the X server, which should already have this information. Unless nvidia/nouveau decides that's a good time to test for connected monitors again, with all the time-outs that usually involves.
    – dirkt
    21 hours ago










  • I'm running nouveau. I have the EDID in /sys/class/drm/card0-VGA-1/edid but cat /path/edid gives the same result both with the monitor plugged and unplugged. Maybe the chocking could be avoided with some nice trick, I didn't try that route. About "just calling the X server", maybe that's what srandr does, but I'm not at ease with compiling C.
    – White_Rabbit
    20 hours ago










  • Which call did you use? Just xrandr -q? If this results in monitor probing with long timeouts each time it's called (check /var/log/Xorg.0.log for hints if it really does that), I'd consider a bugreport with the nouveau developers. Possibly there's also a way to set shorter timeouts or to just probe card0-VGA-1, so I'd ask them. It seems to work via get-edid, after all.
    – dirkt
    20 hours ago










  • I use xrandr --display :0 --query. I can't interpret the log. #Last line before call [ 15674.053] (II) event7 - ThinkPad Extra Buttons: device is a keyboard # I call xrandr [ 17548.848] (II) NOUVEAU(0): EDID vendor "PHL", prod id 2314 # [ many lines ] # [ last line of /var/log/Xorg.0.log] [ 17548.849] (II) NOUVEAU(0): Modeline "1280x720"x60.0 74.48 1280 1336 1472 1664 720 721 724 746 -hsync +vsync (44.8 kHz e)
    – White_Rabbit
    20 hours ago















up vote
1
down vote

favorite












I've read the answers to this question but I don't have ACPI, the /sys/class/drm/card0-socket/status method does not work and the xrandr method chokes my CPU. udevadm monitor shows nothing when (un)plugging the monitor.



I've got a circa 2013 Lenovo ThinkPad w530 with nVidia quadro something. I'm running Lubuntu 18.04 with the nouveau driver. The monitor is a 27" Philips 271S. I'm using a VGA cable.



How do I do detect monitor (un)plugging?










share|improve this question









New contributor




White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1




    Are you running nvidia or nouveau? Depending on that, you may also get "files" with EDID entries under /sys or /proc. Also, it's interesting that xrandr "chokes your CPU', while read-edid, which calls the BIOS and has to do some extremely complicated things to do that, does not. xrandr really should just call the X server, which should already have this information. Unless nvidia/nouveau decides that's a good time to test for connected monitors again, with all the time-outs that usually involves.
    – dirkt
    21 hours ago










  • I'm running nouveau. I have the EDID in /sys/class/drm/card0-VGA-1/edid but cat /path/edid gives the same result both with the monitor plugged and unplugged. Maybe the chocking could be avoided with some nice trick, I didn't try that route. About "just calling the X server", maybe that's what srandr does, but I'm not at ease with compiling C.
    – White_Rabbit
    20 hours ago










  • Which call did you use? Just xrandr -q? If this results in monitor probing with long timeouts each time it's called (check /var/log/Xorg.0.log for hints if it really does that), I'd consider a bugreport with the nouveau developers. Possibly there's also a way to set shorter timeouts or to just probe card0-VGA-1, so I'd ask them. It seems to work via get-edid, after all.
    – dirkt
    20 hours ago










  • I use xrandr --display :0 --query. I can't interpret the log. #Last line before call [ 15674.053] (II) event7 - ThinkPad Extra Buttons: device is a keyboard # I call xrandr [ 17548.848] (II) NOUVEAU(0): EDID vendor "PHL", prod id 2314 # [ many lines ] # [ last line of /var/log/Xorg.0.log] [ 17548.849] (II) NOUVEAU(0): Modeline "1280x720"x60.0 74.48 1280 1336 1472 1664 720 721 724 746 -hsync +vsync (44.8 kHz e)
    – White_Rabbit
    20 hours ago













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I've read the answers to this question but I don't have ACPI, the /sys/class/drm/card0-socket/status method does not work and the xrandr method chokes my CPU. udevadm monitor shows nothing when (un)plugging the monitor.



I've got a circa 2013 Lenovo ThinkPad w530 with nVidia quadro something. I'm running Lubuntu 18.04 with the nouveau driver. The monitor is a 27" Philips 271S. I'm using a VGA cable.



How do I do detect monitor (un)plugging?










share|improve this question









New contributor




White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I've read the answers to this question but I don't have ACPI, the /sys/class/drm/card0-socket/status method does not work and the xrandr method chokes my CPU. udevadm monitor shows nothing when (un)plugging the monitor.



I've got a circa 2013 Lenovo ThinkPad w530 with nVidia quadro something. I'm running Lubuntu 18.04 with the nouveau driver. The monitor is a 27" Philips 271S. I'm using a VGA cable.



How do I do detect monitor (un)plugging?







x11 nvidia xrandr display thinkpad






share|improve this question









New contributor




White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 20 hours ago





















New contributor




White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked yesterday









White_Rabbit

284




284




New contributor




White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1




    Are you running nvidia or nouveau? Depending on that, you may also get "files" with EDID entries under /sys or /proc. Also, it's interesting that xrandr "chokes your CPU', while read-edid, which calls the BIOS and has to do some extremely complicated things to do that, does not. xrandr really should just call the X server, which should already have this information. Unless nvidia/nouveau decides that's a good time to test for connected monitors again, with all the time-outs that usually involves.
    – dirkt
    21 hours ago










  • I'm running nouveau. I have the EDID in /sys/class/drm/card0-VGA-1/edid but cat /path/edid gives the same result both with the monitor plugged and unplugged. Maybe the chocking could be avoided with some nice trick, I didn't try that route. About "just calling the X server", maybe that's what srandr does, but I'm not at ease with compiling C.
    – White_Rabbit
    20 hours ago










  • Which call did you use? Just xrandr -q? If this results in monitor probing with long timeouts each time it's called (check /var/log/Xorg.0.log for hints if it really does that), I'd consider a bugreport with the nouveau developers. Possibly there's also a way to set shorter timeouts or to just probe card0-VGA-1, so I'd ask them. It seems to work via get-edid, after all.
    – dirkt
    20 hours ago










  • I use xrandr --display :0 --query. I can't interpret the log. #Last line before call [ 15674.053] (II) event7 - ThinkPad Extra Buttons: device is a keyboard # I call xrandr [ 17548.848] (II) NOUVEAU(0): EDID vendor "PHL", prod id 2314 # [ many lines ] # [ last line of /var/log/Xorg.0.log] [ 17548.849] (II) NOUVEAU(0): Modeline "1280x720"x60.0 74.48 1280 1336 1472 1664 720 721 724 746 -hsync +vsync (44.8 kHz e)
    – White_Rabbit
    20 hours ago













  • 1




    Are you running nvidia or nouveau? Depending on that, you may also get "files" with EDID entries under /sys or /proc. Also, it's interesting that xrandr "chokes your CPU', while read-edid, which calls the BIOS and has to do some extremely complicated things to do that, does not. xrandr really should just call the X server, which should already have this information. Unless nvidia/nouveau decides that's a good time to test for connected monitors again, with all the time-outs that usually involves.
    – dirkt
    21 hours ago










  • I'm running nouveau. I have the EDID in /sys/class/drm/card0-VGA-1/edid but cat /path/edid gives the same result both with the monitor plugged and unplugged. Maybe the chocking could be avoided with some nice trick, I didn't try that route. About "just calling the X server", maybe that's what srandr does, but I'm not at ease with compiling C.
    – White_Rabbit
    20 hours ago










  • Which call did you use? Just xrandr -q? If this results in monitor probing with long timeouts each time it's called (check /var/log/Xorg.0.log for hints if it really does that), I'd consider a bugreport with the nouveau developers. Possibly there's also a way to set shorter timeouts or to just probe card0-VGA-1, so I'd ask them. It seems to work via get-edid, after all.
    – dirkt
    20 hours ago










  • I use xrandr --display :0 --query. I can't interpret the log. #Last line before call [ 15674.053] (II) event7 - ThinkPad Extra Buttons: device is a keyboard # I call xrandr [ 17548.848] (II) NOUVEAU(0): EDID vendor "PHL", prod id 2314 # [ many lines ] # [ last line of /var/log/Xorg.0.log] [ 17548.849] (II) NOUVEAU(0): Modeline "1280x720"x60.0 74.48 1280 1336 1472 1664 720 721 724 746 -hsync +vsync (44.8 kHz e)
    – White_Rabbit
    20 hours ago








1




1




Are you running nvidia or nouveau? Depending on that, you may also get "files" with EDID entries under /sys or /proc. Also, it's interesting that xrandr "chokes your CPU', while read-edid, which calls the BIOS and has to do some extremely complicated things to do that, does not. xrandr really should just call the X server, which should already have this information. Unless nvidia/nouveau decides that's a good time to test for connected monitors again, with all the time-outs that usually involves.
– dirkt
21 hours ago




Are you running nvidia or nouveau? Depending on that, you may also get "files" with EDID entries under /sys or /proc. Also, it's interesting that xrandr "chokes your CPU', while read-edid, which calls the BIOS and has to do some extremely complicated things to do that, does not. xrandr really should just call the X server, which should already have this information. Unless nvidia/nouveau decides that's a good time to test for connected monitors again, with all the time-outs that usually involves.
– dirkt
21 hours ago












I'm running nouveau. I have the EDID in /sys/class/drm/card0-VGA-1/edid but cat /path/edid gives the same result both with the monitor plugged and unplugged. Maybe the chocking could be avoided with some nice trick, I didn't try that route. About "just calling the X server", maybe that's what srandr does, but I'm not at ease with compiling C.
– White_Rabbit
20 hours ago




I'm running nouveau. I have the EDID in /sys/class/drm/card0-VGA-1/edid but cat /path/edid gives the same result both with the monitor plugged and unplugged. Maybe the chocking could be avoided with some nice trick, I didn't try that route. About "just calling the X server", maybe that's what srandr does, but I'm not at ease with compiling C.
– White_Rabbit
20 hours ago












Which call did you use? Just xrandr -q? If this results in monitor probing with long timeouts each time it's called (check /var/log/Xorg.0.log for hints if it really does that), I'd consider a bugreport with the nouveau developers. Possibly there's also a way to set shorter timeouts or to just probe card0-VGA-1, so I'd ask them. It seems to work via get-edid, after all.
– dirkt
20 hours ago




Which call did you use? Just xrandr -q? If this results in monitor probing with long timeouts each time it's called (check /var/log/Xorg.0.log for hints if it really does that), I'd consider a bugreport with the nouveau developers. Possibly there's also a way to set shorter timeouts or to just probe card0-VGA-1, so I'd ask them. It seems to work via get-edid, after all.
– dirkt
20 hours ago












I use xrandr --display :0 --query. I can't interpret the log. #Last line before call [ 15674.053] (II) event7 - ThinkPad Extra Buttons: device is a keyboard # I call xrandr [ 17548.848] (II) NOUVEAU(0): EDID vendor "PHL", prod id 2314 # [ many lines ] # [ last line of /var/log/Xorg.0.log] [ 17548.849] (II) NOUVEAU(0): Modeline "1280x720"x60.0 74.48 1280 1336 1472 1664 720 721 724 746 -hsync +vsync (44.8 kHz e)
– White_Rabbit
20 hours ago





I use xrandr --display :0 --query. I can't interpret the log. #Last line before call [ 15674.053] (II) event7 - ThinkPad Extra Buttons: device is a keyboard # I call xrandr [ 17548.848] (II) NOUVEAU(0): EDID vendor "PHL", prod id 2314 # [ many lines ] # [ last line of /var/log/Xorg.0.log] [ 17548.849] (II) NOUVEAU(0): Modeline "1280x720"x60.0 74.48 1280 1336 1472 1664 720 721 724 746 -hsync +vsync (44.8 kHz e)
– White_Rabbit
20 hours ago











1 Answer
1






active

oldest

votes

















up vote
2
down vote













I resorted to polling for the external screen EDID.
I installed the read-edid package, added a line in visudo



%sudo ALL=(ALL:ALL) NOPASSWD:/usr/bin/get-edid


to allow passwordless get-edid and used the following loop:



#!/bin/bash
# edid_based_automatic_display_loop.sh
export NEW_CONNECTION=1
export NEW_DISCONNECTION=1

while :
do
sleep 1
sudo get-edid 2>/dev/null|parse-edid 2>/dev/null|grep "PHL 271S7Q">/dev/null
_DISCONNECTED=`echo $?`
# echo "DISCONNECTED $_DISCONNECTED"
if [ $_DISCONNECTED = "0" -a $NEW_CONNECTION = "1" ] ; then
export NEW_DISCONNECTION=1;
export NEW_CONNECTION=0;
bash /home/bruno/.screenlayout/only_external.sh
elif [ $_DISCONNECTED = "1" -a $NEW_DISCONNECTION = "1" ] ; then
export NEW_DISCONNECTION=0;
export NEW_CONNECTION=1;
bash /home/bruno/.screenlayout/only_laptop.sh
fi
done





share|improve this answer








New contributor




White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    White_Rabbit is a new contributor. Be nice, and check out our Code of Conduct.









     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481728%2fhow-do-i-detect-when-a-monitor-is-plugged-in-or-unplugged-without-acpi-xrandr%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    I resorted to polling for the external screen EDID.
    I installed the read-edid package, added a line in visudo



    %sudo ALL=(ALL:ALL) NOPASSWD:/usr/bin/get-edid


    to allow passwordless get-edid and used the following loop:



    #!/bin/bash
    # edid_based_automatic_display_loop.sh
    export NEW_CONNECTION=1
    export NEW_DISCONNECTION=1

    while :
    do
    sleep 1
    sudo get-edid 2>/dev/null|parse-edid 2>/dev/null|grep "PHL 271S7Q">/dev/null
    _DISCONNECTED=`echo $?`
    # echo "DISCONNECTED $_DISCONNECTED"
    if [ $_DISCONNECTED = "0" -a $NEW_CONNECTION = "1" ] ; then
    export NEW_DISCONNECTION=1;
    export NEW_CONNECTION=0;
    bash /home/bruno/.screenlayout/only_external.sh
    elif [ $_DISCONNECTED = "1" -a $NEW_DISCONNECTION = "1" ] ; then
    export NEW_DISCONNECTION=0;
    export NEW_CONNECTION=1;
    bash /home/bruno/.screenlayout/only_laptop.sh
    fi
    done





    share|improve this answer








    New contributor




    White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      2
      down vote













      I resorted to polling for the external screen EDID.
      I installed the read-edid package, added a line in visudo



      %sudo ALL=(ALL:ALL) NOPASSWD:/usr/bin/get-edid


      to allow passwordless get-edid and used the following loop:



      #!/bin/bash
      # edid_based_automatic_display_loop.sh
      export NEW_CONNECTION=1
      export NEW_DISCONNECTION=1

      while :
      do
      sleep 1
      sudo get-edid 2>/dev/null|parse-edid 2>/dev/null|grep "PHL 271S7Q">/dev/null
      _DISCONNECTED=`echo $?`
      # echo "DISCONNECTED $_DISCONNECTED"
      if [ $_DISCONNECTED = "0" -a $NEW_CONNECTION = "1" ] ; then
      export NEW_DISCONNECTION=1;
      export NEW_CONNECTION=0;
      bash /home/bruno/.screenlayout/only_external.sh
      elif [ $_DISCONNECTED = "1" -a $NEW_DISCONNECTION = "1" ] ; then
      export NEW_DISCONNECTION=0;
      export NEW_CONNECTION=1;
      bash /home/bruno/.screenlayout/only_laptop.sh
      fi
      done





      share|improve this answer








      New contributor




      White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.



















        up vote
        2
        down vote










        up vote
        2
        down vote









        I resorted to polling for the external screen EDID.
        I installed the read-edid package, added a line in visudo



        %sudo ALL=(ALL:ALL) NOPASSWD:/usr/bin/get-edid


        to allow passwordless get-edid and used the following loop:



        #!/bin/bash
        # edid_based_automatic_display_loop.sh
        export NEW_CONNECTION=1
        export NEW_DISCONNECTION=1

        while :
        do
        sleep 1
        sudo get-edid 2>/dev/null|parse-edid 2>/dev/null|grep "PHL 271S7Q">/dev/null
        _DISCONNECTED=`echo $?`
        # echo "DISCONNECTED $_DISCONNECTED"
        if [ $_DISCONNECTED = "0" -a $NEW_CONNECTION = "1" ] ; then
        export NEW_DISCONNECTION=1;
        export NEW_CONNECTION=0;
        bash /home/bruno/.screenlayout/only_external.sh
        elif [ $_DISCONNECTED = "1" -a $NEW_DISCONNECTION = "1" ] ; then
        export NEW_DISCONNECTION=0;
        export NEW_CONNECTION=1;
        bash /home/bruno/.screenlayout/only_laptop.sh
        fi
        done





        share|improve this answer








        New contributor




        White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        I resorted to polling for the external screen EDID.
        I installed the read-edid package, added a line in visudo



        %sudo ALL=(ALL:ALL) NOPASSWD:/usr/bin/get-edid


        to allow passwordless get-edid and used the following loop:



        #!/bin/bash
        # edid_based_automatic_display_loop.sh
        export NEW_CONNECTION=1
        export NEW_DISCONNECTION=1

        while :
        do
        sleep 1
        sudo get-edid 2>/dev/null|parse-edid 2>/dev/null|grep "PHL 271S7Q">/dev/null
        _DISCONNECTED=`echo $?`
        # echo "DISCONNECTED $_DISCONNECTED"
        if [ $_DISCONNECTED = "0" -a $NEW_CONNECTION = "1" ] ; then
        export NEW_DISCONNECTION=1;
        export NEW_CONNECTION=0;
        bash /home/bruno/.screenlayout/only_external.sh
        elif [ $_DISCONNECTED = "1" -a $NEW_DISCONNECTION = "1" ] ; then
        export NEW_DISCONNECTION=0;
        export NEW_CONNECTION=1;
        bash /home/bruno/.screenlayout/only_laptop.sh
        fi
        done






        share|improve this answer








        New contributor




        White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered yesterday









        White_Rabbit

        284




        284




        New contributor




        White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        White_Rabbit is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




















            White_Rabbit is a new contributor. Be nice, and check out our Code of Conduct.









             

            draft saved


            draft discarded


















            White_Rabbit is a new contributor. Be nice, and check out our Code of Conduct.












            White_Rabbit is a new contributor. Be nice, and check out our Code of Conduct.











            White_Rabbit is a new contributor. Be nice, and check out our Code of Conduct.













             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481728%2fhow-do-i-detect-when-a-monitor-is-plugged-in-or-unplugged-without-acpi-xrandr%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown






            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay