baskerville / bspwm

A tiling window manager based on binary space partitioning
BSD 2-Clause "Simplified" License
7.69k stars 417 forks source link

[lemonbar] Workspaces indicator stuck after recent update #700

Open alecive opened 6 years ago

alecive commented 6 years ago

Hi,

this is very similar to https://github.com/baskerville/sutils/issues/14 (but the cause is different because that never worked for me, whereas this broke only now).

I recently updated bspwm and lemonbar to the latest commit, and now as soon as I start my bspwm session, the workspaces indicator on panel is not updated any more. I can still click on the workspaces in order to change workspace, but if I change workspace with e.g. a keyboard shortcut, the panel does not get updated. BTW with workspaces indicator I mean this:

workspaces_indicator_lemonbar

Now, I tried to find the commit that was the root of this issue (both in lemonbar and bspwm), but it has been a while since my last update and there are too many commits to trace back. However, I discovered that if I git checkout 7561be48e38e183786544a72d31bf7ee586d7b8a , the issue does not appear any more.

If anybody with more knowledge of the codebase wants to point me to other potential commits that may be the cause of the issue, I would be happy to test them!

FYI this is my panel.sh:

#! /bin/sh

# From example .profile changes
export PANEL_FIFO="/tmp/panel-fifo"
export PANEL_HEIGHT="28"
export PANEL_FONT="SourceCodePro-10"
export PANEL_WM_NAME="lemonpanel"

# From panel_colors file
COLOR_DEFAULT_FG="#c0c5ce"
COLOR_DEFAULT_BG="#2b303b"
COLOR_MONITOR_FG="#a3be8c"
COLOR_MONITOR_BG="#2b303b"
COLOR_FOCUSED_MONITOR_FG="#a3be8c"
COLOR_FOCUSED_MONITOR_BG="#4f5b66"
COLOR_FREE_FG="#4f5b66"
COLOR_FREE_BG="#2b303b"
COLOR_FOCUSED_FREE_FG="#000000"
COLOR_FOCUSED_FREE_BG="#504e4e"
COLOR_OCCUPIED_FG="#a7a5a5"
COLOR_OCCUPIED_BG="#2b303b"
COLOR_FOCUSED_OCCUPIED_FG="#d6d3d2"
COLOR_FOCUSED_OCCUPIED_BG="#4f5b66"
COLOR_URGENT_FG="#f15d66"
COLOR_URGENT_BG="#2b303b"
COLOR_FOCUSED_URGENT_FG="#501d1f"
COLOR_FOCUSED_URGENT_BG="#d5443e"
COLOR_STATE_FG="#b483ad"
COLOR_STATE_BG="#2b303b"
COLOR_TITLE_FG="#8fa1b3"
COLOR_TITLE_BG="#2b303b"
COLOR_SYS_FG="#ebcb8b"
COLOR_SYS_BG="#2b303b"
COLOR_GREEN="#a3be8c"
COLOR_RED="#bf616a"

# Kill any panel processes older than us, instead of bailing like the example
# does. That caused one too many panel-less boots for me.
while [ $(pgrep -cx panel.sh) -gt 1 ] ; do
    pkill -ox -9 panel.sh
done

# Kill any remaining trays / xtitle instances so we don't have multiples.
killall -9 xtitle
killall -9 stalonetray
killall -9 nm-applet
killall -9 indicator-sound-switcher

trap 'trap - TERM; kill 0' INT TERM QUIT EXIT

[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
mkfifo "$PANEL_FIFO"

bspc config top_padding $PANEL_HEIGHT
bspc subscribe report > "$PANEL_FIFO" &

# Here are the subprograms that add information to the status FIFO which are
# interpreted by panel_bar, below. Each output is detected by its first
# character, which is how the bspwm internal information is presented.

# T - xtitle output
# S - date output (same as example)
# B - battery output

xtitle -sf 'T%s' > "$PANEL_FIFO" &
clock -sf 'S%a, %b %d %H:%M' > "$PANEL_FIFO" &

bat_percent() {
    BAT="/sys/class/power_supply/BAT1"
    while true; do
        CHARGE_NOW=`cat $BAT/charge_now`
        CHARGE_FULL=`cat $BAT/charge_full`
        PERCENT=`echo "($CHARGE_NOW * 100)/$CHARGE_FULL" | bc`
        BATSTATUS=`cat $BAT/status`

        if   [ "$BATSTATUS" = "Charging" ]; then
            BATSTATUS="+"
        elif [ "$BATSTATUS" = "Discharging" ]; then
            BATSTATUS="-"
        else
            BATSTATUS=""
        fi

        echo "B$BATSTATUS$PERCENT"
        sleep 1
    done
}

bat_percent > "$PANEL_FIFO" &

vol_info() {
    while true; do
        volStatus=$(amixer -D pulse sget Master | tail -n 1 | cut -d '[' -f 3 | sed 's/]//g')
        volLevel=$(amixer -D pulse sget Master | awk '/Front Left:/ {print $5}' | tr -dc "0-9" | sed 's/%//g' )
        if [ $volStatus = "on" ]; then
            echo "N$volLevel"
        else
            echo "F$volLevel"
        fi
        sleep 1
    done
}

vol_info > "$PANEL_FIFO" &

brightness_info() {
    while true; do
        br_float=$(xbacklight)
        br_int=${br_float%.*}
        echo "R$br_int"
        sleep 1
    done
}

brightness_info > "$PANEL_FIFO" &

num_mon=$(bspc query -M | wc -l)
panel_bar() {
    while read line < $PANEL_FIFO; do
        case $line in
            R*)
                # brightness
                br="%{F$COLOR_SYS_FG} ${line#?}%{F-}"
                ;;
            N*)
                # volume output - on status
                vol="%{F$COLOR_GREEN} ${line#?}%{F-}"
                ;;
            F*)
                # volume output - off status
                vol="%{F$COLOR_RED} ${line#?}%{F-}"
                ;;
            B*)
                # battery output
                bat="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?}%"
                ;;
            S*)
                # clock output
                sys="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?} %{B-}%{F-}"
                ;;
            T*)
                # xtitle output
                title="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG} ${line#?} %{B-}%{F-}"
                ;;
            W*)
                # bspwm's state
                wm=""
                IFS=':'
                set -- ${line#?}
                while [ $# -gt 0 ] ; do
                    item=$1
                    name=${item#?}
                    case $item in
                        [mM]*)
                            [ $num_mon -lt 2 ] && shift && continue
                            case $item in
                                m*)
                                    # monitor
                                    FG=$COLOR_MONITOR_FG
                                    BG=$COLOR_MONITOR_BG
                                    ;;
                                M*)
                                    # focused monitor
                                    FG=$COLOR_FOCUSED_MONITOR_FG
                                    BG=$COLOR_FOCUSED_MONITOR_BG
                                    ;;
                            esac
                            wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc monitor -f ${name}:} ${name} %{A}%{B-}%{F-}"
                            ;;
                        [fFoOuU]*)
                            case $item in
                                f*)
                                    # free desktop
                                    FG=$COLOR_FREE_FG
                                    BG=$COLOR_FREE_BG
                                    ;;
                                F*)
                                    # focused free desktop
                                    FG=$COLOR_FOCUSED_FREE_FG
                                    BG=$COLOR_FOCUSED_FREE_BG
                                    ;;
                                o*)
                                    # occupied desktop
                                    FG=$COLOR_OCCUPIED_FG
                                    BG=$COLOR_OCCUPIED_BG
                                    ;;
                                O*)
                                    # focused occupied desktop
                                    FG=$COLOR_FOCUSED_OCCUPIED_FG
                                    BG=$COLOR_FOCUSED_OCCUPIED_BG
                                    ;;
                                u*)
                                    # urgent desktop
                                    FG=$COLOR_URGENT_FG
                                    BG=$COLOR_URGENT_BG
                                    ;;
                                U*)
                                    # focused urgent desktop
                                    FG=$COLOR_FOCUSED_URGENT_FG
                                    BG=$COLOR_FOCUSED_URGENT_BG
                                    ;;
                            esac
                            wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-}"
                            ;;
                        [LTG]*)
                            # layout, state and flags
                            wm="${wm}%{F$COLOR_STATE_FG}%{B$COLOR_STATE_BG} ${name} %{B-}%{F-}"
                            ;;
                    esac
                    shift
                done
                ;;
        esac
        if [ "$num_mon" -gt "1" ]; then
            printf "%s\n" "%{l}${wm}%{c}${title}%{r}${bat}${vol}${br}${sys}%{S+}%{l}${wm}%{c}${title}%{r}${bat}${vol}${br}${sys}"
        else
            printf "%s\n" "%{l}${wm}%{c}${title}%{r}${bat}${vol}${br}${sys}"
        fi

    done
}

panel_bar | lemonbar -a 32 -n "$PANEL_WM_NAME" -g x$PANEL_HEIGHT -f "$PANEL_FONT" -F "$COLOR_DEFAULT_FG" -B "$COLOR_DEFAULT_BG" | sh &

if [ "$num_mon" -gt "1" ]; then
    TRAY_GEOM="1x1-2810"
else
    TRAY_GEOM="1x1-250"
fi

stalonetray --geometry $TRAY_GEOM -i $PANEL_HEIGHT -bg "$COLOR_DEFAULT_BG" --grow-gravity NE --kludges force_icons_size &

wid=$(xdo id -a stalonetray)
tries_left=20

while [ -z "$wid" -a "$tries_left" -gt 0 ] ; do
    sleep 0.05
    wid=$(xdo id -a stalonetray)
    tries_left=$((tries_left -1))
done
[ -n "$wid" ] && xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$wid"

wid=$(xdo id -a "$PANEL_WM_NAME")
tries_left=20

while [ -z "$wid" -a "$tries_left" -gt 0 ] ; do
    sleep 0.05
    wid=$(xdo id -a "$PANEL_WM_NAME")
    tries_left=$((tries_left - 1))
done
[ -n "$wid" ] && xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$wid"

nm-applet &
indicator-sound-switcher &

wait
alecive commented 6 years ago

Interestingly, if I stick to this commit https://github.com/baskerville/bspwm/commit/7561be48e38e183786544a72d31bf7ee586d7b8a, https://github.com/baskerville/sutils/issues/14 seems to be solved.