aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config/sway
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-13 13:43:22 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-13 13:43:22 +0100
commit740aaf55a6e6c969e01f0b032c4142a126680eb8 (patch)
tree216c482487a78824888f50a3c3b02be006943739 /dot_config/sway
parentac0654daf06a9d01fd264d96c00c8ab47b90cb73 (diff)
downloaddotfiles-740aaf55a6e6c969e01f0b032c4142a126680eb8.tar.gz
dotfiles-740aaf55a6e6c969e01f0b032c4142a126680eb8.tar.bz2
dotfiles-740aaf55a6e6c969e01f0b032c4142a126680eb8.zip
fix(sway): wait for protonmail-bridge IMAP banner before launching TB
The bridge opens the IMAP listener before the keyring is unlocked, so a port-open check returns true while the server would still reject logins. Probe for the '* OK' IMAP greeting (the bridge only sends it once it can actually service logins) and add a 1s grace period for SMTP (1025) to catch up.
Diffstat (limited to 'dot_config/sway')
-rw-r--r--dot_config/sway/executable_tb-autostart.sh22
1 files changed, 14 insertions, 8 deletions
diff --git a/dot_config/sway/executable_tb-autostart.sh b/dot_config/sway/executable_tb-autostart.sh
index c711e7f..ceae5de 100644
--- a/dot_config/sway/executable_tb-autostart.sh
+++ b/dot_config/sway/executable_tb-autostart.sh
@@ -7,18 +7,24 @@
set -eu
MARK=tb-main
+BRIDGE_HOST=127.0.0.1
BRIDGE_PORT=1143
-# Wait for protonmail-bridge's IMAP listener before launching Thunderbird so
-# TB doesn't pop up a "failed to login to 127.0.0.1" error on cold boot. Give
-# up after ~15s and launch anyway — the user can reconnect manually.
-for _ in $(seq 1 150); do
- if ss -ltnH "sport = :$BRIDGE_PORT" 2>/dev/null | grep -q .; then
- break
- fi
- sleep 0.1
+# protonmail-bridge opens the IMAP socket early (before the keyring is
+# unlocked), so "port is listening" is not enough — TB will race and pop up
+# "failed to login to 127.0.0.1". Wait for the real IMAP '* OK' greeting,
+# which the bridge only sends once it can actually service logins.
+for _ in $(seq 1 300); do
+ banner=$(ncat -w 1 -i 1 "$BRIDGE_HOST" "$BRIDGE_PORT" </dev/null 2>/dev/null | head -c 64)
+ case "$banner" in
+ "* OK"*) break ;;
+ esac
+ sleep 0.2
done
+# Small grace period so the SMTP listener (1025) catches up too.
+sleep 1
+
thunderbird &
for _ in $(seq 1 200); do