diff --git a/.gitignore b/.gitignore index 0d0508b..027df9b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ colors/gen/vendor colors/gen/tmp *.lock *.log +*.pid diff --git a/sh/bashrc b/sh/bashrc index 4944c3c..e3c915d 100644 --- a/sh/bashrc +++ b/sh/bashrc @@ -50,6 +50,9 @@ alias emacs="emacs -nw" # arch aliases alias archupdate="pacaur -Syyu --noconfirm --noedit" +# wm aliases +alias startbar="source $DOTFILES_PATH/wm/extras/bar/start.bash" + export EDITOR="vim" if command -v nvim >/dev/null 2>&1; then alias vim="nvim" diff --git a/sh/layout_dev.tmux b/sh/layout_dev.tmux index 9945356..5b31d0c 100644 --- a/sh/layout_dev.tmux +++ b/sh/layout_dev.tmux @@ -6,5 +6,3 @@ selectp -U splitw -v -p 50 resize-pane -x 100 selectp -L -splitw -h -p 50 -selectp -L diff --git a/variables.bash b/variables.bash index 5ca6e8f..7d5c685 100755 --- a/variables.bash +++ b/variables.bash @@ -13,12 +13,13 @@ source "$DOTFILES_PATH/scripts/get_color.sh" export BAR_ON_XINIT=0 export BAR_FIFO="$DOTFILES_PATH/wm_bar_fifo.lock" -export BAR_TOP=1 +export BAR_TOP=0 export BAR_MARGIN=$WINDOW_GAP export BAR_HEIGHT=20 export BAR_BORDER_WIDTH=1 export BAR_FONT_FAMILY="$PRIMARY_FONT_FAMILY_WITH_SIZE" export BAR_UNDERLINE=1 +export BAR_WID="wmpanel" # load per-device bashrc_env if it exists if [ -a "$HOME/.bashrc_env" ]; then diff --git a/wm/extras/bar/modules/pacaur-updates-bm.bash b/wm/extras/bar/modules/pacaur-updates-bm.bash index 34ad6d8..04aba2f 100644 --- a/wm/extras/bar/modules/pacaur-updates-bm.bash +++ b/wm/extras/bar/modules/pacaur-updates-bm.bash @@ -17,9 +17,13 @@ register_bar_module "$PRIORITY" "$MATCH" "bar_module_pacaur" bar_module_pacaur_updater() { while true; do - NUM_PACKAGES=$(pacaur -Syq > /dev/null && pacaur -Qqu | wc -l) - echo -e "$MATCH_PREFIX""$NUM_PACKAGES" > "$BAR_FIFO" - sleep 300 + if [ -e "/var/lib/pacman/db.lck" ]; then + sleep 10 + else + NUM_PACKAGES=$(pacaur -Syq --silent >/dev/null 2>/dev/null && pacaur -Qqu | wc -l) + echo -e "$MATCH_PREFIX""$NUM_PACKAGES" > "$BAR_FIFO" + sleep 300 + fi done } bar_module_pacaur_updater & diff --git a/wm/extras/bar/run_bar.bash b/wm/extras/bar/run_bar.bash new file mode 100755 index 0000000..46feb6e --- /dev/null +++ b/wm/extras/bar/run_bar.bash @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +source "$DOTFILES_PATH/variables.bash" + +export BAR_RUNNING=1 +function killbar() { + export BAR_RUNNING=0 + if [ $BAR_TOP -eq 1 ]; then + bspc config -m $(bspc query -M | head -n 1) top_padding "0" + else + bspc config -m $(bspc query -M | head -n 1) bottom_padding "0" + fi +} + +if [ -e "$BAR_PID_FILE" ]; then + killbar +fi + +trap killbar INT TERM QUIT EXIT + +rm -f "$BAR_FIFO" +mkfifo "$BAR_FIFO" + +if [ $BAR_TOP -eq 1 ]; then + bspc config -m $(bspc query -M | head -n 1) top_padding "$BAR_HEIGHT" +else + bspc config -m $(bspc query -M | head -n 1) bottom_padding "$BAR_HEIGHT" +fi + +# get width of our main monitor +WIDTH=`xrandr -q | egrep '(^| )connected( |$)' | tr 'x' '\n' | head -n 1 | awk '{print $NF}'` +WIDTH=$((WIDTH-BAR_MARGIN-BAR_MARGIN)) + +BAR_B="" +if [ $BAR_TOP -eq 1 ]; then + : +else + BAR_B="-b" +fi + +source "$DOTFILES_PATH/wm/extras/bar/colors.bash" + +cat "$BAR_FIFO" | "$DOTFILES_PATH/wm/extras/bar/formatter.bash" | lemonbar $BAR_B -g \ + "$WIDTH"x"$BAR_HEIGHT"+"$BAR_MARGIN"+"$POS_Y" -u "$BAR_BORDER_WIDTH" -f \ + "$BAR_FONT_FAMILY" -F "$COLOR_FOREGROUND" -B "$COLOR_BACKGROUND" -n "$BAR_WID" + +killbar diff --git a/wm/extras/bar/start.bash b/wm/extras/bar/start.bash index 34cbb74..dfa2bc6 100755 --- a/wm/extras/bar/start.bash +++ b/wm/extras/bar/start.bash @@ -1,41 +1,19 @@ #!/usr/bin/env bash -source "$DOTFILES_PATH/variables.bash" +export BAR_PID_FILE="$DOTFILES_PATH/wm_bar.pid" -export BAR_RUNNING=1 -function killbar() { - export BAR_RUNNING=0 - if [ $BAR_TOP -eq 1 ]; then - bspc config -m $(bspc query -M | head -n 1) top_padding "0" - else - bspc config -m $(bspc query -M | head -n 1) bottom_padding "0" - fi +"$DOTFILES_PATH/wm/extras/bar/run_bar.bash" & + +echo "$!" > "$BAR_PID_FILE" +echo "Starting bar with PID $!" + +export BAR_PID="$!" + +stopbar() { + kill -SIGINT $(cat "$BAR_PID_FILE") + rm -f "$BAR_PID_FILE" } +export -f stopbar -trap killbar INT TERM QUIT EXIT +xdo lower -a wmpanel -rm -f "$BAR_FIFO" -mkfifo "$BAR_FIFO" - -if [ $BAR_TOP -eq 1 ]; then - bspc config -m $(bspc query -M | head -n 1) top_padding "$BAR_HEIGHT" -else - bspc config -m $(bspc query -M | head -n 1) bottom_padding "$BAR_HEIGHT" -fi - -# get width of our main monitor -WIDTH=`xrandr -q | egrep '(^| )connected( |$)' | tr 'x' '\n' | head -n 1 | awk '{print $NF}'` -WIDTH=$((WIDTH-BAR_MARGIN-BAR_MARGIN)) - -BAR_B="" -if [ $BAR_TOP -eq 1 ]; then - : -else - BAR_B="-b" -fi - -source "$DOTFILES_PATH/wm/extras/bar/colors.bash" - -cat "$BAR_FIFO" | "$DOTFILES_PATH/wm/extras/bar/formatter.bash" | lemonbar $BAR_B -g "$WIDTH"x"$BAR_HEIGHT"+"$BAR_MARGIN"+"$POS_Y" -u "$BAR_BORDER_WIDTH" -f "$BAR_FONT_FAMILY" -F "$COLOR_FOREGROUND" -B "$COLOR_BACKGROUND" - -killbar diff --git a/wm/sxhkdrc b/wm/sxhkdrc index 1333aad..56c237d 100755 --- a/wm/sxhkdrc +++ b/wm/sxhkdrc @@ -22,7 +22,7 @@ super + {s,f} # set modes to pseudo_tiled/fullscreen for current node super + shift + {s,f} - bspc node -t {pseudo_tiled,fullscreen} + bspc node -t {pseudo_tiled,fullscreen -l above} # focus the last node/desktop super + {grave,Tab}