Skip to content

Instantly share code, notes, and snippets.

@markuskont
Created November 30, 2019 22:05
Show Gist options
  • Save markuskont/48337614d6a1092291af0e014b1450d3 to your computer and use it in GitHub Desktop.
Save markuskont/48337614d6a1092291af0e014b1450d3 to your computer and use it in GitHub Desktop.
KERNEL=="card0", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/markus/.Xauthority", RUN+="/usr/share/markus/hotplug-monitor.sh"
#! /usr/bin/bash
export DISPLAY=:0
export XAUTHORITY=/home/markus/.Xauthority
IN=LVDS-1
OUT1=DP-1
OUT2=HDMI-1
function connect(){
xrandr --output $OUT1 --right-of $IN --preferred --primary --output $IN --auto
}
function disconnect(){
xrandr --output $OUT1 --off --output $OUT2 --off --output $IN --auto --primary
}
#xrandr | grep "HDMI1 connected" &> /dev/null && connect || disconnect
xrandr | egrep "($OUT1|$OUT2) connected" &> /dev/null && connect || disconnect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment