27 lines
766 B
Bash
Executable File
27 lines
766 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Workspace name for scratchpad
|
|
SCRATCH="special:firefox"
|
|
|
|
# Find Firefox window
|
|
WIN=$(hyprctl clients -j | jq -r '.[] | select(.class == "firefox") | .address' | head -n1)
|
|
|
|
if [ -z "$WIN" ]; then
|
|
# If not running, launch Firefox
|
|
firefox &
|
|
exit
|
|
fi
|
|
|
|
# Get current workspace of Firefox
|
|
CUR=$(hyprctl clients -j | jq -r --arg WIN "$WIN" '.[] | select(.address == $WIN) | .workspace.name')
|
|
|
|
if [ "$CUR" = "$SCRATCH" ]; then
|
|
# If hidden, move back to current workspace
|
|
hyprctl dispatch movetoworkspacesilent "$(hyprctl activeworkspace -j | jq -r .name),address:$WIN"
|
|
hyprctl dispatch focuswindow "address:$WIN"
|
|
else
|
|
# Otherwise, move it to scratchpad
|
|
hyprctl dispatch movetoworkspacesilent "$SCRATCH,address:$WIN"
|
|
fi
|
|
|