⬆️ switch from jq to jaq

This commit is contained in:
Laureηt 2023-06-10 20:36:41 +02:00
parent c0c2a18d78
commit 06f9283378
Signed by: Laurent
SSH key fingerprint: SHA256:kZEpW8cMJ54PDeCvOhzreNr4FSh6R13CMGH/POoO8DI
3 changed files with 9 additions and 7 deletions

View file

@ -11,7 +11,7 @@
home.packages = with pkgs; [ home.packages = with pkgs; [
swaybg # wayland background swaybg # wayland background
socat # socket cat socat # socket cat
jq # json utils jaq # (fast) json utils
borgbackup # backup borgbackup # backup
dconf # required by home-manager dconf # required by home-manager
duf # replacement for df duf # replacement for df

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# print current active workspace id # 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 # print current active workspace id on workspace changes
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - |

View file

@ -1,9 +1,11 @@
#!/bin/bash #!/bin/bash
EMPTY=$(seq 1 10 | jaq -nRc '[inputs | (. | tostring)] | {(.[]): 0}')
# function to get workspaces infos and their window count # function to get workspaces infos and their window count
spaces (){ spaces (){
WORKSPACE_WINDOWS=$(hyprctl workspaces -j | jq 'map({key: .id | tostring, value: .windows}) | from_entries') ACTIVES=$(hyprctl workspaces -j | jaq -c '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)})' echo $EMPTY $ACTIVES | jaq -src 'add | to_entries | map({id: (.key | tostring), windows: .value})'
} }
# print workspaces infos # print workspaces infos