From 06f9283378ff9f9ccf7bb779ae7e430ee0aabc11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure=CE=B7t?= Date: Sat, 10 Jun 2023 20:36:41 +0200 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20switch=20from=20`jq`=20to?= =?UTF-8?q?=20`jaq`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hosts/neodymium/home/packages.nix | 2 +- .../home/wayland/eww/scripts/get-active-workspace | 4 ++-- .../neodymium/home/wayland/eww/scripts/get-workspaces | 10 ++++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hosts/neodymium/home/packages.nix b/hosts/neodymium/home/packages.nix index 5cacc1d..de1e2c2 100644 --- a/hosts/neodymium/home/packages.nix +++ b/hosts/neodymium/home/packages.nix @@ -11,7 +11,7 @@ home.packages = with pkgs; [ swaybg # wayland background socat # socket cat - jq # json utils + jaq # (fast) json utils borgbackup # backup dconf # required by home-manager duf # replacement for df diff --git a/hosts/neodymium/home/wayland/eww/scripts/get-active-workspace b/hosts/neodymium/home/wayland/eww/scripts/get-active-workspace index 165002b..c2c42c5 100755 --- a/hosts/neodymium/home/wayland/eww/scripts/get-active-workspace +++ b/hosts/neodymium/home/wayland/eww/scripts/get-active-workspace @@ -1,8 +1,8 @@ #!/usr/bin/env bash # print current active workspace id -hyprctl monitors -j | jq '.[] | select(.focused) | .activeWorkspace.id' +hyprctl monitors -j | jaq '.[] | select(.focused) | .activeWorkspace.id' # print current active workspace id on workspace changes socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | - stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}' \ No newline at end of file + stdbuf -o0 awk -F '>>|,' -e '/^workspace>>/ {print $2}' -e '/^focusedmon>>/ {print $3}' diff --git a/hosts/neodymium/home/wayland/eww/scripts/get-workspaces b/hosts/neodymium/home/wayland/eww/scripts/get-workspaces index 6eb1cf5..31d5798 100755 --- a/hosts/neodymium/home/wayland/eww/scripts/get-workspaces +++ b/hosts/neodymium/home/wayland/eww/scripts/get-workspaces @@ -1,15 +1,17 @@ #!/bin/bash +EMPTY=$(seq 1 10 | jaq -nRc '[inputs | (. | tostring)] | {(.[]): 0}') + # function to get workspaces infos and their window count spaces (){ - WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries') - seq 1 10 | jq --argjson windows "${WORKSPACE_WINDOWS}" --slurp -Mc 'map(tostring) | map({id: ., windows: ($windows[.]//0)})' + ACTIVES=$(hyprctl workspaces -j | jaq -c 'map({key: .id | tostring, value: .windows}) | from_entries') + echo $EMPTY $ACTIVES | jaq -src 'add | to_entries | map({id: (.key | tostring), windows: .value})' } # print workspaces infos spaces -# print info on workspace changes +# print info on workspace changes socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | while read -r line; do spaces -done \ No newline at end of file +done