Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- LVDS=eDP1
- VGA=VGA1
- if [ -z $SWITCH_DISPLAY_CURRENT ]; then
- export SWITCH_DISPLAY_CURRENT=0
- fi
- xrandr | grep -q "$VGA connected " && VGA_IS_ON=1 || VGA_IS_ON=0
- # Switch displays
- switch_display()
- {
- if [[ $VGA_IS_ON -eq 0 ]]; then
- xrandr --output $LVDS --auto --scale 1x1
- export SWITCH_DISPLAY_CURRENT=0
- return 0
- fi
- if [[ $VGA_IS_ON -eq 1 && $SWITCH_DISPLAY_CURRENT -eq 0 ]]; then
- xrandr --output $LVDS --auto --output $VGA --off
- export SWITCH_DISPLAY_CURRENT=1
- return 0
- fi
- if [[ $VGA_IS_ON -eq 1 && $SWITCH_DISPLAY_CURRENT -eq 1 ]]; then
- xrandr --output eDP1 --scale 1.405x1.405 --output VGA1 --auto --scale 1x1 --same-as eDP1
- export SWITCH_DISPLAY_CURRENT=2
- return 0
- fi
- if [[ $VGA_IS_ON -eq 1 && $SWITCH_DISPLAY_CURRENT -eq 2 ]]; then
- xrandr --output $VGA --auto --left-of $LVDS --output $LVDS --auto --scale 1x1
- export SWITCH_DISPLAY_CURRENT=3
- return 0
- fi
- if [[ $VGA_IS_ON -eq 1 && $SWITCH_DISPLAY_CURRENT -eq 3 ]]; then
- xrandr --output $VGA --auto --right-of $LVDS
- export SWITCH_DISPLAY_CURRENT=4
- return 0
- fi
- if [[ $VGA_IS_ON -eq 1 && $SWITCH_DISPLAY_CURRENT -eq 4 ]]; then
- xrandr --output $VGA --auto --output $LVDS --off
- export SWITCH_DISPLAY_CURRENT=0
- return 0
- fi
- }
- switch_display
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement