From 81dac1aca5c4282a78f69ba729bcb62b5cb8521a Mon Sep 17 00:00:00 2001 From: Ryan Kes Date: Sun, 9 Oct 2022 17:53:25 +0200 Subject: [PATCH] feat: determine chassis type automatically --- .chezmoi.toml.tmpl | 5 +++-- private_dot_config/X11/xresources.tmpl | 2 +- private_dot_config/alacritty/alacritty.yml.tmpl | 2 +- private_dot_config/bspwm/executable_bspwmrc.tmpl | 12 ++++++------ private_dot_config/dunst/dunstrc.tmpl | 2 +- private_dot_config/sxhkd/sxhkdrc.tmpl | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.chezmoi.toml.tmpl b/.chezmoi.toml.tmpl index fb6f42f..ca7729e 100644 --- a/.chezmoi.toml.tmpl +++ b/.chezmoi.toml.tmpl @@ -1,4 +1,5 @@ -{{- $type := promptStringOnce . "type" "Computer type (desktop|laptop)" -}} +{{- $chassisType := "desktop" }} +{{- $chassisType = (output "hostnamectl" "--json=short" | mustFromJson).Chassis }} [data] - type = {{ $type | quote }} + chassisType = {{ $chassisType| quote }} diff --git a/private_dot_config/X11/xresources.tmpl b/private_dot_config/X11/xresources.tmpl index 8aecade..a961120 100644 --- a/private_dot_config/X11/xresources.tmpl +++ b/private_dot_config/X11/xresources.tmpl @@ -2,7 +2,7 @@ ! Xft settings !------------------------------------------------------------------------------- -{{ if ne .type "desktop" }}Xft.dpi: 160{{- end }} +{{ if ne .chassisType "desktop" }}Xft.dpi: 160{{- end }} Xft.antialias: false Xft.rgba: rgb Xft.hinting: true diff --git a/private_dot_config/alacritty/alacritty.yml.tmpl b/private_dot_config/alacritty/alacritty.yml.tmpl index 3779aaf..c73f5c3 100644 --- a/private_dot_config/alacritty/alacritty.yml.tmpl +++ b/private_dot_config/alacritty/alacritty.yml.tmpl @@ -23,7 +23,7 @@ font: style: Bold Italic - size: {{ if eq .type "desktop" }}6.5{{ else }}8.5{{- end }} + size: {{ if eq .chassisType "desktop" }}6.5{{ else }}8.5{{- end }} colors: primary: diff --git a/private_dot_config/bspwm/executable_bspwmrc.tmpl b/private_dot_config/bspwm/executable_bspwmrc.tmpl index 89d49e5..bbed8e2 100644 --- a/private_dot_config/bspwm/executable_bspwmrc.tmpl +++ b/private_dot_config/bspwm/executable_bspwmrc.tmpl @@ -6,7 +6,7 @@ function start_if_not_running if [ (pgrep -u (id -u) -x "$PROCESS_NAME" | wc -l) -lt 1 ] - if type -q $argv[1] + if.chassisType -q $argv[1] eval "$argv[1] &" end end @@ -15,7 +15,7 @@ end ###---Start app in alacritty if not running already---### function start_shell_if_not_running if [ (pgrep -u (id -u) -x $argv[1] | wc -l) -lt 1 ] - if type -q $argv[1] + if.chassisType -q $argv[1] eval "alacritty --class $argv[1],$argv[1] -e $argv[1] &" end end @@ -35,7 +35,7 @@ sxhkd & setxkbmap -option caps:escape ###---Monitors---### -{{- if eq .type "desktop" }} +{{- if eq .chassisType "desktop" }} bspc monitor DP-3 -d 2 3 4 5 6 7 8 9 0 bspc monitor DP-2 -d 1 xrandr --output DP-3 --primary --mode 3840x2160 --rotate normal --output DP-2 --mode 2560x1440 --pos 0x0 --rotate left @@ -51,7 +51,7 @@ killall -q polybar while pgrep -u (id -u) -x polybar >/dev/null sleep 1 end -{{- if eq .type "desktop" }} +{{- if eq .chassisType "desktop" }} polybar-monitor1 & polybar-monitor2 & {{ else }} @@ -60,7 +60,7 @@ polybar framework-bottom & {{- end }} ###---Wallpaper & opacity---### -{{- if eq .type "desktop" }} +{{- if eq .chassisType "desktop" }} xwallpaper --output DP-2 --zoom ~/.cache/wall2.png --output DP-3 --zoom ~/.cache/wall1.png & {{ else }} xwallpaper --output eDP-1 --zoom ~/.cache/wall1.png & @@ -122,7 +122,7 @@ start_if_not_running emacs start_if_not_running element-desktop start_if_not_running element-desktop-nightly start_if_not_running gpodder -{{- if eq .type "desktop" }}start_if_not_running slack{{ end }} +{{- if eq .chassisType "desktop" }}start_if_not_running slack{{ end }} pkill -f cleanfullscreen ~/.local/bin/cleanfullscreen & diff --git a/private_dot_config/dunst/dunstrc.tmpl b/private_dot_config/dunst/dunstrc.tmpl index cb4a312..40643fd 100644 --- a/private_dot_config/dunst/dunstrc.tmpl +++ b/private_dot_config/dunst/dunstrc.tmpl @@ -25,7 +25,7 @@ idle_threshold = 120 - {{- if eq .type "desktop" }} + {{- if eq .chassisType "desktop" }} font = JoyPixels 10, Hack Nerd Font Mono 10 {{ else }} font = JoyPixels 12, Hack Nerd Font Mono 12 diff --git a/private_dot_config/sxhkd/sxhkdrc.tmpl b/private_dot_config/sxhkd/sxhkdrc.tmpl index fa69b6c..ecd0c49 100644 --- a/private_dot_config/sxhkd/sxhkdrc.tmpl +++ b/private_dot_config/sxhkd/sxhkdrc.tmpl @@ -80,11 +80,11 @@ Print #-----------------------------------------------------------App shortcuts-------------------------------------------------------------- # terminal emulator -super + {{ if eq .type "desktop" }}Backspace{{ else }}Return{{- end }} +super + {{ if eq .chassisType "desktop" }}Backspace{{ else }}Return{{- end }} $TERMINAL # program launcher -super + {{ if eq .type "desktop" }}Delete{{ else }}@space{{- end }} +super + {{ if eq .chassisType "desktop" }}Delete{{ else }}@space{{- end }} dmenu-frecency # make sxhkd reload its configuration files: