Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clock stuck on lemonbar #14

Open
alecive opened this issue Aug 29, 2017 · 0 comments
Open

Clock stuck on lemonbar #14

alecive opened this issue Aug 29, 2017 · 0 comments

Comments

@alecive
Copy link

alecive commented Aug 29, 2017

Hi @baskerville ,

I am an happy bspwm user, but I am having this issue with the clock applet with lemonbar. What happens is that everything works fine, until at some point the clock is stuck and does not get updated any more.

Everything else (like the battery, xtitle, workspaces etc) works, which means that it should be more of a clock issue rather than a lemonbar issue (this is why I am reporting it here).

Strangely enough, if I type clock from a terminal it prints out the correct time.

FYI below is my panel script (I could have cut off the not important things but I preferred to keep it as-is). I call it in my init.sh as 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant