Skip to content

Instantly share code, notes, and snippets.

@burukuru
Created November 12, 2018 09:53
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 burukuru/2bec4d45489da33b7f99c009ba6d44e4 to your computer and use it in GitHub Desktop.
Save burukuru/2bec4d45489da33b7f99c009ba6d44e4 to your computer and use it in GitHub Desktop.
#!/bin/bash [14/29]
set -x
function single_screen() {
xrandr --output HDMI-2 --off --output HDMI-1 --off --output DP-1 --off --output eDP-1 --mode 2560x1600 --pos 0x0 --rotate normal --output DP-2 --off
awesomewm_restart
}
function external_dual() {
SCREEN1=$(echo "$EXT_SCREEN" | xargs | awk '{print $1}')
SCREEN2=$(echo "$EXT_SCREEN" | xargs | awk '{print $2}')
# xrandr --output "$SCREEN2" --right-of SCREEN1 --auto --primary
xrandr --output "$SCREEN2" --primary --mode 1920x1080 --pos 1920x0 --rotate normal --output "$SCREEN1" --mode 1920x1080 --pos 0x0 --rotate normal --output DP-1 --off --output eDP-1 --off
--output DP-2 --off
awesomewm_restart
}
function external_single() {
SCREEN1=$(echo "$EXT_SCREEN" | xargs | awk '{print $1}')
single_screen
xrandr --output "$SCREEN1" --right-of eDP-1 --auto --primary
}
function awesomewm_restart() {
sleep 2
kill -HUP $(pgrep awesome)
sleep 2
}
function windows_arrange() {
/home/thanh/bin/arrange.py
}
EXT_SCREEN=$(xrandr | grep "\bconnected" | grep -v eDP-1 | cut -d' ' -f 1)
if [[ -n "$EXT_SCREEN" ]]; then
if [[ $(echo -n "$EXT_SCREEN" | wc -w) == 2 ]]
then
external_dual
else
external_single
fi
else
single_screen
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment