mirror of
https://github.com/elenapan/dotfiles.git
synced 2026-01-11 09:11:01 +08:00
Make scratchpad-toggle explicitly focus the window if unfocused
This commit is contained in:
parent
e6b06c8bd2
commit
4dca14db75
1 changed files with 9 additions and 6 deletions
|
|
@ -4,11 +4,14 @@ cmd="$2"
|
|||
query_focused="${query//\]/ workspace\=__focused__ con_id=__focused__]}"
|
||||
|
||||
# If focused, move to scratchpad
|
||||
if swaymsg "${query_focused} focus" >/dev/null; then
|
||||
if swaymsg "${query_focused} exec true" >/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}
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue