summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlen <alen@dotfiles.xyz>2023-09-12 00:22:35 +0400
committerAlen <alen@dotfiles.xyz>2023-09-12 00:28:38 +0400
commite8015fdbc726da24fde3f71ce9445500a41c2103 (patch)
treeaad3abdcd9ecd4ab67e74025e0c69835e6a65954
parent019c873fc8ec98e615d70b2dcaf77ac277a352a0 (diff)
Refactor run scripts to be tad bit simpler
-rw-r--r--.chezmoiignore6
-rwxr-xr-xrun_gnome_tweaks.sh.tmpl37
-rw-r--r--run_macos_dock.sh.tmpl19
3 files changed, 28 insertions, 34 deletions
diff --git a/.chezmoiignore b/.chezmoiignore
index 2466552..7f855d2 100644
--- a/.chezmoiignore
+++ b/.chezmoiignore
@@ -8,3 +8,9 @@
 
 # Ignore Library/ for non-macOS
 {{ if ne .chezmoi.os "darwin" -}} /Library/ {{- end }}
+
+# Ignore run_macos_* for non-macOS
+{{ if ne .chezmoi.os "darwin" -}} /*macos_*.sh {{- end }}
+
+# Ignore run_gnome_* for non-GNOME
+{{ if not (lookPath "dconf") -}} /*gnome_*.sh {{- end }}
diff --git a/run_gnome_tweaks.sh.tmpl b/run_gnome_tweaks.sh.tmpl
index 1c6664c..eaa37d2 100755
--- a/run_gnome_tweaks.sh.tmpl
+++ b/run_gnome_tweaks.sh.tmpl
@@ -2,28 +2,21 @@
 
 set -e
 
-# TODO: Move the lookPath dconf and OS check to chezmoi ignore level
-{{ if lookPath "dconf" }}
-  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 }}
+# TODO: Move settings to .chezmoi.toml.tmpl
 
-  {{ if lookPath "systemd-detect-virt" }}
-    {{ $virt := output "systemd-detect-virt" }}
-    {{ if ne $virt "none" }}
-      dconf write /org/gnome/desktop/session/idle-delay "uint32 0"
-      dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type "'nothing'"
-    {{ end }}
-  {{ end }}
+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 }}
+
+{{ if and (lookPath "systemd-detect-virt") (ne (output "systemd-detect-virt") "none") }}
+  dconf write /org/gnome/desktop/session/idle-delay "uint32 0"
+  dconf write /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type "'nothing'"
+{{ end }}
 
-  {{ if lookPath "hostnamectl" }}
-    {{ $chassis := output "hostnamectl" "chassis" }}
-      {{ if or (eq $chassis "laptop") (eq $chassis "vm") }}
-        dconf write /org/gnome/desktop/peripherals/mouse/natural-scroll "true"
-        dconf write /org/gnome/desktop/peripherals/touchpad/two-finger-scrolling-enabled "true"
-      {{ end }}
-  {{ end }}
+{{ if and (lookPath "hostnamectl") (eq (output "hostnamectl" "chassis") "laptop" "vm") }}
+  dconf write /org/gnome/desktop/peripherals/mouse/natural-scroll "true"
+  dconf write /org/gnome/desktop/peripherals/touchpad/two-finger-scrolling-enabled "true"
 {{ end }}
diff --git a/run_macos_dock.sh.tmpl b/run_macos_dock.sh.tmpl
index 231fb22..db87fbd 100644
--- a/run_macos_dock.sh.tmpl
+++ b/run_macos_dock.sh.tmpl
@@ -2,15 +2,10 @@
 
 set -e
 
-# TODO: Move the lookPath defaults and OS check to chezmoi ignore level
-{{ if eq .chezmoi.os "darwin" -}}
-if which defaults &>/dev/null; then
-    defaults write com.apple.dock autohide-time-modifier -float 0.25
-    defaults write com.apple.dock autohide-delay -float 0
-    defaults write com.apple.dock orientation -string left
-    defaults write com.apple.dock show-recents -bool false
-    defaults write com.apple.dock autohide -bool true
-    defaults write com.apple.dock tilesize -float 50.0
-    killall Dock
-fi
-{{ end }}
+defaults write com.apple.dock autohide-time-modifier -float 0.25
+defaults write com.apple.dock autohide-delay -float 0
+defaults write com.apple.dock orientation -string left
+defaults write com.apple.dock show-recents -bool false
+defaults write com.apple.dock autohide -bool true
+defaults write com.apple.dock tilesize -float 50.0
+killall Dock