From 5fa69ddde85cf24e8fbd4ad38dcd3bc4b495bda8 Mon Sep 17 00:00:00 2001 From: nedia Date: Tue, 18 Jan 2022 17:22:25 +1300 Subject: [PATCH 01/10] bspwm-node-flags: script, module & preview --- polybar-scripts/bspwm-node-flags/README.md | 35 ++++++++++++++++++ .../bspwm-node-flags/bspwm-node-flags | 30 +++++++++++++++ .../bspwm-node-flags/bspwm-node-flags.ini | 6 +++ .../bspwm-node-flags/bspwn-node-flags.gif | Bin 0 -> 9546 bytes 4 files changed, 71 insertions(+) create mode 100644 polybar-scripts/bspwm-node-flags/README.md create mode 100755 polybar-scripts/bspwm-node-flags/bspwm-node-flags create mode 100644 polybar-scripts/bspwm-node-flags/bspwm-node-flags.ini create mode 100644 polybar-scripts/bspwm-node-flags/bspwn-node-flags.gif diff --git a/polybar-scripts/bspwm-node-flags/README.md b/polybar-scripts/bspwm-node-flags/README.md new file mode 100644 index 00000000..40ecc98e --- /dev/null +++ b/polybar-scripts/bspwm-node-flags/README.md @@ -0,0 +1,35 @@ +# dunstctl, a dunst controller script & module + +This script is written in [`fish`](https://fishshell.com/), and displays a +bookmark icon, alongside a single character to be used in conjunction with +[`bspwm`](https://github.com/baskerville/bspwm) to show flags of the focused +node. + +The following code can be modified if you'd prefer different characters for the +name of the flags. I have chosen `S` for sticky, `X` for lock, `M` for marked & +`P` for private. There are other flags on the node, but these are all that are +currently coded. +```sh +# Filter out false flags, and prepend a character to act as the name. +set flags (string match -ie true \ + 'S:'$flag_states[1] 'X:'$flag_states[2] \ + 'M:'$flag_states[3] 'P:'$flag_states[4]) +``` + +`chmod +x $HOME/.config/polybar/scripts/bspwm-node-flags` (or the path of your +choice.) + +## Preview + +![bspwm-node-flags](bspwm-node-flags.gif) + +## Example module + +```ini +[module/bspwm-node-flags] +exec = $HOME/.config/polybar/scripts/bspwm-node-flags +format-foreground = '#fabd2f' +tail = true +type = custom/script + +``` diff --git a/polybar-scripts/bspwm-node-flags/bspwm-node-flags b/polybar-scripts/bspwm-node-flags/bspwm-node-flags new file mode 100755 index 00000000..0c9b298e --- /dev/null +++ b/polybar-scripts/bspwm-node-flags/bspwm-node-flags @@ -0,0 +1,30 @@ +#! /usr/bin/env fish + +bspc subscribe node | while read -a msg + # A couple of the events that are output by `bspc subscribe node` are + # `node_focus` and `node_stack` - we're only worried about the node being in + # focus, or a flag being set on the current node. + if test "$msg[1]" = 'node_focus'; or test "$msg[1]" = 'node_flag' + # We're only concerned with displaying these flags. + set flag_states (bspc query -T -n focused \ + | jq -r '.sticky,.locked,.marked,.private') + # Filter out false flags, and prepend a character to act as the name. + set flags (string match -ie true \ + 'S:'$flag_states[1] 'X:'$flag_states[2] \ + 'M:'$flag_states[3] 'P:'$flag_states[4]) + + # If we've matched the string 'true' above, $flags will not be empty. + if string length -q -- $flags + set output ' ' + for flag in $flags + # The name is the first character before the ':'. + set name (string split ':' $flag)[1] + set output "$output$name" + end + echo $output + else + # When we've got nothing, we want to clear the output. + echo '' + end + end +end diff --git a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.ini b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.ini new file mode 100644 index 00000000..b474fdb9 --- /dev/null +++ b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.ini @@ -0,0 +1,6 @@ +[module/winflags] +exec = $HOME/.config/polybar/scripts/winflags +format-foreground = ${colours.warning} +label = %{T3}%output%%{T-} +tail = true +type = custom/script diff --git a/polybar-scripts/bspwm-node-flags/bspwn-node-flags.gif b/polybar-scripts/bspwm-node-flags/bspwn-node-flags.gif new file mode 100644 index 0000000000000000000000000000000000000000..48851cfcb6f3840480d1a5881acd3dedb26bddda GIT binary patch literal 9546 zcmeI&XHZjn+b-~xN@yYUAT6PU77*zmU=m2^2#A0J8j6U53W$n;not8Ggen4J=p6%s zf})1rm8OEC20=woilAcI4+q?PKhOJ~_netC^L{vI<~;vTnMppa%>7%}b+2V*LoqV; zfq}GvZ=hYk*4YH0P$<8kprj}gjYiAJV`MQ{S&Wh_Rznu6B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r~8GTT{$NIiTc}`{f z_*@pMs-AATjewkevuIMUCbZiH3l8vc$-YSScCBF4y}=#LN8*U4@8?}0WkV)EIj|eQ zz{vvHb41VyyaTms>q$TmG%Q9dkswxQ+`0`E=KAgvzkynpB$VwLP~QeBCOv#i&%(=x zuW2+{Op@`2OWKf#4(UKHc6!xJTIkuVXy{!ECoa=s{L#U zw-4b_(+~EXfG6k`uRSv58SzZw!DFnc2?sy(onDG&r5AG@Oi&NvK*mgH{R(!J{JXZg z?cn}dTW`XMpPG;Pq(GX94yG(N@}ps-$~8ZP8MK@ zmTf0BG*lm!PuINd-1c+H4^lC`FM}g9o|sp6pmN{eqn2O5eio&Sef!9M5h_(TSw22Mzrc4x%OD+)fvn1G8wV0Eh%Ffgk#2<{bIqV z)%)(U+hgN=Vj*b*Ff$htD%pV@Q{2KOE3t^k@&w;tK499w;7*lCH&9GWlonyeisu$f z3569UgM9?$O6{p>A7+F$g;{i)w>AhHr|ui9(*>7R|6Y>{AZ&xZfBAviGDOm%B35M$ zHl}QzVvIF>;D2vP&EL-aF0uoR^#5FBgUve~Y(5hyyWcpc#eSHTS5cr`LX92LfEJdy z8H%IjK$hDY9{(m!_u`5q;vE2UsezjgRe}$x321I(2Bf8irxF+l2zJl9IXRex0A-zM z47^(^FP~|^uzX@ZS;O-(pHge87kBGq|Xdq>N>Xnn!iRx z#t^;rh^dGug11~7u2V`Epl)>Rq+%0Ji#$sCI#gk;ujJd!_c@3)BCyFx^^+ZoPT2y5w-Twpk+xe#e literal 0 HcmV?d00001 From 922bf829d85b196b93b03d64f19d0c9cc4521d8b Mon Sep 17 00:00:00 2001 From: nedia Date: Tue, 18 Jan 2022 17:29:51 +1300 Subject: [PATCH 02/10] fix: some grammatical errors --- polybar-scripts/bspwm-node-flags/README.md | 2 +- polybar-scripts/bspwm-node-flags/bspwm-node-flags.ini | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/polybar-scripts/bspwm-node-flags/README.md b/polybar-scripts/bspwm-node-flags/README.md index 40ecc98e..4c1b53d2 100644 --- a/polybar-scripts/bspwm-node-flags/README.md +++ b/polybar-scripts/bspwm-node-flags/README.md @@ -1,4 +1,4 @@ -# dunstctl, a dunst controller script & module +# bspwm-node-flags This script is written in [`fish`](https://fishshell.com/), and displays a bookmark icon, alongside a single character to be used in conjunction with diff --git a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.ini b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.ini index b474fdb9..2a61fa5f 100644 --- a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.ini +++ b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.ini @@ -1,6 +1,5 @@ -[module/winflags] -exec = $HOME/.config/polybar/scripts/winflags -format-foreground = ${colours.warning} -label = %{T3}%output%%{T-} +[module/bspwm-node-flags] +exec = $HOME/.config/polybar/scripts/bspwm-node-flags +format-foreground = '#fabd2f' tail = true type = custom/script From e4983d6e920437f8ef52606da744d65eb4201353 Mon Sep 17 00:00:00 2001 From: nedia Date: Wed, 19 Jan 2022 06:44:04 +1300 Subject: [PATCH 03/10] feat: include a sh/bash version of the script --- .../bspwm-node-flags/bspwm-node-flags.sh | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 polybar-scripts/bspwm-node-flags/bspwm-node-flags.sh diff --git a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.sh b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.sh new file mode 100644 index 00000000..ecfacbad --- /dev/null +++ b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.sh @@ -0,0 +1,31 @@ +#! /usr/bin/env sh + +bspc subscribe node | while read -a msg; do + # A couple of the events that are output by `bspc subscribe node` are + # `node_focus` and `node_stack` - we're only worried about the node being in + # focus, or a flag being set on the current node. + if [ "$msg[0]" = "node_focus" -o "$msg[1]" = "node_flag" ] + # We're only concerned with displaying these flags. + flag_states=$(bspc query -T -n focused \ + | jq -r '.sticky,.locked,.marked,.private') + # Filter out false flags, and prepend a character to act as the name. + flags=$(string match -ie true \ + 'S:'$flag_states[1] 'X:'$flag_states[2] \ + 'M:'$flag_states[3] 'P:'$flag_states[4]) + + # If we've matched the string 'true' above, $flags will not be empty. + if [ -z "$flags" ] + output=' ' + for flag in $flags; do + # The name is the first character before the ':'. + set name (string split ':' $flag)[1] + name=$(awk -F ':' '{ print $1 }' $flags) + output="$output$name" + done + echo $output + else + # When we've got nothing, we want to clear the output. + echo '' + fi + fi +done From ae8a5b4707c41576eca8e6cba4d2e4d9cd7b7b42 Mon Sep 17 00:00:00 2001 From: nedia Date: Thu, 20 Jan 2022 11:30:54 +1300 Subject: [PATCH 04/10] feat: include python version for wider compat --- polybar-scripts/bspwm-node-flags/README.md | 24 ++++++---- ...bspwm-node-flags => bspwm-node-flags.fish} | 0 .../bspwm-node-flags/bspwm-node-flags.py | 44 +++++++++++++++++++ .../bspwm-node-flags/bspwm-node-flags.sh | 31 ------------- .../bspwm-node-flags/bspwn-node-flags | 7 +++ 5 files changed, 66 insertions(+), 40 deletions(-) rename polybar-scripts/bspwm-node-flags/{bspwm-node-flags => bspwm-node-flags.fish} (100%) create mode 100755 polybar-scripts/bspwm-node-flags/bspwm-node-flags.py delete mode 100644 polybar-scripts/bspwm-node-flags/bspwm-node-flags.sh create mode 100644 polybar-scripts/bspwm-node-flags/bspwn-node-flags diff --git a/polybar-scripts/bspwm-node-flags/README.md b/polybar-scripts/bspwm-node-flags/README.md index 4c1b53d2..1d75d219 100644 --- a/polybar-scripts/bspwm-node-flags/README.md +++ b/polybar-scripts/bspwm-node-flags/README.md @@ -1,7 +1,9 @@ # bspwm-node-flags -This script is written in [`fish`](https://fishshell.com/), and displays a -bookmark icon, alongside a single character to be used in conjunction with +This script was originally written in [`fish`](https://fishshell.com/), so a +fish script has been included, but I have rewritten it in `python` so that it's +more shell agnostic - `python` is more common than `fish`. This module displays +a bookmark icon, alongside a single character to be used in conjunction with [`bspwm`](https://github.com/baskerville/bspwm) to show flags of the focused node. @@ -9,15 +11,19 @@ The following code can be modified if you'd prefer different characters for the name of the flags. I have chosen `S` for sticky, `X` for lock, `M` for marked & `P` for private. There are other flags on the node, but these are all that are currently coded. -```sh -# Filter out false flags, and prepend a character to act as the name. -set flags (string match -ie true \ - 'S:'$flag_states[1] 'X:'$flag_states[2] \ - 'M:'$flag_states[3] 'P:'$flag_states[4]) + +```python +flag_states = { + 'S': node_tree['sticky'], + 'X': node_tree['locked'], + 'M': node_tree['marked'], + 'P': node_tree['private'] +} ``` -`chmod +x $HOME/.config/polybar/scripts/bspwm-node-flags` (or the path of your -choice.) +`chmod +x $HOME/.config/polybar/scripts/bspwm-node-flags` + +`chmod +x $HOME/.config/polybar/scripts/bspwm-node-flags.py` ## Preview diff --git a/polybar-scripts/bspwm-node-flags/bspwm-node-flags b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.fish similarity index 100% rename from polybar-scripts/bspwm-node-flags/bspwm-node-flags rename to polybar-scripts/bspwm-node-flags/bspwm-node-flags.fish diff --git a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py new file mode 100755 index 00000000..cd89ec6e --- /dev/null +++ b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py @@ -0,0 +1,44 @@ +#! usr/bin/env python + +import argparse +import json + +argparser = argparse.ArgumentParser(description = 'Display `bspwm` node flags') +argparser.add_argument( + 'event', + type=str, + help = 'Type of node event output by `bspc subscribe node`' +) +argparser.add_argument( + 'node_tree', + type=str, + help = 'JSON output of `bspc query -T -n focused`' +) +args = argparser.parse_args() + +# A couple of the events that are output by `bspc subscribe node` are +# `node_focus` and `node_stack` - we're only worried about the node being in +# focus, or a flag being set on the current node. +if args.event == 'node_focus' or args.event == 'node_flag': + # Parse node_tree JSON output. + node_tree = json.loads(args.node_tree) + + # We're only concerned with displaying these flags. + flag_states = { + 'S': node_tree['sticky'], + 'X': node_tree['locked'], + 'M': node_tree['marked'], + 'P': node_tree['private'] + } + + # Filter out false flags. + if list(flag_states.values()).count(True) > 0: + flags = [ ' ' ] + for flag, state in flag_states.items(): + if state: + flags.append(flag) + + print(''.join(flags)) + else: + # When we've got nothing, we want to clear the output. + print('') diff --git a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.sh b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.sh deleted file mode 100644 index ecfacbad..00000000 --- a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.sh +++ /dev/null @@ -1,31 +0,0 @@ -#! /usr/bin/env sh - -bspc subscribe node | while read -a msg; do - # A couple of the events that are output by `bspc subscribe node` are - # `node_focus` and `node_stack` - we're only worried about the node being in - # focus, or a flag being set on the current node. - if [ "$msg[0]" = "node_focus" -o "$msg[1]" = "node_flag" ] - # We're only concerned with displaying these flags. - flag_states=$(bspc query -T -n focused \ - | jq -r '.sticky,.locked,.marked,.private') - # Filter out false flags, and prepend a character to act as the name. - flags=$(string match -ie true \ - 'S:'$flag_states[1] 'X:'$flag_states[2] \ - 'M:'$flag_states[3] 'P:'$flag_states[4]) - - # If we've matched the string 'true' above, $flags will not be empty. - if [ -z "$flags" ] - output=' ' - for flag in $flags; do - # The name is the first character before the ':'. - set name (string split ':' $flag)[1] - name=$(awk -F ':' '{ print $1 }' $flags) - output="$output$name" - done - echo $output - else - # When we've got nothing, we want to clear the output. - echo '' - fi - fi -done diff --git a/polybar-scripts/bspwm-node-flags/bspwn-node-flags b/polybar-scripts/bspwm-node-flags/bspwn-node-flags new file mode 100644 index 00000000..46354a14 --- /dev/null +++ b/polybar-scripts/bspwm-node-flags/bspwn-node-flags @@ -0,0 +1,7 @@ +#! /usr/bin/env sh + +bspc subscribe node | while read -a msg; do + event=$msg + node_tree=$(bspc query -T -n focused) + python $HOME/.config/polybar/scripts/bspwm-node-flags.py $event $node_tree +done From 7795dba0206718d576b4e07e3360212f0eaca01d Mon Sep 17 00:00:00 2001 From: nedia Date: Thu, 20 Jan 2022 11:39:42 +1300 Subject: [PATCH 05/10] chore: update preview gif --- .../bspwm-node-flags/bspwn-node-flags.gif | Bin 9546 -> 13862 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/polybar-scripts/bspwm-node-flags/bspwn-node-flags.gif b/polybar-scripts/bspwm-node-flags/bspwn-node-flags.gif index 48851cfcb6f3840480d1a5881acd3dedb26bddda..ca6b43fef081f2b3b12fdb622ec6586bd9201c40 100644 GIT binary patch literal 13862 zcmeI3XHb*-+OMBf0tpa$s3vqm=tZg~G(%BC5djf`0wN;P?U>NJGywrM^denUK-AES zfHV~qS%`p$h@hxgIia}LUhm#}X3u%g`Et%XNhTkjFUe&7*K_@T_nlqlW;(iVp8*x% z3!nz90peJkI95s=CnJuN7sqLcOYRVtG7^{35SO(Qm)kFa#YrgHN$7ZNQ`xmmLl%q0 ztv_`ga2Ot(Wq_m=UdsKVw49u@g0hUJzAP3eC&4eLyH`$^A}_|NU~&+T#VD#O5~Q~& zNr@=!!z&%Rs4OLfC>E`{A5 zkg+`^OGiakXNQ~4p3}No3c5Shb;(41dtU<`ZNt!OJGLtsDM%UVsTl3sX>6!!Dv2}I zS2GO?GL0$SWvEFes*}ys&EpF!h`N@>zLt)7%aB;BgXG=2^eD18$_{1g@N^ps13UKv zb{UoXtc>h07VM`GoD^`*Hm1&J2nSs)UDXb{YRkHvJ%30^`cPKRq1@8L>IV<+H+N4< z^N_}Q%1U}VnR`0h9Z}IcQr>v<+{vRC(vBuZdz;Jq9Jcn|F6kd~HXs-uRNowuq;$&1 z>9ix^?A?2zTDS`~suu!W!_QMA&mM_7za!dQF1oWNE+Zwr`Aj^sAt5m+Axk--?s`JQ z&cxeilfsTC4=_^)n$pP9Y0>`ahm_OX>NC2Uv*Lm;d+BGVp3Sb#%DLm8d!zhHxbM}= zO4piiGaO~}hwBS#6^e?3ie8izKe=Dh=vV3{UwT-%GzRE+gmGyV38je@Z zbyi>Xt8O}0-I82$OSyKwtL{nN&0|V8A5`4(SGsju<<`rDhU62Cd7e!{x=lCJo9k4X zTYH;F?lwQGycei???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Fr~8GTT{$NIiTc}`{f z_*@pMs-AATjewkevuIMUCbZiH3l8vc$-YSScCBF4y}=#LN8*U4@8?}0WkV)EIj|eQ zz{vvHb41VyyaTms>q$TmG%Q9dkswxQ+`0`E=KAgvzkynpB$VwLP~QeBCOv#i&%(=x zuW2+{Op@`2OWKf#4(UKHc6!xJTIkuVXy{!ECoa=s{L#U zw-4b_(+~EXfG6k`uRSv58SzZw!DFnc2?sy(onDG&r5AG@Oi&NvK*mgH{R(!J{JXZg z?cn}dTW`XMpPG;Pq(GX94yG(N@}ps-$~8ZP8MK@ zmTf0BG*lm!PuINd-1c+H4^lC`FM}g9o|sp6pmN{eqn2O5eio&Sef!9M5h_(TSw22Mzrc4x%OD+)fvn1G8wV0Eh%Ffgk#2<{bIqV z)%)(U+hgN=Vj*b*Ff$htD%pV@Q{2KOE3t^k@&w;tK499w;7*lCH&9GWlonyeisu$f z3569UgM9?$O6{p>A7+F$g;{i)w>AhHr|ui9(*>7R|6Y>{AZ&xZfBAviGDOm%B35M$ zHl}QzVvIF>;D2vP&EL-aF0uoR^#5FBgUve~Y(5hyyWcpc#eSHTS5cr`LX92LfEJdy z8H%IjK$hDY9{(m!_u`5q;vE2UsezjgRe}$x321I(2Bf8irxF+l2zJl9IXRex0A-zM z47^(^FP~|^uzX@ZS;O-(pHge87kBGq|Xdq>N>Xnn!iRx z#t^;rh^dGug11~7u2V`Epl)>Rq+%0Ji#$sCI#gk;ujJd!_c@3)BCyFx^^+ZoPT2y5w-Twpk+xe#e From 22d1973b6636ea059f824cc072f9b45e7faaaf9d Mon Sep 17 00:00:00 2001 From: nedia Date: Thu, 20 Jan 2022 11:41:34 +1300 Subject: [PATCH 06/10] fix: make 2nd argument optional --- polybar-scripts/bspwm-node-flags/bspwm-node-flags.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py index cd89ec6e..b0f5bd0a 100755 --- a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py +++ b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py @@ -12,7 +12,8 @@ argparser.add_argument( 'node_tree', type=str, - help = 'JSON output of `bspc query -T -n focused`' + help = 'JSON output of `bspc query -T -n focused`', + required = False ) args = argparser.parse_args() From 0f96bb859130a718b823c4af1783f27789afd427 Mon Sep 17 00:00:00 2001 From: nedia Date: Thu, 20 Jan 2022 11:42:55 +1300 Subject: [PATCH 07/10] fix: set default value in optional pos arg --- polybar-scripts/bspwm-node-flags/bspwm-node-flags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py index b0f5bd0a..feee0b70 100755 --- a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py +++ b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py @@ -13,7 +13,7 @@ 'node_tree', type=str, help = 'JSON output of `bspc query -T -n focused`', - required = False + default = '' ) args = argparser.parse_args() From 9d1ab69ace5441d23fef9e72aacad6388ea09a82 Mon Sep 17 00:00:00 2001 From: nedia Date: Thu, 20 Jan 2022 14:14:23 +1300 Subject: [PATCH 08/10] feat: check node_event in sh, not python --- .../bspwm-node-flags/bspwm-node-flags.py | 52 ++++++++----------- .../bspwm-node-flags/bspwn-node-flags | 10 ++-- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py index feee0b70..15af382b 100755 --- a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py +++ b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py @@ -4,42 +4,32 @@ import json argparser = argparse.ArgumentParser(description = 'Display `bspwm` node flags') -argparser.add_argument( - 'event', - type=str, - help = 'Type of node event output by `bspc subscribe node`' -) argparser.add_argument( 'node_tree', - type=str, - help = 'JSON output of `bspc query -T -n focused`', - default = '' + type = str, + help = 'JSON output of `bspc query -T -n focused`' ) args = argparser.parse_args() -# A couple of the events that are output by `bspc subscribe node` are -# `node_focus` and `node_stack` - we're only worried about the node being in -# focus, or a flag being set on the current node. -if args.event == 'node_focus' or args.event == 'node_flag': - # Parse node_tree JSON output. - node_tree = json.loads(args.node_tree) +# Parse node_tree JSON output. +node_tree = json.loads(args.node_tree) - # We're only concerned with displaying these flags. - flag_states = { - 'S': node_tree['sticky'], - 'X': node_tree['locked'], - 'M': node_tree['marked'], - 'P': node_tree['private'] - } +# We're only concerned with displaying these flags. +flag_states = { + 'S': node_tree['sticky'], + 'X': node_tree['locked'], + 'M': node_tree['marked'], + 'P': node_tree['private'] +} - # Filter out false flags. - if list(flag_states.values()).count(True) > 0: - flags = [ ' ' ] - for flag, state in flag_states.items(): - if state: - flags.append(flag) +# Filter out false flags. +if list(flag_states.values()).count(True) > 0: + flags = [ ' ' ] + for flag, state in flag_states.items(): + if state: + flags.append(flag) - print(''.join(flags)) - else: - # When we've got nothing, we want to clear the output. - print('') + print(''.join(flags)) +else: + # When we've got nothing, we want to clear the output. + print('') diff --git a/polybar-scripts/bspwm-node-flags/bspwn-node-flags b/polybar-scripts/bspwm-node-flags/bspwn-node-flags index 46354a14..9bf2cc37 100644 --- a/polybar-scripts/bspwm-node-flags/bspwn-node-flags +++ b/polybar-scripts/bspwm-node-flags/bspwn-node-flags @@ -1,7 +1,11 @@ #! /usr/bin/env sh bspc subscribe node | while read -a msg; do - event=$msg - node_tree=$(bspc query -T -n focused) - python $HOME/.config/polybar/scripts/bspwm-node-flags.py $event $node_tree + # A couple of the events that are output by `bspc subscribe node` are + # `node_focus` and `node_stack` - we're only worried about the node being in + # focus, or a flag being set on the current node. + if [[ "$msg" == 'node_focus' || "$msg" == 'node_flag' ]]; then + node_tree=$(bspc query -T -n focused) + python $HOME/.config/polybar/scripts/bspwm-node-flags.py $node_tree + fi done From 13eed85c2610a4d471f5dfda8ace5316e382fafe Mon Sep 17 00:00:00 2001 From: nedia Date: Thu, 20 Jan 2022 14:37:49 +1300 Subject: [PATCH 09/10] fix: add default back --- polybar-scripts/bspwm-node-flags/bspwm-node-flags.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py index 15af382b..afc83fb5 100755 --- a/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py +++ b/polybar-scripts/bspwm-node-flags/bspwm-node-flags.py @@ -7,7 +7,8 @@ argparser.add_argument( 'node_tree', type = str, - help = 'JSON output of `bspc query -T -n focused`' + help = 'JSON output of `bspc query -T -n focused`', + default = '' ) args = argparser.parse_args() From d342ec675da4f6c77f2927eeec5a068bed690ea1 Mon Sep 17 00:00:00 2001 From: nedia Date: Thu, 20 Jan 2022 21:33:21 +1300 Subject: [PATCH 10/10] fix: node instances with a name containing a space was breaking things --- polybar-scripts/bspwm-node-flags/bspwn-node-flags | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polybar-scripts/bspwm-node-flags/bspwn-node-flags b/polybar-scripts/bspwm-node-flags/bspwn-node-flags index 9bf2cc37..7e8219da 100644 --- a/polybar-scripts/bspwm-node-flags/bspwn-node-flags +++ b/polybar-scripts/bspwm-node-flags/bspwn-node-flags @@ -6,6 +6,6 @@ bspc subscribe node | while read -a msg; do # focus, or a flag being set on the current node. if [[ "$msg" == 'node_focus' || "$msg" == 'node_flag' ]]; then node_tree=$(bspc query -T -n focused) - python $HOME/.config/polybar/scripts/bspwm-node-flags.py $node_tree + python $HOME/.config/polybar/scripts/bspwm-node-flags.py "$node_tree" fi done