From 01d1eb8d24254d83f1dacd3d7c661aa29b1dd240 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Mon, 28 Nov 2016 14:02:46 -0600 Subject: [PATCH] bar on startup detect padding stuff --- env/wm/bspwm_config | 13 +++++++++++++ env/wm/bspwmrc | 1 - env/wm/extras/bar/start.bash | 5 +++++ scripts/monitors.sh | 4 ++++ variables.bash | 2 +- 5 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 scripts/monitors.sh diff --git a/env/wm/bspwm_config b/env/wm/bspwm_config index f7ccbcf..6f9bfff 100755 --- a/env/wm/bspwm_config +++ b/env/wm/bspwm_config @@ -20,6 +20,19 @@ bspc config gapless_monocle true bspc config window_gap "$WINDOW_GAP" +if [ "$BAR_ON_XINIT" -eq 1 ]; then + if [ -z "$BAR_MONITOR" -o "$BAR_MONITOR" -eq 0 ]; then + source "$DOTFILES_PATH/scripts/monitors.sh" + BAR_MONITOR="$LAST_BSPWM_MONITOR" + fi + + if [ $BAR_TOP -eq 1 ]; then + bspc config -m ${BAR_MONITOR} top_padding "$BAR_HEIGHT" + else + bspc config -m ${BAR_MONITOR} bottom_padding "$BAR_HEIGHT" + fi +fi + echo "${BSPWM_MONITORS}" BSPWM_MONITORS=$(bspc query -M | tac) diff --git a/env/wm/bspwmrc b/env/wm/bspwmrc index 3c49727..5810080 100755 --- a/env/wm/bspwmrc +++ b/env/wm/bspwmrc @@ -10,4 +10,3 @@ bspc wm -o urxvtd & sxhkd & - diff --git a/env/wm/extras/bar/start.bash b/env/wm/extras/bar/start.bash index 140d11e..27a91e9 100755 --- a/env/wm/extras/bar/start.bash +++ b/env/wm/extras/bar/start.bash @@ -29,6 +29,11 @@ trap killbar INT TERM QUIT EXIT rm -f "$BAR_FIFO" mkfifo "$BAR_FIFO" +if [ -z "$BAR_MONITOR" -o "$BAR_MONITOR" -eq 0 ]; then + source "$DOTFILES_PATH/scripts/monitors.sh" + BAR_MONITOR="$LAST_BSPWM_MONITOR" +fi + if [ $BAR_TOP -eq 1 ]; then bspc config -m ${BAR_MONITOR} top_padding "$BAR_HEIGHT" else diff --git a/scripts/monitors.sh b/scripts/monitors.sh new file mode 100644 index 0000000..cd14ac7 --- /dev/null +++ b/scripts/monitors.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +export LAST_BSPWM_MONITOR=$(bspc query -M | tail -n 1) +export FIRST_BSPWM_MONITOR=$(bspc query -M | head -n 1) diff --git a/variables.bash b/variables.bash index 68c4471..d8942a5 100755 --- a/variables.bash +++ b/variables.bash @@ -16,7 +16,7 @@ export BAR_PATH="$DOTFILES_PATH/env/wm/extras/bar" export BAR_PID_FILE="$BAR_PATH/wm_bar.pid" export BAR_ON_XINIT=1 export BAR_FIFO="$BAR_PATH/wm_bar_fifo.lock" -export BAR_MONITOR=$(bspc query -M | tail -n 1) +export BAR_MONITOR=0 # detect monitor automatically export BAR_LOG="$BAR_PATH/wm_bar.log" export BAR_TOP=0 export BAR_HEIGHT=30