Skip to content

Instantly share code, notes, and snippets.

@settinghead
Created June 30, 2017 16:49
Show Gist options
  • Select an option

  • Save settinghead/5ee755a14d04d911a513dfbdd466a9a7 to your computer and use it in GitHub Desktop.

Select an option

Save settinghead/5ee755a14d04d911a513dfbdd466a9a7 to your computer and use it in GitHub Desktop.
Xfce automatic dual monitor detection and and configuration
#!/bin/bash
let "target = 2"
swon=false
function nscreens {
curr=$(xrandr | grep " connected" | wc -l)
}
function setup_scr {
xrandr --output eDP-1 --mode 1920x1080 --pos 401x1080 \
--output HDMI-2 --auto --pos -0x0
}
while true
do
sleep 4
nscreens
if [ "$curr" -eq "$target" ] && [ "$swon" == false ]
then
setup_scr
swon=true
elif [ "$curr" -ne "$target" ] && [ "$swon" == true ]
then
xrandr
swon=false
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment