From a6e3fced1a8aaacfc65f54d507ac11bc31fef411 Mon Sep 17 00:00:00 2001 From: aloslider <53711835+aloslider@users.noreply.github.com> Date: Mon, 19 Oct 2026 22:08:45 +0300 Subject: [PATCH] [scripts] Make discord script work for both clients --- dot_local/scripts/discord/executable_toggle-key.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dot_local/scripts/discord/executable_toggle-key.sh b/dot_local/scripts/discord/executable_toggle-key.sh index 85040fe..f2f9299 100644 --- a/dot_local/scripts/discord/executable_toggle-key.sh +++ b/dot_local/scripts/discord/executable_toggle-key.sh @@ -1,7 +1,6 @@ #!/bin/sh set -eu -APP_NAME="discord-canary" KEY="${1:-${KEY:-}}" if [ -z "$KEY" ]; then @@ -13,11 +12,15 @@ fi PREV_FOCUS=$(niri msg -j focused-window | jq -r '.id // empty') WINS=$(niri msg -j windows) WSS=$(niri msg -j workspaces) -DISCORD_ID=$(printf '%s' "$WINS" | jq -r --arg a "$APP_NAME" \ - '.[] | select(.app_id == $a) | .id' | head -n1) +DISCORD_ID=$(printf '%s' "$WINS" | jq -r --arg focus "$PREV_FOCUS" ' + [ .[] | select(.app_id == "discord" or .app_id == "discord-canary") ] + | (map(select(.id == ($focus | tonumber? // -1))) | .[0].id) // + (map(select(.app_id == "discord-canary")) | .[0].id) // + (.[0].id // empty) +') if [ -z "$DISCORD_ID" ]; then - notify-send "Discord not found" "Could not find $APP_NAME window" + notify-send "Discord not found" "No discord or discord-canary window" exit 1 fi