Skip to content

Commit

Permalink
sway: Fix dropdown terminals not being brought into focus when toggled
Browse files Browse the repository at this point in the history
  • Loading branch information
zapling committed Nov 21, 2024
1 parent a42bb2b commit bc5ef8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .config/sway/config
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ bar {
### Key bindings

# Dropdown terminals
bindsym $mod+u [app_id="dropdown1"] scratchpad show
bindsym $mod+Shift+u [app_id="dropdown2"] scratchpad show
bindsym $mod+u exec ~/.local/bin/swayvm-toggle-scratchpad dropdown1
bindsym $mod+Shift+u exec ~/.local/bin/swayvm-toggle-scratchpad dropdown2

# Browser
bindsym $mod+Shift+t exec firefox
Expand Down
13 changes: 13 additions & 0 deletions .local/bin/swayvm-toggle-scratchpad
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

target=$1
data=$(swaymsg -t get_tree | jq ".. | select(.type?) | select(.app_id==\"$target\" or .window_properties.class==\"$target\")")
id=$(echo "$data" | jq ".id")
is_visible=$(echo "$data" | jq ".visible")

if [[ "$is_visible" == "true" ]]; then
swaymsg "[con_id=$id] scratchpad show"
exit
fi

swaymsg "[con_id=$id] scratchpad show" && swaymsg "[con_id=$id] focus"

0 comments on commit bc5ef8d

Please sign in to comment.