Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 63 lines (56 sloc) 1.62 KB
#!/bin/bash
# NAME="i3wm_conf"
# BLURB="Conditionals for building i3 window manager config at runtime"
# SOURCE="https://github.com/vonbrownie/homebin/blob/master/i3wm_conf"
set -eu
DIR_i3="$HOME/.config/i3"
CONF_i3="$DIR_i3/config"
MOD_ID="$HOME/.computer_model"
Conf_base() {
local CONF="$DIR_i3/config.base"
cat $CONF > $CONF_i3
}
Conf_display() {
# Setup for primary and - if present - secondary displays
local DSPLY1
DSPLY1=$(xrandr | grep " connected" | awk 'FNR == 1 {print $1}')
local DSPLY2
DSPLY2=$(xrandr | grep " connected" | awk 'FNR == 2 {print $1}')
local D_DSPLY="$DIR_i3/config.dual_display"
local S_DSPLY="$DIR_i3/config.single_display"
local PRI_DSPLY="$DSPLY2"
local SEC_DSPLY="$DSPLY1"
if [[ -n $DSPLY2 ]]; then
sed "s/PRIMARY/$PRI_DSPLY/g; s/SECOND/$SEC_DSPLY/g" $D_DSPLY >> $CONF_i3
else
cat $S_DSPLY >> $CONF_i3
fi
# Setup a device-specific statusbar
local C720_STAT="i3status.conf.chromebook_c720"
local E520_STAT="i3status.conf.thinkpad_e520"
local T430S_STAT="i3status.conf.thinkpad_t430s"
local DESK_STAT="i3status.conf.desktop"
set +eu
local MOD_C720
MOD_C720=$( grep "c720" $MOD_ID )
local MOD_E520
MOD_E520=$( grep "e520" $MOD_ID )
local MOD_T430S
MOD_T430S=$( grep "t430s" $MOD_ID )
local MOD_DESK
MOD_DESK=$( grep "desktop" $MOD_ID )
if [[ -n $MOD_C720 ]]; then
sed -i "s/STATUS_CONF/$C720_STAT/g" $CONF_i3
elif [[ -n $MOD_E520 ]]; then
sed -i "s/STATUS_CONF/$E520_STAT/g" $CONF_i3
elif [[ -n $MOD_T430S ]]; then
sed -i "s/STATUS_CONF/$T430S_STAT/g" $CONF_i3
else
sed -i "s/STATUS_CONF/$DESK_STAT/g" $CONF_i3
fi
set -eu
}
# (O< .: Start
# (/)_
Conf_base
Conf_display
You can’t perform that action at this time.