summaryrefslogtreecommitdiffstatshomepage
path: root/dot_config
diff options
context:
space:
mode:
authorsommerfeld <sommerfeld@sommerfeld.dev>2026-08-14 14:21:05 +0100
committersommerfeld <sommerfeld@sommerfeld.dev>2026-08-14 14:21:05 +0100
commit6f75cc55c4a2f55d32984e1e6c05d49dca310762 (patch)
treea9285ceb6736f1464a0c5201f192e5115e00bfdf /dot_config
parentccbe17845c579d32a994035bfc153d606a9e8a42 (diff)
downloaddotfiles-6f75cc55c4a2f55d32984e1e6c05d49dca310762.tar.gz
dotfiles-6f75cc55c4a2f55d32984e1e6c05d49dca310762.tar.bz2
dotfiles-6f75cc55c4a2f55d32984e1e6c05d49dca310762.zip
Fix Thunderbird scratchpad targeting
Diffstat (limited to 'dot_config')
-rw-r--r--dot_config/sway/config1
-rw-r--r--dot_config/sway/executable_tb-autostart.sh17
-rw-r--r--dot_config/sway/executable_tb-toggle.sh41
3 files changed, 43 insertions, 16 deletions
diff --git a/dot_config/sway/config b/dot_config/sway/config
index e98278d..62e23c3 100644
--- a/dot_config/sway/config
+++ b/dot_config/sway/config
@@ -50,7 +50,6 @@ for_window [class="feh"] floating enable
for_window [app_id="imv"] floating enable
for_window [app_id="floating"] floating enable
for_window [class="Tor Browser"] floating enable
-for_window [app_id="org.mozilla.thunderbird" title=".*Mozilla Thunderbird$"] mark --add tb-main
for_window [shell=".*"] inhibit_idle fullscreen
for_window [app_id="^[Ww]aydroid.*"] shortcuts_inhibitor disable
diff --git a/dot_config/sway/executable_tb-autostart.sh b/dot_config/sway/executable_tb-autostart.sh
index b7b9b78..d9e503f 100644
--- a/dot_config/sway/executable_tb-autostart.sh
+++ b/dot_config/sway/executable_tb-autostart.sh
@@ -7,6 +7,8 @@
set -eu
MARK=tb-main
+APP_ID=org.mozilla.thunderbird
+TITLE_SUFFIX="Mozilla Thunderbird"
BRIDGE_HOST=127.0.0.1
BRIDGE_IMAP_PORT=1144
BRIDGE_SMTP_PORT=1016
@@ -32,10 +34,17 @@ done
flatpak run org.mozilla.thunderbird &
for _ in $(seq 1 200); do
- if swaymsg -t get_tree | jq -e --arg m "$MARK" '
- [.. | objects | select(.marks? // [] | index($m))] | length > 0
- ' >/dev/null 2>&1; then
- swaymsg "[con_mark=\"$MARK\"] move container to scratchpad" >/dev/null
+ tb_id=$(swaymsg -t get_tree | jq -r \
+ --arg app "$APP_ID" --arg suffix "$TITLE_SUFFIX" '
+ first(
+ .. | objects
+ | select(.app_id? == $app)
+ | select((.name? // "") | endswith($suffix))
+ | .id
+ ) // empty')
+ if [ -n "$tb_id" ]; then
+ swaymsg "[con_id=\"$tb_id\"] mark --add $MARK" >/dev/null
+ swaymsg "[con_id=\"$tb_id\"] move container to scratchpad" >/dev/null
exit 0
fi
sleep 0.1
diff --git a/dot_config/sway/executable_tb-toggle.sh b/dot_config/sway/executable_tb-toggle.sh
index 13382ed..1ad595b 100644
--- a/dot_config/sway/executable_tb-toggle.sh
+++ b/dot_config/sway/executable_tb-toggle.sh
@@ -1,34 +1,53 @@
#!/usr/bin/env dash
# 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.
+# current workspace (tiled). If Thunderbird isn't running yet, launch it.
set -eu
MARK=tb-main
+APP_ID=org.mozilla.thunderbird
+TITLE_SUFFIX="Mozilla Thunderbird"
+
+tree=$(swaymsg -t get_tree)
+tb_id=$(printf '%s\n' "$tree" | jq -r --arg m "$MARK" '
+ first(
+ .. | objects
+ | select(.marks? // [] | index($m))
+ | .id
+ ) // empty')
+
+if [ -z "$tb_id" ]; then
+ tb_id=$(printf '%s\n' "$tree" | jq -r \
+ --arg app "$APP_ID" --arg suffix "$TITLE_SUFFIX" '
+ first(
+ .. | objects
+ | select(.app_id? == $app)
+ | select((.name? // "") | endswith($suffix))
+ | .id
+ ) // empty')
+ if [ -z "$tb_id" ]; then
+ exec flatpak run org.mozilla.thunderbird
+ fi
+ swaymsg "[con_id=\"$tb_id\"] mark --add $MARK" >/dev/null
+fi
-# 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" '
+tb_ws=$(printf '%s\n' "$tree" | jq -r --argjson id "$tb_id" '
first(
.. | objects
| select(.type=="workspace")
- | select([.. | objects | select(.marks? // [] | index($m))] | length > 0)
+ | select([.. | objects | select(.id? == $id)] | length > 0)
| .name
) // empty')
-if [ -z "$tb_ws" ]; then
- exec flatpak run org.mozilla.thunderbird
-fi
-
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
+ swaymsg "[con_id=\"$tb_id\"] scratchpad show, floating disable" >/dev/null
else
# Criteria-based move can cause sway to follow focus to the originating
# workspace. Pin focus back to where we started.
current_ws=$(swaymsg -t get_workspaces | jq -r '.[] | select(.focused) | .name')
- swaymsg "[con_mark=\"$MARK\"] move container to scratchpad" >/dev/null
+ swaymsg "[con_id=\"$tb_id\"] move container to scratchpad" >/dev/null
swaymsg "workspace \"$current_ws\"" >/dev/null
fi