{{- $chassisType := "desktop" }} {{- if eq .chezmoi.os "darwin" }} {{- if contains "MacBook" (output "sysctl" "-n" "hw.model") }} {{- $chassisType = "laptop" }} {{- else }} {{- $chassisType = "desktop" }} {{- end }} {{- else if eq .chezmoi.os "linux" }} {{- $chassisType = (output "hostnamectl" "--json=short" | mustFromJson).Chassis }} {{- else if eq .chezmoi.os "windows" }} {{- $chassisType = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "if ((Get-CimInstance -Class Win32_Battery | Measure-Object).Count -gt 0) { Write-Output 'laptop' } else { Write-Output 'desktop' }") | trim }} {{- end }} {{- $cpuCores := 1 }} {{- $cpuThreads := 1 }} {{- if eq .chezmoi.os "darwin" }} {{- $cpuCores = (output "sysctl" "-n" "hw.physicalcpu_max") | trim | atoi }} {{- $cpuThreads = (output "sysctl" "-n" "hw.logicalcpu_max") | trim | atoi }} {{- else if eq .chezmoi.os "linux" }} {{- $cpuCores = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | sort --field-separator=',' --key='2,4' --unique | wc --lines") | trim | atoi }} {{- $cpuThreads = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | wc --lines") | trim | atoi }} {{- else if eq .chezmoi.os "windows" }} {{- $cpuCores = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfCores") | trim | atoi }} {{- $cpuThreads = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfLogicalProcessors") | trim | atoi }} {{- end -}} [merge] command = "bash" args = [ "-c", "cp {{ "{{" }} .Target {{ "}}" }} {{ "{{" }} .Target {{ "}}" }}.base && code --new-window --wait --merge {{ "{{" }} .Destination {{ "}}" }} {{ "{{" }} .Target {{ "}}" }} {{ "{{" }} .Target {{ "}}" }}.base {{ "{{" }} .Source {{ "}}" }}", ] [data] chassis = "{{ $chassisType }}" [data.cpu] cores = {{ $cpuCores }} threads = {{ $cpuThreads }} encryption = "age" [age] identity = "/home/xevion/key.txt" recipient = "age1s3ctpj9lafl6qwyvd89sn448us7gdzd53d8yyhsc7zny78c0k4sqerrkze" [hooks.read-source-state.pre] command = ".local/share/chezmoi/.install-password-manager.sh"