From e5209aad576fe44d3965fcb94d6709348b0a93bf Mon Sep 17 00:00:00 2001 From: Peter Son Struschka Date: Sun, 11 Oct 2020 12:15:08 +0800 Subject: all: overhaul all: Remove old symlinks herbstluftwm: use polybar instead of dzen2 polybar: update config doom-emacs: update repository --- .../bin/statusbar/polybar_hlwm_workspaces.sh | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 herbstluftwm/.local/bin/statusbar/polybar_hlwm_workspaces.sh (limited to 'herbstluftwm/.local/bin/statusbar') diff --git a/herbstluftwm/.local/bin/statusbar/polybar_hlwm_workspaces.sh b/herbstluftwm/.local/bin/statusbar/polybar_hlwm_workspaces.sh new file mode 100755 index 0000000..b7cf5e6 --- /dev/null +++ b/herbstluftwm/.local/bin/statusbar/polybar_hlwm_workspaces.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash + +hc() { + "${herbstclient_command[@]:-herbstclient}" "$@" +} + +monitor_bound() { + echo "$1" | cut -d' ' -f2 +} + +hlwm_id() { + while read -r bound; do + hc list_monitors | grep "$bound" | sed -e 's/:.*$//g' + done <<< "$(monitor_bound "$1")" +} + +this_monitor=$(polybar -m | grep "$MONITOR") + + +monitor=$(hlwm_id "$this_monitor") + +get_layout() { + currenttag=$(hc tag_status | tr '\t' '\n' | sed -n 's/#//p') + focusedtaglayout=$(hc layout "$currenttag" @ | awk '{print $2}' | sed 's/://') + case "$focusedtaglayout" in + vertical) + echo "V" ;; + horizontal) + echo "H" ;; + max) + echo "M" ;; + grid) + echo "G" ;; + esac +} + +layout=$(get_layout) + +herbstclient --idle "(tag_*|focus_changed|window_title_changed)" 2>/dev/null | { + + while true; do + # Read tags into $tags array + IFS=$'\t' read -ra tags <<< "$(hc tag_status "$monitor")" + { + # Read the prefix from each tag + for i in "${tags[@]}" ; do + case ${i:1} in + 'hidden') + ;& + 'scratchpad') + continue + ;; + esac + case ${i:0:1} in + '#') + echo -n "%{B#9fbc00}%{F#101010}" + # Tag in focus on this monitor + ;; + '%') + echo -n "%{B#9ca668}%{F#141414}" + # Tag in focus on other monitor + ;; + '+') + echo -n "%{B#9ca668}%{F#141414}" + # tag viewed on this monitor + ;; + '-') + echo -n "%{B#9ca668}%{F#141414}" + # Tag viewed on other monitor + ;; + ':') + echo -n "%{B#222}%{F#ffffff}" + # Tag is not empty + ;; + '!') + echo -n "%{B#ff0675}%{F#141414}" + # Tag contains urgent window + ;; + *) + echo -n "%{B#222}%{F#7a7a7a}" + ;; + esac + + echo "%{A1:herbstclient use ${i:1}:} ${i:1} %{A -u -o F- B-}" + done + + echo "%{F-}%{B-}" + + echo "| [$layout]" + + } | tr -d "\n" + echo + IFS=$'\t' read -ra cmd || break + + case "${cmd[0]}" in + focus_changed|window_title_changed|layout_changed) + layout=$(get_layout) + esac + # wait for next event from herbstclient --idle + # read -r || break + done +} 2>/dev/null -- cgit v1.2.3