mirror of
https://github.com/ItsDrike/dotfiles.git
synced 2025-06-29 20:20:41 +00:00
Add lemonbar implementation for bspwm
This commit is contained in:
parent
a916b15d11
commit
2ef59a7720
7 changed files with 472 additions and 0 deletions
41
home/.config/lemonbar/applet-window
Executable file
41
home/.config/lemonbar/applet-window
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
PANEL_FIFO="$1"
|
||||
PREFIX="$2"
|
||||
DELAY="$3"
|
||||
MAX_LEN="$(("$4"-3))"
|
||||
|
||||
exec 5>"$PANEL_FIFO"
|
||||
|
||||
main() {
|
||||
local win_id="$(bspc query -N -n focused)"
|
||||
local win_name="$(xprop -id "$win_id" | grep "^WM_NAME" | cut -d' ' -f3- | tr -d '"')"
|
||||
local trimmed_win_name="${win_name:0:$MAX_LEN}"
|
||||
if [[ "$win_name" != "$trimmed_win_name" ]]; then
|
||||
win_name="${trimmed_win_name}..."
|
||||
fi
|
||||
|
||||
REPLY="$trimmed_win_name"
|
||||
}
|
||||
|
||||
# Run 2 loops here, one for instant updates once other window is focused
|
||||
# in bspwm, other for timed updates, in case the window changes it's title
|
||||
# on it's own (such as when we switch a tab in firefox)
|
||||
|
||||
{print init; stdbuf -oL bspc subscribe node} | while read line; do
|
||||
case ${line} in
|
||||
node_focus* ) main ;;
|
||||
init ) main ;;
|
||||
* ) continue ;;
|
||||
esac
|
||||
|
||||
echo "$PREFIX $REPLY" >&5
|
||||
done &
|
||||
|
||||
while :; do
|
||||
main
|
||||
echo "$PREFIX $REPLY" >&5
|
||||
sleep "$DELAY"
|
||||
done
|
||||
|
||||
wait $!
|
Loading…
Add table
Add a link
Reference in a new issue