Import from root chezmoi source
This commit is contained in:
commit
97a309bbe3
21 files changed
+1394
No files matched your search
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/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"
|
||||
Reference in new issue
Block a user