Announcement

Collapse
No announcement yet.

script to find active display

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    script to find active display

    I would like to know the active display and user logged in to a display for a script.
    Knowing that in linux you can have multiple instances of X :0.0 :1.0 ... and that any user could be logged in I would like to write an acpi triggered script to change the display resolution using the active display's user and instance. I can't seem to find a file in /sys or /proc that mentions this info is there some way to get it?

    #2
    Re: script to find active display

    How about parsing the output of the good ol' Unix "who" command?

    Comment


      #3
      Re: script to find active display

      w and who tell who is on :0 or who is on :1 ok fine but how do I know what is the active display if I start a second x and am switching between them.

      Comment


        #4
        Re: script to find active display

        are you sure "who -u" would not do what you want? I thought it would show ALL logged in users (and it should show the display for each I thought, although I only have one logged in now and it's getting late to try a remote login or something)

        Best luck!

        Comment


          #5
          Re: script to find active display

          It does display the user and the display they are logged into however it does not display what display is currently on screen aka the active display.

          so far my script looks like so

          Code:
          ACTIVE_DISPLAY=":0"
          X_USER=`who|awk '{print $2 " " $1}'|grep ^$ACTIVE_DISPLAY|awk '{print $2}'`
          su $X_USER -c "xrandr -display $ACTIVE_DISPLAY --output VGA --auto --rotate normal"
          Which will be good enough for now however I would like a way to get the true active display.
          So that it will do it for the right one. This is a script I am setting up Fn+F4 to use to change the display settings.

          Comment

          Working...
          X