Last active
December 10, 2015 06:39
-
-
Save monstermunchkin/4395820 to your computer and use it in GitHub Desktop.
Multi-monitor setup depending on location. The location is determined by the ESSID.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
monsetup="$(xrandr)" | |
int_mon="$(grep -Eo 'LVDS[[:digit:]]' <<< "${monsetup}")" | |
ext_mon="$(grep -Eo 'VGA[[:digit:]]' <<< "${monsetup}")" | |
if grep -Eq 'VGA[[:digit:]] connected' <<< "${monsetup}"; then | |
# where am I? | |
at_work=0 | |
for conn in $(sudo netcfg current); do | |
if [[ "${conn}" == stampay* ]]; then | |
at_work=1 | |
break | |
fi | |
done | |
# place monitors correctly and make LVDS primary | |
if [[ "${at_work}" -eq 0 ]]; then | |
left_mon="${int_mon} --primary" | |
right_mon="${ext_mon}" | |
else | |
left_mon="${ext_mon}" | |
right_mon="${int_mon} --primary" | |
fi | |
xrandr \ | |
--output ${right_mon} --mode 1920x1080 --pos 1920x0 --rotate normal \ | |
--output ${left_mon} --mode 1920x1080 --pos 0x0 --rotate normal | |
sed -ri \ | |
-e "/^# BEGIN LAYOUT/,/^# END LAYOUT/ s/(workspace) ([1-5]) (output) .*/\1 \2 \3 ${left_mon%% *}/" \ | |
-e "/^# BEGIN LAYOUT/,/^# END LAYOUT/ s/(workspace) ([6-9]|10) (output) .*/\1 \2 \3 ${right_mon%% *}/" \ | |
~/.i3/config | |
i3-msg reload | |
i3-msg 'rename workspace 6 to "6: www"' | |
i3-msg 'rename workspace 9 to "9: Spotify"' | |
i3-msg 'rename workspace 10 to "10: Jabber"' | |
else | |
xrandr \ | |
--output "${int_mon}" --primary --mode 1920x1080 --pos 0x0 --rotate normal \ | |
--output "${ext_mon}" --off | |
sed -ri "/^# BEGIN LAYOUT/,/^# END LAYOUT/ s/VGA[[:digit:]]{1,2}/${int_mon}/" ~/.i3/config | |
i3-msg reload | |
fi | |
nitrogen --restore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment