naftulikay / autopulse

Dynamically change PulseAudio sinks on hotplug events.
MIT License
2 stars 0 forks source link

Automatic Discovery of DISPLAY Variable #1

Open naftulikay opened 7 years ago

naftulikay commented 7 years ago

It should be possible to automatically discover the first active display in use by the given user using the following logic:

if w | grep -P '^(naftuli)' | awk '{print $2;}' | grep -qP '^tty\d' ; then
  # we have naftuli logged in at a physical TTY on the machine, not guaranteed to be X
  if w | grep -P '^(naftuli)' | grep -P '\b(tty\d)\b' | awk '{print $3;}' | grep -qP '^:\d+' ; then
    # we have naftuli logged in at a physical TTY with what looks like an X display
    DISPLAY="$(w | grep -P '^(naftuli)' | grep -P '\b(tty\d)\b' | awk '{print $3;}')"
  fi
fi

Special props to Gilles for his answer to this X question on unix.stackexchange.

naftulikay commented 7 years ago

Obviously would need to implement in Python :blush: