mirror of
https://github.com/elenapan/dotfiles.git
synced 2025-12-26 15:14:58 +08:00
17 lines
527 B
Bash
Executable file
17 lines
527 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} exec true" >/dev/null; then
|
|
swaymsg "${query} move window to scratchpad"
|
|
else
|
|
# If it exists (but not focused), move to current workspace and focus
|
|
if swaymsg "${query} exec true" >/dev/null; then
|
|
swaymsg "${query} scratchpad show, focus"
|
|
else
|
|
# Window not open, run the command that spawns it
|
|
${cmd}
|
|
fi
|
|
fi
|