Skip to content

Instantly share code, notes, and snippets.

@danilrwx
Created March 8, 2020 01:37
Show Gist options
  • Select an option

  • Save danilrwx/a95b0e7e873b6cd27ffa6ac298097f5e to your computer and use it in GitHub Desktop.

Select an option

Save danilrwx/a95b0e7e873b6cd27ffa6ac298097f5e to your computer and use it in GitHub Desktop.
#!/bin/bash
my_laptop_external_monitor=$(xrandr --query | grep 'VGA-1')
while true; do
if [[ $my_laptop_external_monitor = *connected* ]]; then
xrandr --output VGA-1 --mode 1920x1080 --above eDP-1
#xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x1080 --rotate normal --output VGA-1 --mode 1920x1080 --pos 0x0 --rotate normal --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --off
fi
if [[ $my_laptop_external_monitor = *disconnected* ]]; then
xrandr --output eDP-1 --primary --mode 1920x1080
fi
sleep 1s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment