List displays that are turned on [duplicate]












1















This question already has an answer here:




  • Check if display is powered on in Linux

    2 answers




I would like to check if a monitor is turned on so that I can switch the output to it.



xrandr --query


will show all connected displays no matter if they are turned on or not



xrandr --listmonitors


will only list the monitors that are displaying something.










share|improve this question















marked as duplicate by Rui F Ribeiro, roaima, GAD3R, elbarna, Jeff Schaller Dec 22 '18 at 1:03


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















    1















    This question already has an answer here:




    • Check if display is powered on in Linux

      2 answers




    I would like to check if a monitor is turned on so that I can switch the output to it.



    xrandr --query


    will show all connected displays no matter if they are turned on or not



    xrandr --listmonitors


    will only list the monitors that are displaying something.










    share|improve this question















    marked as duplicate by Rui F Ribeiro, roaima, GAD3R, elbarna, Jeff Schaller Dec 22 '18 at 1:03


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















      1












      1








      1








      This question already has an answer here:




      • Check if display is powered on in Linux

        2 answers




      I would like to check if a monitor is turned on so that I can switch the output to it.



      xrandr --query


      will show all connected displays no matter if they are turned on or not



      xrandr --listmonitors


      will only list the monitors that are displaying something.










      share|improve this question
















      This question already has an answer here:




      • Check if display is powered on in Linux

        2 answers




      I would like to check if a monitor is turned on so that I can switch the output to it.



      xrandr --query


      will show all connected displays no matter if they are turned on or not



      xrandr --listmonitors


      will only list the monitors that are displaying something.





      This question already has an answer here:




      • Check if display is powered on in Linux

        2 answers








      shell






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 21 '18 at 17:10









      fra-san

      1,192214




      1,192214










      asked Dec 21 '18 at 15:45









      schtiehve

      61




      61




      marked as duplicate by Rui F Ribeiro, roaima, GAD3R, elbarna, Jeff Schaller Dec 22 '18 at 1:03


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Rui F Ribeiro, roaima, GAD3R, elbarna, Jeff Schaller Dec 22 '18 at 1:03


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          https://stackoverflow.com/questions/3433203/how-to-determine-if-lcd-monitor-is-turned-on-from-linux-command-line found shell script code to check, a la:



          #!/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





          share|improve this answer























          • That dosen't seem to yield the results I'm looking for. What I wanna do is run a script that only executes when a second Monitor is Physically turned on. This Script will always return the status "on" when one Monitor is on and in usage.
            – schtiehve
            Dec 21 '18 at 18:45




















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          https://stackoverflow.com/questions/3433203/how-to-determine-if-lcd-monitor-is-turned-on-from-linux-command-line found shell script code to check, a la:



          #!/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





          share|improve this answer























          • That dosen't seem to yield the results I'm looking for. What I wanna do is run a script that only executes when a second Monitor is Physically turned on. This Script will always return the status "on" when one Monitor is on and in usage.
            – schtiehve
            Dec 21 '18 at 18:45


















          0














          https://stackoverflow.com/questions/3433203/how-to-determine-if-lcd-monitor-is-turned-on-from-linux-command-line found shell script code to check, a la:



          #!/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





          share|improve this answer























          • That dosen't seem to yield the results I'm looking for. What I wanna do is run a script that only executes when a second Monitor is Physically turned on. This Script will always return the status "on" when one Monitor is on and in usage.
            – schtiehve
            Dec 21 '18 at 18:45
















          0












          0








          0






          https://stackoverflow.com/questions/3433203/how-to-determine-if-lcd-monitor-is-turned-on-from-linux-command-line found shell script code to check, a la:



          #!/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





          share|improve this answer














          https://stackoverflow.com/questions/3433203/how-to-determine-if-lcd-monitor-is-turned-on-from-linux-command-line found shell script code to check, a la:



          #!/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






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 21 '18 at 16:57

























          answered Dec 21 '18 at 16:27









          K7AAY

          380319




          380319












          • That dosen't seem to yield the results I'm looking for. What I wanna do is run a script that only executes when a second Monitor is Physically turned on. This Script will always return the status "on" when one Monitor is on and in usage.
            – schtiehve
            Dec 21 '18 at 18:45




















          • That dosen't seem to yield the results I'm looking for. What I wanna do is run a script that only executes when a second Monitor is Physically turned on. This Script will always return the status "on" when one Monitor is on and in usage.
            – schtiehve
            Dec 21 '18 at 18:45


















          That dosen't seem to yield the results I'm looking for. What I wanna do is run a script that only executes when a second Monitor is Physically turned on. This Script will always return the status "on" when one Monitor is on and in usage.
          – schtiehve
          Dec 21 '18 at 18:45






          That dosen't seem to yield the results I'm looking for. What I wanna do is run a script that only executes when a second Monitor is Physically turned on. This Script will always return the status "on" when one Monitor is on and in usage.
          – schtiehve
          Dec 21 '18 at 18:45





          Popular posts from this blog

          List directoties down one level, excluding some named directories and files

          list processes belonging to a network namespace

          list systemd RuntimeDirectory mounts