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:
parent
6bbaa8f2f5
commit
bc2ceb5e52
1 changed files with 10 additions and 1 deletions
|
|
@ -76,6 +76,15 @@ data:
|
|||
{{- else if $swayOverrideOff }}
|
||||
sway: false
|
||||
{{- 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" }}
|
||||
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 }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue