Filename: i3config.sh
#!/bin/bash
# xrandr and i3 config conditional upon Work / Studio / Laptop
theme='tango-jungle'
# grep -c returns 1 line then 1 aka true else 0 aka false
xrandr | grep ' connected '
Work="$( \
ifconfig | grep eth0 -A1 | tail -1 | grep -c 'inet addr:10.19.2.' \
&& \
xrandr | grep -c 'HDMI3 connected ' \
)"
echo Work:${Work}
echo Work:${Work} | grep 1 && Work=1 || Work=0
Studio="$( xrandr | grep -c 'VGA1 connected ' )"
Laptop="$( if [[ ${Work} = 0 && ${Studio} = 0 ]];then echo 1;else echo 0;fi )"
# output results for debugging
echo Work:${Work} Studio:${Studio} Laptop:${Laptop}
# being extra vigilant on condition checking to avoid unexpected results
if [[ ${Work} = 1 ]]
then
location=Work
echo ${location}
~/.i3/ScreenLayout/${location}.sh
j4-make-config -a config.${location} ${theme}
rm ~/.stalonetrayrc;ln -s ~/.i3/stalonetrayrc/stalonetrayrc.${location} ~/.stalonetrayrc
fi
if [[ ${Work} = 0 && ${Studio} = 1 && ${Laptop} = 0 ]]
then
location=Studio
echo ${location}
~/.i3/ScreenLayout/${location}.sh
j4-make-config -a config.${location} ${theme}
rm ~/.stalonetrayrc;ln -s ~/.i3/stalonetrayrc/stalonetrayrc.${location} ~/.stalonetrayrc
fi
if [[ ${Work} = 0 && ${Studio} = 0 && ${Laptop} = 1 ]]
then
location=Studio
echo ${location}
~/.i3/ScreenLayout/${location}.sh
j4-make-config -a config.${location} ${theme}
rm ~/.stalonetrayrc;ln -s ~/.i3/stalonetrayrc/stalonetrayrc.${location} ~/.stalonetrayrc
fi
# if above condtions do not match then do not do custom xrandr and do use most recent i3 config
#
No comments:
Post a Comment
This is Charles Weldon Witt. Thank you for commenting on my blog.