irongit
hygoland/UserScripts/ToggleMinimize.sh
25 lines763 BBourne Again Shell (bash)
1#!/bin/bash
2
3details=$(hyprctl clients -j | jq -r '.[] | select(.class | test("'"$1"'"; "i"))')
4class=$(echo "$details" | jq -r '.class')
5workspace=$(echo "$details" | jq -r '.workspace.name')
6echo "$class $workspace"
7
8# Launch app and exit if class is not found
9if [ -z "$details" ]; then
10 $2 &>/dev/null &
11 exit 0
12fi
13
14cur_workspace=$(hyprctl activeworkspace -j | jq '.id')
15
16# Toggle minimized
17if [ "$workspace" = "special:minimized" ]; then
18 # Bring to current workspace
19 echo "moving to workspace: $cur_workspace"
20 hyprctl dispatch movetoworkspacesilent "$cur_workspace", "class:$class"
21else
22 # Move to special:minimized
23 echo "moving to minimized workspace"
24 hyprctl dispatch movetoworkspacesilent special:minimized, "class:$class"
25fi