Files
dotfiles/dot_config/niri/scripts/executable_ndw-route-workspace.sh
T
Prad NukalaandClaude Fable 5 2142bdf9cb feat(arch-layer,scripts): linux-gated desktop configs + package install scripts
niri (exact_config.d, scripts), noctalia (plugins excluded — runtime
state with embedded token), fontconfig, mimeapps.list,
niri-dynamic-workspaces, systemd user unit files (enable-state not
managed; only nirinit enabled by run_once), niri-launch vendored from
/usr/bin (unowned hand-written script, shellcheck warnings pre-existing).

Scripts: packages (pacman --needed + paru, brew on darwin, root-safe,
keyed on packages.yaml hash), gh extensions (idempotent), user services
(linux), post (tpm clone, bat cache, fc-cache). All shellcheck-clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-09 14:56:09 -04:00

43 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# ndw-route-workspace.sh
# Routes a niri-dynamic-workspaces workspace to the correct monitor by
# resolving the Apple Studio Display's connector at runtime.
#
# Inputs: NDW_WORKSPACE_KEY env var (set by ndw on_create), or $1.
# Exits silently on unknown keys so it's safe to call for all workspaces.
set -euo pipefail
KEY="${NDW_WORKSPACE_KEY:-${1:-}}"
[ -z "$KEY" ] && exit 0
INTERNAL="HDMI-A-1"
# Resolve the external Apple Studio Display connector.
# Match by make+model; fall back to eDP-1 if not currently connected.
resolve_external() {
niri msg --json outputs | jq -r '
to_entries
| map(select(
.value.make == "Apple Computer Inc"
and .value.model == "StudioDisplay"
))
| .[0].key // empty
'
}
case "$KEY" in
y|g|m|x|z|p|l|a)
target="$INTERNAL"
;;
b|f|s|w|c|d|o)
target="$(resolve_external)"
[ -z "$target" ] && target="$INTERNAL" # external not connected
;;
*)
exit 0
;;
esac
exec niri msg action move-workspace-to-monitor "$target"