Skip to content

Instantly share code, notes, and snippets.

@wallentx
Created July 16, 2015 16:17
Show Gist options
  • Save wallentx/3b5c21bc53dc347a9f95 to your computer and use it in GitHub Desktop.
Save wallentx/3b5c21bc53dc347a9f95 to your computer and use it in GitHub Desktop.
bspwmrc
#!/bin/sh
#Toggle a default gap setting if it's not already set.
if [ -z "$BSPWM_GAPS" ]; then export BSPWM_GAPS=true; fi
#Get settings
. ~/.bspwm_theme
bspc config border_width $b_border_width
bspc config split_ratio $b_split_ratio
bspc config normal_border_color "$b_normal_border_color"
bspc config active_border_color "$b_active_border_color"
bspc config focused_border_color "$b_focused_border_color"
bspc config presel_border_color "$b_presel_border_color"
bspc config urgent_border_color "$b_urgent_border_color"
bspc config focused_locked_border_color "$b_focused_locked_border_color"
#focus options:
bspc config focus_follows_pointer true
bspc config pointer_follows_monitor false
bspc config pointer_follows_focus false
bspc config focus_by_distance true
#behavior settings
bspc config auto_alternate true
bspc config auto_cancel true
#rules
bspc rule -a mplayer2 floating=on
bspc rule -a gimp floating=on
bspc rule -a Screenkey manage=off
bspc config left_padding 0
bspc config right_padding 0
bspc config bottom_padding 0
# set window spacing according to gap settings:
if [ "$BSPWM_GAPS" = true ]; then
bspc config window_gap $b_window_gap
bspc config top_padding $(expr $PANEL_HEIGHT + $PANEL_GAP)
bspc config borderless_monocle false
else
bspc config window_gap 0
bspc config top_padding $(expr $PANEL_HEIGHT + $b_border_width)
bspc config borderless_monocle true
# overlapping borders
bspc config window_gap -$b_border_width
for side in right bottom left ; do
bspc config ${side}_padding $b_border_width
done
fi
# TODO - fix the bug here if lemonbar is set to panel - button on panel kills itself, but as is can lead to lag over time.
killall lemonbar
~/.config/bspwm/panel/panel &
desktops=$(bspc query -M)
# determine if this is initial run by seeing if monitors have been renamed to numbers yet
echo "$desktops" | grep -q "[a-zA-Z]"
if [ $? -eq 0 ]; then IsInitialRun=true; else IsInitialRun=false; fi
# rename all the monitors to numbers and create 5 workspaces on each
i=1
# get a list of desktops in monocle mode:
MonocleDesktops=''
for desktop in $(bspc query -D); do
[ ! -z "$( bspc query -d $desktop -T | grep "M - \*")" ] && MonocleDesktops="$MonocleDesktops $desktop"
done
# create desktops or reset desktop configuration if it already exists.
for monitor in $desktops; do
[ "$IsInitialRun" = true ] && \
bspc monitor "$monitor" -n $i -d $i/{i,ii,iii,iiii,iiiii} || \
bspc monitor "$monitor" -d $i/{i,ii,iii,iiii,iiiii}
let i++
done
# Set any Monocle desktops back to tiling mode
for desktop in $MonocleDesktops; do
bspc desktop $desktop -l monocle
done
# set all windows to the new border width:
for window in $(bspc query -W); do
bspc config -w $window border_width $b_border_width
done
[ "$IsInitialRun" = true ] && ~/.config/bspwm/autostart.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment