Skip to content

Instantly share code, notes, and snippets.

@niklas
Created July 14, 2014 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niklas/cf96ee8e9267fe5ac1f7 to your computer and use it in GitHub Desktop.
Save niklas/cf96ee8e9267fe5ac1f7 to your computer and use it in GitHub Desktop.
Setup correct resolutions based on connected displays
#!/usr/bin/ruby
def dpi
147
end
def desktop
system "xrandr --output VGA1 --auto --left-of LVDS1 --output LVDS1 --auto --primary --dpi #{dpi}"
system "xset dpms force on" # wake up monitor from power saving mode
system "marble-mouse left"
end
def auto
system "xrandr --auto --dpi #{dpi}"
end
def main
if system "xrandr | grep -q 'VGA1 connected'"
desktop
else
auto
end
system 'xset dpms force on' # wake up monitor from power saving mode
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment