1
0
Fork 0

Make sway hostname match support suffix forms (byte-arch etc.)

The previous `has .chezmoi.hostname ` only matched exact
strings. byte's hostname is `byte-arch` (set by the CachyOS installer),
so it didn't match the `byte` entry in the allowlist and got sway=false.

New logic: hostname matches if it equals any entry OR starts with
'<entry>-' or '<entry>.'. So 'byte', 'byte-arch', and 'byte.foo' all
match the 'byte' entry.
This commit is contained in:
Rain 2026-06-22 14:26:01 -04:00
parent 6bbaa8f2f5
commit bc2ceb5e52

View file

@ -76,6 +76,15 @@ data:
{{- else if $swayOverrideOff }} {{- else if $swayOverrideOff }}
sway: false sway: false
{{- else }} {{- else }}
{{- /* Hostname allowlist for the desktop stack. Match if hostname
equals or starts with any of the listed prefixes (e.g. "byte"
matches both "byte" and "byte-arch"). */}}
{{- $swayHosts := list "miche" "byte" "kaiser" }} {{- $swayHosts := list "miche" "byte" "kaiser" }}
sway: {{ has .chezmoi.hostname $swayHosts }} {{- $swayMatch := false }}
{{- range $swayHosts }}
{{- if or (eq . $.chezmoi.hostname) (hasPrefix (printf "%s-" .) $.chezmoi.hostname) (hasPrefix (printf "%s." .) $.chezmoi.hostname) }}
{{- $swayMatch = true }}
{{- end }}
{{- end }}
sway: {{ $swayMatch }}
{{- end }} {{- end }}