Fix multi-monitor workspace routing regression, add laptop auto-detect

- Restore desktop DP-3=primary/DP-2=secondary workspace mapping that
  broke when workspace routing switched from name-matching to raw
  geometric ordering.
- Extract shared laptop/desktop detection + output ranking into
  lib-outputs.sh (battery presence selects the profile automatically),
  sourced by both select-workspace.sh and the new apply-outputs.sh, so
  keybind routing and monitor placement can never disagree.
- Add apply-outputs.sh: on the laptop, automatically positions whatever
  external display is plugged in (and re-runs on hotplug via swaymsg
  -t subscribe), making it primary. No-op on the desktop, which keeps
  its static fixed-arrangement config.
This commit is contained in:
2026-08-21 23:08:01 -05:00
parent 5c57ee20f7
commit f1275e7870
5 changed files with 106 additions and 12 deletions
+9 -5
View File
@@ -16,11 +16,15 @@ output * bg ~/.config/sway/wallpapers/blue-horizon.svg fill
# Desktop-only dual-monitor arrangement: DP-3 is the centered primary
# display, DP-2 sits immediately to its left. Sway silently ignores
# `output` directives for names that don't exist, so this is a no-op on
# the single-monitor laptop (its internal panel, e.g. eDP-1, is untouched
# and simply gets everything). Workspace-to-output routing is not pinned
# here; scripts/select-workspace.sh assigns workspaces to whichever
# outputs are actually connected, in left-to-right order, so it adapts
# automatically on both machines without any per-host config.
# the laptop, where scripts/apply-outputs.sh instead positions whatever
# external display gets plugged in dynamically (see that script and
# scripts/lib-outputs.sh for the shared laptop/desktop detection logic).
#
# Workspace-to-output routing isn't pinned here either way:
# scripts/select-workspace.sh (shared with apply-outputs.sh) assigns
# workspaces 1-10/11-20/... to whichever outputs are connected, ranked
# primary-first, so both keybinds and monitor placement always agree on
# which output is "first" without any per-host config.
output DP-3 position 0 0
output DP-2 position -2560 0
+1
View File
@@ -1,4 +1,5 @@
exec_always --no-startup-id sh -c 'pkill waybar; exec waybar'
exec_always --no-startup-id sh -c 'pkill -f apply-outputs.sh; exec ~/.config/sway/scripts/apply-outputs.sh'
exec --no-startup-id mako
exec --no-startup-id nm-applet --indicator
exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1