aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rwxr-xr-xi3blocks/.local/lib/i3blocks/i3blocks-title26
1 files changed, 10 insertions, 16 deletions
diff --git a/i3blocks/.local/lib/i3blocks/i3blocks-title b/i3blocks/.local/lib/i3blocks/i3blocks-title
index 52ffd47..716f56f 100755
--- a/i3blocks/.local/lib/i3blocks/i3blocks-title
+++ b/i3blocks/.local/lib/i3blocks/i3blocks-title
@@ -1,23 +1,17 @@
#!/bin/sh
-swaymsg -t get_tree |
- jq --compact-output '.. | select(.focused? == true and .type == "con") |
- {
- "full_text": (.name // ""),
- "short_text": ([.app_id, .window_title] | map(select(. != null and . != "")) | (first // "")),
- }
-'
+into_block='{
+ "full_text": (.name // ""),
+ "short_text": ([.app_id, .window_title, .name] | map(select(. != null and . != "")) | (first // "")),
+} | .short_text |= .[0:(env.max_width // (. | length) | tonumber)]'
+
+swaymsg -t get_tree | jq -c '.. | select(.focused? == true and .type == "con") | '"$into_block"
-swaymsg --monitor -t subscribe '["window", "workspace"]' |
- jq --compact-output --unbuffered '
- if .change == "close" and .container.focused == true then
+swaymsg --monitor -t subscribe '["window", "workspace"]' | jq -c --unbuffered '
+ select((.change | test("close|focus|title")) and (.current.type == "workspace" or .container.focused)) |
+ if .current.type == "workspace" or .change == "close" then
{ "full_text": "" }
- elif .change == "focus" or (.change == "title" and .container.focused == true) then
- .container | {
- "full_text": (.name // ""),
- "short_text": ([.app_id, .window_title] | map(select(. != null and . != "")) | (first // "")),
- }
else
- empty
+ .container | '"$into_block"'
end
'