work on better bar mechanics

This commit is contained in:
Daniel Flanagan 2016-07-27 08:57:56 -05:00
parent dff9ebec55
commit 118f77032c
12 changed files with 140 additions and 86 deletions

View file

@ -53,19 +53,29 @@ if [ -t 0 ]; then
# arch aliases # arch aliases
alias archupdate="pacaur -Syyu --noconfirm --noedit" alias archupdate="pacaur -Syyu --noconfirm --noedit"
# wm aliases
alias startbar="source $DOTFILES_PATH/wm/extras/bar/start.bash"
stopbar() { stopbar() {
if [[ -f "$BAR_PID_FILE" ]]; then if [[ -f "$BAR_PID_FILE" ]]; then
echo
kill -SIGINT $(cat "$BAR_PID_FILE") kill -SIGINT $(cat "$BAR_PID_FILE")
rm -f "$BAR_PID_FILE" rm -f "$BAR_PID_FILE"
killall lemonbar
else else
echo "Bar is not running." echo "Bar is not running."
fi fi
} }
export -f stopbar export -f stopbar
# wm aliases
startbar() {
if [[ -f "$BAR_PID_FILE" ]]; then
stopbar
fi
"$DOTFILES_PATH/wm/extras/bar/start.bash"
echo $! > "$BAR_PID_FILE"
bg
disown
}
export -f startbar
# misc aliases # misc aliases
alias keyrepeat="xset r rate 250 80" alias keyrepeat="xset r rate 250 80"

View file

@ -5,8 +5,8 @@
export DOTFILES_PATH="$HOME/.dotfiles" export DOTFILES_PATH="$HOME/.dotfiles"
export REPOSITORY_PATH="$HOME/Documents/open-source" export REPOSITORY_PATH="$HOME/Documents/open-source"
export WINDOW_GAP=5
export BORDER_WIDTH=1 export BORDER_WIDTH=1
export WINDOW_GAP=5
export BAR_PID_FILE="$DOTFILES_PATH/wm_bar.pid" export BAR_PID_FILE="$DOTFILES_PATH/wm_bar.pid"
source "$DOTFILES_PATH/scripts/get_x_fonts.sh" source "$DOTFILES_PATH/scripts/get_x_fonts.sh"
@ -14,14 +14,27 @@ source "$DOTFILES_PATH/scripts/get_color.sh"
export BAR_ON_XINIT=0 export BAR_ON_XINIT=0
export BAR_FIFO="$DOTFILES_PATH/wm_bar_fifo.lock" export BAR_FIFO="$DOTFILES_PATH/wm_bar_fifo.lock"
export BAR_LOG="$DOTFILES_PATH/wm_bar.log"
export BAR_TOP=0 export BAR_TOP=0
export BAR_MARGIN=$WINDOW_GAP
export BAR_HEIGHT=20 export BAR_HEIGHT=20
export BAR_BORDER_WIDTH=1 export BAR_BORDER_WIDTH=1
export BAR_FONT_FAMILY="$PRIMARY_FONT_FAMILY_WITH_SIZE" export BAR_FONT_FAMILY="$PRIMARY_FONT_FAMILY_WITH_SIZE"
export BAR_UNDERLINE=1 export BAR_UNDERLINE=1
# export BAR_MARGIN=$WINDOW_GAP
export BAR_MARGIN=700
export BAR_WID="wmpanel" export BAR_WID="wmpanel"
export TOP_BAR_PADDING=0
export BOTTOM_BAR_PADDING=0
if [[ $BAR_TOP -eq 0 ]]; then
export BOTTOM_BAR_PADDING=$BAR_HEIGHT
else
export TOP_BAR_PADDING=$BAR_HEIGHT
fi
export WINDOW_GAP=$(expr $WINDOW_GAP - $BORDER_WIDTH)
# load per-device bashrc_env if it exists # load per-device bashrc_env if it exists
if [ -a "$HOME/.bashrc_env" ]; then if [ -a "$HOME/.bashrc_env" ]; then
. "$HOME/.bashrc_env" . "$HOME/.bashrc_env"

View file

@ -11,13 +11,12 @@ source "$DOTFILES_PATH/scripts/get_x_fonts.sh"
bspc config normal_border_color "#$(get_color 01)" bspc config normal_border_color "#$(get_color 01)"
bspc config focused_border_color "#$(get_color 0D)" bspc config focused_border_color "#$(get_color 0D)"
bspc config active_border_color "#$(get_color 0C)" bspc config active_border_color "#$(get_color 09)"
bspc config presel_feedback_color "#$(get_color 04)" bspc config presel_feedback_color "#$(get_color 04)"
bspc config border_width "$BORDER_WIDTH" bspc config border_width "$BORDER_WIDTH"
bspc config split_ratio 0.50 bspc config split_ratio 0.50
bspc config borderless_monocle true bspc config borderless_monocle true
bspc config gapless_monocle true bspc config gapless_monocle true
bspc config focus_by_distance true
bspc config window_gap "$WINDOW_GAP" bspc config window_gap "$WINDOW_GAP"

View file

@ -1,12 +1,12 @@
export COLOR_FOREGROUND="#ff$(get_color 05)" export COLOR_FOREGROUND="#$(get_color 05 | awk '{print toupper($0)}')"
export COLOR_DARK="#ff$(get_color 02)" export COLOR_DARK="#$(get_color 02 | awk '{print toupper($0)}')"
export COLOR_BACKGROUND="#ff$(get_color 00)" export COLOR_BACKGROUND="#$(get_color 00 | awk '{print toupper($0)}')"
export COLOR_HIGHLIGHT="#ff$(get_color 0D)" export COLOR_HIGHLIGHT="#$(get_color 0D | awk '{print toupper($0)}')"
export COLOR_URGENT="#ff$(get_color 08)" export COLOR_URGENT="#$(get_color 08 | awk '{print toupper($0)}')"
export COLOR_S1="#ff$(get_color 0E)" export COLOR_S1="#$(get_color 0E | awk '{print toupper($0)}')"
export COLOR_S2="#ff$(get_color 0F)" export COLOR_S2="#$(get_color 0F | awk '{print toupper($0)}')"
export COLOR_S3="#ff$(get_color 0D)" export COLOR_S3="#$(get_color 0D | awk '{print toupper($0)}')"
export COLOR_S4="#ff$(get_color 0A)" export COLOR_S4="#$(get_color 0A | awk '{print toupper($0)}')"
export COLOR_S5="#ff$(get_color 09)" export COLOR_S5="#$(get_color 09 | awk '{print toupper($0)}')"

View file

@ -16,13 +16,19 @@ export MODULE_MATCH=()
export MODULE_CALLBACK=() export MODULE_CALLBACK=()
export MODULE_DATA=() export MODULE_DATA=()
export MODULE_CONTENT=() export MODULE_CONTENT=()
export MODULE_INIT=()
export MODULE_PIDS=""
register_bar_module() { register_bar_module() {
MODULE_MATCH[$1]=$2 MODULE_MATCH[$1]=$2
MODULE_CALLBACK[$1]=$3 MODULE_CALLBACK[$1]=$3
MODULE_DATA[$1]= MODULE_DATA[$1]=
MODULE_CONTENT[$1]= MODULE_CONTENT[$1]=
# echo -e "Registered Bar Module: $1 $2 $3" >> "$BAR_LOG" MODULE_INIT[$1]=$4
${MODULE_INIT[$1]} &
PID=$!
echo $PID > "$DOTFILES_PATH/wm/extras/bar/modules/$3.pid"
# echo -e "Registered Bar Module: $1 $2 $3 $4 with PID $PID" >> "$BAR_LOG"
} }
export -f register_bar_module export -f register_bar_module

View file

@ -51,7 +51,12 @@ bar_module_bspwm() {
echo -e "$content" echo -e "$content"
} }
export -f bar_module_bspwm export -f bar_module_bspwm
register_bar_module "$PRIORITY" "$MATCH" "bar_module_bspwm"
bspc subscribe all > "$BAR_FIFO" & bar_module_bspwm_updater()
{
bspc subscribe all > "$BAR_FIFO"
}
export -f bar_module_bspwm_updater
register_bar_module "$PRIORITY" "$MATCH" "bar_module_bspwm" "bar_module_bspwm_updater"

View file

@ -13,7 +13,6 @@ bar_module_clock() {
} }
export -f bar_module_clock export -f bar_module_clock
register_bar_module "$PRIORITY" "$MATCH" "bar_module_clock"
bar_module_clock_updater() { bar_module_clock_updater() {
while true; do while true; do
@ -21,5 +20,6 @@ bar_module_clock_updater() {
sleep 1 sleep 1
done done
} }
bar_module_clock_updater & export -f bar_module_clock_updater
register_bar_module "$PRIORITY" "$MATCH" "bar_module_clock" "bar_module_clock_updater"

View file

@ -11,9 +11,7 @@ MATCH="$MATCH_PREFIX*"
bar_module_date() { bar_module_date() {
echo -e "%{T-}%{r}%{F$COLOR_S2}${1:7}%{F-}" echo -e "%{T-}%{r}%{F$COLOR_S2}${1:7}%{F-}"
} }
export -f bar_module_date export -f bar_module_date
register_bar_module "$PRIORITY" "$MATCH" "bar_module_date"
bar_module_date_updater() { bar_module_date_updater() {
while true; do while true; do
@ -21,5 +19,6 @@ bar_module_date_updater() {
sleep 60 sleep 60
done done
} }
bar_module_date_updater & export -f bar_module_date_updater
register_bar_module "$PRIORITY" "$MATCH" "bar_module_date" "bar_module_date_updater"

View file

@ -11,9 +11,7 @@ MATCH="$MATCH_PREFIX*"
bar_module_pacaur() { bar_module_pacaur() {
echo -e "%{T-}%{F$COLOR_DARK}pac %{F$COLOR_S1}${1:9}%{F-}" echo -e "%{T-}%{F$COLOR_DARK}pac %{F$COLOR_S1}${1:9}%{F-}"
} }
export -f bar_module_pacaur export -f bar_module_pacaur
register_bar_module "$PRIORITY" "$MATCH" "bar_module_pacaur"
bar_module_pacaur_updater() { bar_module_pacaur_updater() {
while true; do while true; do
@ -26,6 +24,8 @@ bar_module_pacaur_updater() {
fi fi
done done
} }
bar_module_pacaur_updater & export -f bar_module_pacaur_updater
register_bar_module "$PRIORITY" "$MATCH" "bar_module_pacaur" "bar_module_pacaur_updater"
echo -e "$MATCH_PREFIX"?? > "$BAR_FIFO" echo -e "$MATCH_PREFIX"?? > "$BAR_FIFO"

View file

@ -1,47 +0,0 @@
#!/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

View file

@ -2,11 +2,60 @@
source "$DOTFILES_PATH/variables.bash" source "$DOTFILES_PATH/variables.bash"
"$DOTFILES_PATH/wm/extras/bar/run_bar.bash" & export BAR_RUNNING=1
export BAR_PID=$! 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
for f in $(ls "$DOTFILES_PATH"/wm/extras/bar/modules/*.pid 2>/dev/null); do
# echo "KILLING MODULE PROCESS $f WITH PID $(cat "$f")"
# kill -SIGTERM $(cat "$f")
rm "$f"
done
kill $!
# kill -SIGTERM $BARPID
}
export -f killbar
echo "$BAR_PID" > "$BAR_PID_FILE" trap killbar INT TERM QUIT EXIT
echo "Starting bar with PID $BAR_PID"
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"
echo $COLOR_FOREGROUND
echo $COLOR_DARK
echo $COLOR_BACKGROUND
echo $COLOR_HIGHLIGHT
echo $COLOR_URGENT
echo $COLOR_S1
echo $COLOR_S2
echo $COLOR_S3
echo $COLOR_S4
echo $COLOR_S5
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"

View file

@ -102,22 +102,42 @@ super + @button{1-3}
# change node gap and desktop padding # change node gap and desktop padding
super + plus super + plus
bspc config -d focused node_gap $((`bspc config -d focused node_gap` + 5 )) bspc config -d focused window_gap $((`bspc config -d focused window_gap` + 5 ))
super + equal super + equal
bspc config -m $(bspc query -M | head -n 1) top_padding $BAR_HEIGHT; bspc config -d focused node_gap $node_GAP bspc config -m $(bspc query -M | head -n 1) top_padding $TOP_BAR_PADDING; bspc config -m $(bspc query -M | head -n 1) bottom_padding $BOTTOM_BAR_PADDING; bspc config -d focused window_gap $WINDOW_GAP
super + minus super + minus
bspc config -d focused node_gap $((`bspc config -d focused node_gap` - 5 )) bspc config -d focused window_gap $((`bspc config -d focused window_gap` - 5 ))
super + alt + r super + alt + r
bspc config -m $(bspc query -M | head -n 1) top_padding $BAR_HEIGHT; bspc config -d focused node_gap 0 bspc config -m $(bspc query -M | head -n 1) bottom_padding $BOTTOM_BAR_PADDING; bspc config -m $(bspc query -M | head -n 1) top_padding $TOP_BAR_PADDING; bspc config -d focused window_gap $WINDOW_GAP
super + alt + equal
bspc config -d focused bottom_padding 0; bspc config -d focused top_padding 0; bspc config -d focused left_padding 0; bspc config -d focused right_padding 0
super + alt + plus super + alt + plus
bspwm_padding +5 bspc config -d focused bottom_padding $(expr $(bspc config -d focused bottom_padding) + 5); bspc config -d focused top_padding $(expr $(bspc config -d focused top_padding) + 5); bspc config -d focused left_padding $(expr $(bspc config -d focused left_padding) + 5); bspc config -d focused right_padding $(expr $(bspc config -d focused right_padding) + 5)
bspc config -d focused bottom_padding $(expr $(bspc config -d focused bottom_padding) + 5); bspc config -d focused top_padding $(expr $(bspc config -d focused top_padding) + 5); bspc config -d focused left_padding $(expr $(bspc config -d focused left_padding) + 5); bspc config -d focused right_padding $(expr $(bspc config -d focused right_padding) + 5)
super + ctrl + alt + k
bspc config -d focused bottom_padding $(expr $(bspc config -d focused bottom_padding) - 5); bspc config -d focused top_padding $(expr $(bspc config -d focused top_padding) - 5)
super + ctrl + alt + j
bspc config -d focused bottom_padding $(expr $(bspc config -d focused bottom_padding) + 5); bspc config -d focused top_padding $(expr $(bspc config -d focused top_padding) + 5)
super + ctrl + alt + h
bspc config -d focused left_padding $(expr $(bspc config -d focused left_padding) - 5); bspc config -d focused right_padding $(expr $(bspc config -d focused right_padding) - 5)
super + ctrl + alt + l
bspc config -d focused left_padding $(expr $(bspc config -d focused left_padding) + 5); bspc config -d focused right_padding $(expr $(bspc config -d focused right_padding) + 5)
super + alt + plus
bspc config -d focused bottom_padding $(expr $(bspc config -d focused bottom_padding) + 5); bspc config -d focused top_padding $(expr $(bspc config -d focused top_padding) + 5); bspc config -d focused left_padding $(expr $(bspc config -d focused left_padding) + 5); bspc config -d focused right_padding $(expr $(bspc config -d focused right_padding) + 5)
super + alt + minus super + alt + minus
bspwm_padding -5 bspc config -d focused bottom_padding $(expr $(bspc config -d focused bottom_padding) - 5)
# wm-independant shortcuts # wm-independant shortcuts