From 89c9213617aede2a220a7c3a49e0a76e91e33951 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Wed, 13 May 2026 13:43:17 +0100 Subject: refactor(sway): stash thunderbird in scratchpad instead of hidden ws waybar's sway/workspaces has no ignore-list (that option is hyprland-only), so the _tb workspace always leaked into the bar and into super+tab cycling. Using sway's native scratchpad solves both: the __i3_scratch workspace is filtered automatically. We run 'floating disable' right after 'scratchpad show' so the window lands tiled on the current workspace, preserving the intended UX. --- dot_config/sway/config | 12 +++++------ dot_config/sway/executable_tb-toggle.sh | 35 ++++++++++++++++----------------- dot_config/sway/executable_ws-cycle.sh | 18 ----------------- dot_config/waybar/config.jsonc | 1 - 4 files changed, 23 insertions(+), 43 deletions(-) delete mode 100644 dot_config/sway/executable_ws-cycle.sh (limited to 'dot_config') diff --git a/dot_config/sway/config b/dot_config/sway/config index 2c2d4bf..752c5c2 100644 --- a/dot_config/sway/config +++ b/dot_config/sway/config @@ -43,7 +43,7 @@ output * bg #282828 solid_color for_window [class="feh"] floating enable for_window [app_id="imv"] floating enable for_window [class="Tor Browser"] floating enable -for_window [app_id="org.mozilla.Thunderbird" title=".*Mozilla Thunderbird$"] mark --add tb-main, move container to workspace _tb +for_window [app_id="org.mozilla.Thunderbird" title=".*Mozilla Thunderbird$"] mark --add tb-main, move container to scratchpad # ── Standard keybinds (sway defaults) ───────────────────────────────────────── bindsym $mod+Return exec $term @@ -117,9 +117,9 @@ bindsym $mod+Shift+e exec swaynag -t warning -m 'Exit sway?' -B 'Yes' 'swaymsg e # ── Personal keybinds ───────────────────────────────────────────────────────── -# Workspace cycling (skips the _tb stash workspace) -bindsym $mod+Tab exec ~/.config/sway/ws-cycle.sh next -bindsym $mod+Shift+Tab exec ~/.config/sway/ws-cycle.sh prev +# Workspace cycling +bindsym $mod+Tab workspace next_on_output +bindsym $mod+Shift+Tab workspace prev_on_output # Volume bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% @@ -156,8 +156,8 @@ mode "qr" { } bindsym $mod+z mode "qr" -# Thunderbird toggle: main window parked on hidden workspace _tb; this pulls it -# to the current workspace (tiled) or sends it back. Child windows (compose, +# Thunderbird toggle: main window stashed in the scratchpad; this pulls it to +# the current workspace (tiled) or sends it back. Child windows (compose, # viewer, calendar, prefs) tile normally wherever Thunderbird spawns them. bindsym $mod+t exec ~/.config/sway/tb-toggle.sh diff --git a/dot_config/sway/executable_tb-toggle.sh b/dot_config/sway/executable_tb-toggle.sh index 5288484..e52f20a 100644 --- a/dot_config/sway/executable_tb-toggle.sh +++ b/dot_config/sway/executable_tb-toggle.sh @@ -1,31 +1,30 @@ #!/bin/sh -# Toggle the Thunderbird main window between the current workspace (tiled) -# and a hidden stash workspace. If Thunderbird isn't running yet, launch it — -# the for_window rule in sway config will mark and park it on the stash. +# Toggle the Thunderbird main window between the sway scratchpad and the +# current workspace (tiled). If Thunderbird isn't running yet, launch it — +# the for_window rule in sway config will mark it and stash it. set -eu -STASH=_tb MARK=tb-main -current_ws=$(swaymsg -t get_workspaces \ - | jq -r '.[] | select(.focused) | .name') - -tb_ws=$(swaymsg -t get_tree \ - | jq -r --arg m "$MARK" ' - first( - .. | objects - | select(.type=="workspace") - | select([.. | objects | select(.marks? // [] | index($m))] | length > 0) - | .name - ) // empty') +# Find the workspace ancestor name of the con carrying MARK. +# __i3_scratch means the window is currently stashed in the scratchpad. +tb_ws=$(swaymsg -t get_tree | jq -r --arg m "$MARK" ' + first( + .. | objects + | select(.type=="workspace") + | select([.. | objects | select(.marks? // [] | index($m))] | length > 0) + | .name + ) // empty') if [ -z "$tb_ws" ]; then exec thunderbird fi -if [ "$tb_ws" = "$current_ws" ]; then - swaymsg "[con_mark=\"$MARK\"] move container to workspace $STASH" >/dev/null +if [ "$tb_ws" = "__i3_scratch" ]; then + # scratchpad show reveals it as floating; floating disable tiles it on the + # current workspace. + swaymsg "[con_mark=\"$MARK\"] scratchpad show, floating disable" >/dev/null else - swaymsg "[con_mark=\"$MARK\"] move container to workspace $current_ws, focus" >/dev/null + swaymsg "[con_mark=\"$MARK\"] move container to scratchpad" >/dev/null fi diff --git a/dot_config/sway/executable_ws-cycle.sh b/dot_config/sway/executable_ws-cycle.sh deleted file mode 100644 index 28a97f0..0000000 --- a/dot_config/sway/executable_ws-cycle.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# Cycle to the next/previous workspace on the current output, skipping -# the _tb stash workspace. Usage: ws-cycle.sh next|prev -set -eu - -DIR=${1:?usage: ws-cycle.sh next|prev} -SKIP=_tb - -swaymsg -t get_workspaces | jq -r --arg dir "$DIR" --arg skip "$SKIP" ' - (map(select(.focused)) | .[0]) as $cur - | map(select(.output == $cur.output and .name != $skip)) - | sort_by(.num, .name) as $list - | ($list | map(.name == $cur.name) | index(true)) as $i - | if $i == null then $list[0].name - elif $dir == "next" then $list[(($i + 1) % ($list | length))].name - else $list[(($i - 1 + ($list | length)) % ($list | length))].name - end -' | xargs -I{} swaymsg workspace {} >/dev/null diff --git a/dot_config/waybar/config.jsonc b/dot_config/waybar/config.jsonc index 8007257..7711ba0 100644 --- a/dot_config/waybar/config.jsonc +++ b/dot_config/waybar/config.jsonc @@ -20,7 +20,6 @@ "sway/workspaces": { "disable-scroll": true, - "ignore-list": ["_tb"], }, "sway/window": { -- cgit v1.3.1