From 02e5b9472b7523848ab937ce335eb73181b73f71 Mon Sep 17 00:00:00 2001 From: Scott Ames Date: Sat, 16 Nov 2024 14:34:55 -0800 Subject: [PATCH] feat(chezmoi): get wallpaper from init input --- .github/workflows/pr_chezmoi_init.yaml | 8 ++++++-- home/.chezmoi.toml.tmpl | 13 +++++++------ home/dot_wallpaper.tmpl | 1 + 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 home/dot_wallpaper.tmpl diff --git a/.github/workflows/pr_chezmoi_init.yaml b/.github/workflows/pr_chezmoi_init.yaml index c1246c49..9cf9c07f 100644 --- a/.github/workflows/pr_chezmoi_init.yaml +++ b/.github/workflows/pr_chezmoi_init.yaml @@ -20,14 +20,18 @@ jobs: - name: Extract branch name shell: bash run: | - echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" \ + >> "${GITHUB_OUTPUT}" id: extract_branch - name: Run chezmoi init in container + # yamllint disable-line rule:line-length uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 # v3 with: # https://github.com/scottames/boxes image: ghcr.io/scottames/fedora-toolbox:latest + # yamllint disable-line rule:line-length options: -v ${{ github.workspace }}:/home/container/src/github.com/scottames/dots/main run: | /home/container/src/github.com/scottames/dots/main/scripts/init.sh \ - --no-tty --branch "${{ steps.extract_branch.outputs.branch }}" + --no-tty --branch "${{ steps.extract_branch.outputs.branch }}" \ + --promptDefaults diff --git a/home/.chezmoi.toml.tmpl b/home/.chezmoi.toml.tmpl index 1ebaaeb9..73a430eb 100644 --- a/home/.chezmoi.toml.tmpl +++ b/home/.chezmoi.toml.tmpl @@ -22,6 +22,7 @@ {{- $osVersion := "" -}} {{- $ublueImageInfo := "" -}} {{- $useGitWorktrees := true -}} +{{- $wallpaper := "" -}} {{- if $useGitWorktrees -}} {{- $dotsStr = printf "%s/main" $dotsStr -}} @@ -101,13 +102,13 @@ output "sh" "-c" "printf 'scott@ames.sh' | md5sum - | cut -d' ' -f1" {{- $srcDir := printf "%s/src" .chezmoi.homeDir -}} {{- $srcGitHubDir := printf "%s/github.com/%s" $srcDir $githubUser -}} {{- $dots := printf "%s/%s" $srcGitHubDir $dotsStr -}} -{{- /* TODO: get from user input */ -}} -{{- - $wallpaper := printf - "%s/walls/main/wide/foggy-peaks-valley_catppuccin-oled_16_GaussianV1_0_20_512.png" - $srcGitHubDir - -}} {{- $chezmoiSourceDir := printf "%s/home" $dots -}} +{{- if lstat (joinPath .chezmoi.homeDir ".wallpaper") -}} +{{- $wallpaper = trim (include (printf "%s/.wallpaper" .chezmoi.homeDir)) -}} +{{- else -}} +{{- $wallpaperDefault := "/usr/share/backgrounds/gnome/adwaita-d.jxl" -}} +{{- $wallpaper = promptStringOnce . "desktop.wallpaper" "path to desktop wallpaper" $wallpaperDefault -}} +{{- end -}} sourceDir = "{{ $chezmoiSourceDir }}" progress = true diff --git a/home/dot_wallpaper.tmpl b/home/dot_wallpaper.tmpl new file mode 100644 index 00000000..a612171b --- /dev/null +++ b/home/dot_wallpaper.tmpl @@ -0,0 +1 @@ +{{ .desktop.wallpaper }}