Skip to content

Instantly share code, notes, and snippets.

@defHLT
Created July 17, 2013 18:45
Show Gist options
  • Save defHLT/6023284 to your computer and use it in GitHub Desktop.
Save defHLT/6023284 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
output = `xrandr`
lvds = output[/LVDS connected.*mm/]
dfp1 = output[/DFP1 connected.*mm/]
if lvds && dfp1
status = "(both)"
options = "lvds\ndfp1"
elsif lvds
status = "(lvds)"
options = "dfp1\nboth"
elsif dfp1
status = "(dfp1)"
options = "lvds\nboth"
end
setup_lvds = 'xrandr --output LVDS --left-of DFP1 --mode 1366x768'
setup_dfp1 = 'xrandr --output DFP1 --right-of LVDS --mode 1440x900'
case `echo "#{options}" | dmenu -p "#{status}"`
when "lvds"
`#{setup_lvds} && xrandr --output DFP1 --off`
when "dfp1"
`#{setup_dfp1} && xrandr --output LVDS --off`
when "both"
if lvds
`#{setup_dfp1}`
else
`#{setup_lvds}`
end
end
`nitrogen --restore` # reset wallpapers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment