summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlen <alen@dotfiles.xyz>2023-09-14 01:18:30 +0400
committerAlen <alen@dotfiles.xyz>2023-09-14 01:36:41 +0400
commit0266521687393cb5e1f816bcdb9631147a23b19c (patch)
tree6a74350923c40c86d11cb004d626003ba6d98cf6
parentf409087b2524f0742e333e642c900aeb87a42550 (diff)
Fix and simplify run_gnome_tweaks.sh.tmpl
-rw-r--r--.chezmoi.toml.tmpl5
-rwxr-xr-xrun_gnome_tweaks.sh.tmpl16
2 files changed, 10 insertions, 11 deletions
diff --git a/.chezmoi.toml.tmpl b/.chezmoi.toml.tmpl
index 671e923..a72f05f 100644
--- a/.chezmoi.toml.tmpl
+++ b/.chezmoi.toml.tmpl
@@ -22,3 +22,8 @@
 
 [data.ssh]
     user = {{ promptString "SSH default user" $defaultUsername | quote }}
+
+{{ if lookPath "dconf" -}}
+[data.gnome]
+    buttonLayout = {{ promptString "GNOME WM button layout" "close,appmenu:" | quote }}
+{{- end }}
diff --git a/run_gnome_tweaks.sh.tmpl b/run_gnome_tweaks.sh.tmpl
index eaa37d2..b5d440e 100755
--- a/run_gnome_tweaks.sh.tmpl
+++ b/run_gnome_tweaks.sh.tmpl
@@ -2,21 +2,15 @@
 
 set -e
 
-# TODO: Move settings to .chezmoi.toml.tmpl
-
 dconf write /org/gnome/desktop/interface/color-scheme "'prefer-dark'"
-{{ if eq .chezmoi.username "sophie" }}
-  dconf write /org/gnome/desktop/wm/preferences/button-layout "':appmenu,close'"
-{{ else }}
-  dconf write /org/gnome/desktop/wm/preferences/button-layout "'close,appmenu:'"
-{{ end }}
+dconf write /org/gnome/desktop/wm/preferences/button-layout "'{{ .gnome.buttonLayout }}'"
 
-{{ if and (lookPath "systemd-detect-virt") (ne (output "systemd-detect-virt") "none") }}
+if systemd-detect-virt &>/dev/null; then
   dconf write /org/gnome/desktop/session/idle-delay "uint32 0"
   dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type "'nothing'"
-{{ end }}
+fi
 
-{{ if and (lookPath "hostnamectl") (eq (output "hostnamectl" "chassis") "laptop" "vm") }}
+if [[ "$(hostnamectl chassis 2>/dev/null)" =~ ^(vm|laptop)$ ]]; then
   dconf write /org/gnome/desktop/peripherals/mouse/natural-scroll "true"
   dconf write /org/gnome/desktop/peripherals/touchpad/two-finger-scrolling-enabled "true"
-{{ end }}
+fi