Skip to content

Commit

Permalink
refactor(chezmoi): misc cleanup in chezmoi data
Browse files Browse the repository at this point in the history
  • Loading branch information
scottames committed Nov 13, 2024
1 parent efab434 commit 2c4ab03
Show file tree
Hide file tree
Showing 20 changed files with 86 additions and 99 deletions.
1 change: 1 addition & 0 deletions .trunk/configs/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.md
.gsettings.yaml
*.jsonc
1 change: 1 addition & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
version: 0.1
cli:
version: 1.22.8
Expand Down
73 changes: 45 additions & 28 deletions home/.chezmoi.toml.tmpl
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
{{- $name := "Scott Ames" -}}
{{- $dotsStr := "dots" -}}
{{- $email := "[email protected]" -}}
{{- $githubUser := "scottames" -}}
{{- $fontMonospace := "FiraCode Nerd Font Mono" -}}
{{- $chassis := "" -}}
{{- $gpu := "" -}}
{{- $isContainer := false -}}
{{- $isDistroBox := false -}}
{{- $isUblue := false -}}

{{- $chassis := "" -}}
{{- $desktopSession := env "DESKTOP_SESSION" -}}
{{- $gpu := "" -}}
{{- $hostname := "" -}}
{{- $hourDark := 24 -}}
{{- $hourLight := 24 -}}
{{- $osVariant := "" -}}
{{- $ublueImageInfo := "" -}}
{{- $dotsStr := "dots" -}}

{{- $isContainer := false -}}
{{- $isDistroBox := false -}}
{{- $isUblue := false -}}
{{- $loginSession := 0 -}}
{{- $loginSessionType := "" -}}

{{- $osVariant := "" -}}
{{- $ublueImageInfo := "" -}}
{{- $useGitWorktrees := true -}}

{{- if $useGitWorktrees -}}
{{- $dotsStr = "dots/main" -}}
{{- $dotsStr = printf "%s/main" $dotsStr -}}
{{- end -}}

{{- $gravatarID := trim (
output "sh" "-c" "printf '[email protected]' | md5sum - | cut -d' ' -f1"
output "sh" "-c" "printf '[email protected]' | md5sum - | cut -d' ' -f1"
) -}}

{{- if eq .chezmoi.os "linux" -}}
Expand All @@ -41,6 +42,9 @@ output "sh" "-c" "printf '[email protected]' | md5sum - | cut -d' ' -f1"
{{- $chassis = trim (
output "distrobox-host-exec" "hostnamectl" "chassis"
) -}}
{{- $hostname = trim (
output "distrobox-host-exec" "hostnamectl" "hostname"
) -}}
{{- $loginSession = trim (
output "distrobox-host-exec" "sh" "-c" "loginctl | grep user | awk '{print $1}'"
) -}}
Expand Down Expand Up @@ -95,41 +99,54 @@ output "sh" "-c" "printf '[email protected]' | md5sum - | cut -d' ' -f1"

sourceDir = "{{ $chezmoiSourceDir }}"
progress = true
{{- if lookPath "delta" }}

{{ if lookPath "delta" -}}
[diff]
pager = "delta"
command = "delta"
args = ["--paging", "never"]
exclude = ["dirs", "scripts"]
{{- end }}

{{ end -}}
[data]
aqua_installed = {{ $aquaInstalled }}
aqua_bin_dir = "{{ $aquaRoot }}/bin"
aqua_root = "{{ $aquaRoot }}"
chezmoi_home = "{{ $chezmoiSourceDir }}"
desktop_session = "{{ $desktopSession }}"
dots = "{{ $dots }}"
hour_dark = {{ $hourDark }}
hour_light = {{ $hourLight }}
login_session = {{ $loginSession }}
login_session_type = "{{ $loginSessionType }}"
monospace_font = "{{ $fontMonospace }}"
wallpaper = "{{ $wallpaper }}"
[data.home]
chezmoi_home = "{{ $chezmoiSourceDir }}"
dots = "{{ $dots }}"

[data.home.aqua]
installed = {{ $aquaInstalled }}
bin_dir = "{{ $aquaRoot }}/bin"
root = "{{ $aquaRoot }}"

[data.host]
name = "{{ $hostname }}"
chassis = "{{ $chassis }}"
is_ublue = {{ $isUblue }}
os_variant = "{{ $osVariant }}"
gpu = "{{ $gpu }}"

[data.desktop]
session = "{{ $desktopSession }}"
wallpaper = "{{ $wallpaper }}"

[data.desktop.fonts]
monospace = "{{ $fontMonospace }}"

[data.desktop.hour]
light = 24
dark = 24

[data.desktop.login]
session = {{ $loginSession }}
type = "{{ $loginSessionType }}"

[data.me]
user = "{{ .chezmoi.username }}"
email = "{{ $email }}"
name = "{{ $name }}"

[data.me.gravatar]
id = "{{ $gravatarID }}"

[data.me.github]
username = "{{ $githubUser }}"

# vi: ft=toml
2 changes: 1 addition & 1 deletion home/.chezmoiexternal.toml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
refreshPeriod = "168h"
stripComponents = 1

{{- if and (regexMatch "^gnome" .desktop_session) (lookPath "flatpak") }}
{{- if and (regexMatch "^gnome" .desktop.session) (lookPath "flatpak") }}

{{ end -}} # gnome .desktop_session && flatpak found

Expand Down
8 changes: 4 additions & 4 deletions home/.chezmoiignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.cache
.gsettings.yaml

{{- if not (regexMatch "^gnome" .desktop_session) }}
{{- if not (regexMatch "^gnome" .desktop.session) }}
### Ignore if not running gnome

# Chezmoi Scripts
Expand All @@ -23,14 +23,14 @@ src/github.com/paperwm*
.local/share/gnome-background-properties/*

###
{{- end}} # end .desktop_session = gnome
{{- end}} # end .desktop.session = gnome

{{- if not (regexMatch "niri" .desktop_session) }}
{{- if not (regexMatch "niri" .desktop.session) }}
.config/niri/config.kdl
.config/systemd/user/niri.service.wants/*
.config/systemd/user/swaybg.service
.local/share/applications/vivaldi-stable.desktop
{{- end}} # end .desktop_session = niri
{{- end}} # end .desktop.session = niri

# Gnome Wallpaper Config
{{ if not (stat (
Expand Down
2 changes: 1 addition & 1 deletion home/.chezmoiscripts/run_once_after_10_aqua.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if [[ ! $(command -v aqua) ]]; then
# ensure AQUA vars are set
function setenv() { export "$1=$2"; }

DOTS="${DOTS:={{ .dots }}}"
DOTS="${DOTS:={{ .home.dots }}}"
eval "$(grep -i AQUA <"${HOME}"/.setenv)"

pushd "$(mktemp -d)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ .dots }}/aqua/aqua-checksums.json
{{ .home.dots }}/aqua/aqua-checksums.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ .dots }}/aqua/aqua-policy.yaml
{{ .home.dots }}/aqua/aqua-policy.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ .dots }}/aqua/aqua-registry.yaml
{{ .home.dots }}/aqua/aqua-registry.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ .dots }}/aqua/aqua.yaml
{{ .home.dots }}/aqua/aqua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
function is_light --description "returns true if it is light (day) time"

set -l h (date +%k)
if test $h -le {{ .hour_light }}
or test $h -ge {{ .hour_dark }}
if test $h -le {{ .desktop.hour.light }}
or test $h -ge {{ .desktop.hour.dark }}
printf false
return 1
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ listener {
timeout = 180
on-timeout = niri msg action power-off-monitors
}
{{- if eq .host.chassis "laptop" }}

listener {
timeout = 5400 # 1.5hr
on-timeout = systemctl suspend
}
}{{ end }}
4 changes: 2 additions & 2 deletions home/private_dot_config/hypr/hyprlock.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source = $HOME/.config/hypr/themes/mocha.conf

$accent = $mauve
$accentAlpha = $mauveAlpha
$font = {{ .monospace_font }}
$font = {{ .desktop.fonts.monospace }}

general {
disable_loading_bar = true
Expand All @@ -11,7 +11,7 @@ general {

background {
monitor =
path = {{ .wallpaper }}
path = {{ .desktop.wallpaper }}
blur_passes = 2
color = $base
}
Expand Down
2 changes: 1 addition & 1 deletion home/private_dot_config/mako/config.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default-timeout=5000
font={{ .monospace_font }} 12
font={{ .desktop.fonts.monospace }} 12

# https://github.com/catppuccin/mako
background-color=#1e1e2e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,42 +50,13 @@ input {
// focus-follows-mouse max-scroll-amount="0%"
}

// You can configure outputs by their name, which you can find
// by running `niri msg outputs` while inside a niri instance.
// The built-in laptop monitor is usually called "eDP-1".
// Find more information on the wiki:
// https://github.com/YaLTeR/niri/wiki/Configuration:-Outputs
// Remember to uncomment the node by removing "/-"!
/-output "eDP-1" {
// Uncomment this line to disable this output.
// off

// Resolution and, optionally, refresh rate of the output.
// The format is "<width>x<height>" or "<width>x<height>@<refresh rate>".
// If the refresh rate is omitted, niri will pick the highest refresh rate
// for the resolution.
// If the mode is omitted altogether or is invalid, niri will pick one automatically.
// Run `niri msg outputs` while inside a niri instance to list all outputs and their modes.
mode "[email protected]"

// You can use integer or fractional scale, for example use 1.5 for 150% scale.
scale 2

// Transform allows to rotate the output counter-clockwise, valid values are:
// normal, 90, 180, 270, flipped, flipped-90, flipped-180 and flipped-270.
{{ if regexMatch "^zx1" .host.name -}}
output "DP-2" {
mode "[email protected]"
scale 1
transform "normal"

// Position of the output in the global coordinate space.
// This affects directional monitor actions like "focus-monitor-left", and cursor movement.
// The cursor can only move between directly adjacent outputs.
// Output scale and rotation has to be taken into account for positioning:
// outputs are sized in logical, or scaled, pixels.
// For example, a 3840×2160 output with scale 2.0 will have a logical size of 1920×1080,
// so to put another output directly adjacent to it on the right, set its x to 1920.
// If the position is unset or results in an overlap, the output is instead placed
// automatically.
position x=1280 y=0
}
{{- end }}

// Settings that influence how windows are positioned and sized.
// Find more information on the wiki:
Expand Down Expand Up @@ -487,6 +458,12 @@ binds {
// Mod+Space { switch-layout "next"; }
// Mod+Shift+Space { switch-layout "prev"; }

// One caveat is that currently rootful Xwayland doesn't seem to share
// clipboard with the compositor. For textual data you can do it manually
// using wl-clipboard. https://github.com/YaLTeR/niri/wiki/Xwayland
Mod+Shift+C { spawn "sh" "-c" "env DISPLAY=:0 xsel -ob | wl-copy"; }
Mod+Shift+V { spawn "sh" "-c" "wl-paste -n | env DISPLAY=:0 xsel -ib"; }

Print { screenshot; }
Ctrl+Print { screenshot-screen; }
Alt+Print { screenshot-window; }
Expand Down
2 changes: 1 addition & 1 deletion home/private_dot_config/nvim/lua/config/options.lua.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local opt = vim.opt
local time = os.date("*t")
local hr = time.hour

if hr >= {{ .hour_light }} and hr <= {{ .hour_dark }} then
if hr >= {{ .desktop.hour.light }} and hr <= {{ .desktop.hour.dark }} then
opt.background = "light"
end

Expand Down
2 changes: 1 addition & 1 deletion home/private_dot_config/nvim/symlink_lazy-lock.json.tmpl
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{ .chezmoi_home }}/private_dot_config/nvim/lazylock.json
{{ .home.chezmoi_home }}/private_dot_config/nvim/lazylock.json
2 changes: 1 addition & 1 deletion home/private_dot_config/systemd/user/swaybg.service.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ After=graphical-session.target
Requisite=graphical-session.target

[Service]
ExecStart=/usr/bin/swaybg -m fill -i "{{ .wallpaper }}"
ExecStart=/usr/bin/swaybg -m fill -i "{{ .desktop.wallpaper }}"
Restart=on-failure
18 changes: 1 addition & 17 deletions home/private_dot_config/wezterm/wezterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ if w.config_builder then
c = w.config_builder()
end

c.color_scheme = "Catppuccin Mocha"
c.default_cursor_style = "BlinkingBar"
c.default_prog = { "fish", "-l" }
c.font = w.font("FiraCode Nerd Font Mono")
Expand All @@ -19,21 +20,4 @@ c.window_decorations = "NONE"
c.window_background_opacity = 0.90
c.window_close_confirmation = "AlwaysPrompt"

local function get_appearance()
if w.gui then
return w.gui.get_appearance()
end
return "Dark"
end

local function scheme_for_appearance(appearance)
if appearance:find("Dark") then
return "Catppuccin Mocha"
else
return "Catppuccin Latte"
end
end

c.color_scheme = scheme_for_appearance(get_appearance())

return c
8 changes: 7 additions & 1 deletion home/private_dot_config/zellij/config.kdl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ simplified_ui false
theme "catppuccin-mocha"
{{ if eq .chezmoi.os "darwin" -}}
copy_command "pbcopy"
{{- else if eq .login_session_type "wayland" -}}
{{- else if eq .desktop.login.type "wayland" -}}
copy_command "wl-copy"
{{- else if eq .login_session_type "x11" -}}
copy_command "xclip -selection clipboard"
{{- end }}

ui {
pane_frames {
rounded_corners true
}
}

keybinds clear-defaults=true {
normal {
}
Expand Down

0 comments on commit 2c4ab03

Please sign in to comment.