mirror of
https://github.com/elenapan/dotfiles.git
synced 2025-12-29 09:22:42 +08:00
14 lines
497 B
Bash
Executable file
14 lines
497 B
Bash
Executable file
#!/usr/bin/env bash
|
|
query="$1"
|
|
cmd="$2"
|
|
query_focused="${query//\]/ workspace\=__focused__ con_id=__focused__]}"
|
|
|
|
# If focused, move to scratchpad
|
|
if swaymsg "${query_focused} focus" >/dev/null; then
|
|
swaymsg "${query} move window to scratchpad"
|
|
# If not focused, try to move to current workspace and focus
|
|
elif ! swaymsg "${query} scratchpad show"; then
|
|
# If the "scratchpad show" fails, it means the scratchpad was not open.
|
|
# Run the command that spawns the scratchpad
|
|
${cmd}
|
|
fi
|