diff --git a/matugen/files/config.toml b/matugen/files/config.toml index 36756ca..88d81d5 100644 --- a/matugen/files/config.toml +++ b/matugen/files/config.toml @@ -59,3 +59,8 @@ post_hook = 'nohup ~/.config/matugen/scripts/sync-nvim-mac.sh >/dev/null 2>&1 &' input_path = '~/.config/matugen/templates/pi-theme.json' output_path = '~/.pi/agent/themes/matugen.json.tmp' post_hook = 'cat ~/.pi/agent/themes/matugen.json.tmp > ~/.pi/agent/themes/matugen.json && nohup ~/.config/matugen/scripts/sync-pi-mac.sh >/dev/null 2>&1 &' + +[templates.wallpaper] +input_path = '~/.config/matugen/templates/wallpaper-path.txt' +output_path = '~/.cache/matugen-last-image' +post_hook = 'nohup ~/.config/matugen/scripts/sync-wallpaper-mac.sh >/dev/null 2>&1 &' diff --git a/matugen/files/scripts/sync-wallpaper-mac.sh b/matugen/files/scripts/sync-wallpaper-mac.sh new file mode 100755 index 0000000..cb73758 --- /dev/null +++ b/matugen/files/scripts/sync-wallpaper-mac.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env sh +set -eu + +log_file="$HOME/.cache/matugen-sync-wallpaper.log" + +mkdir -p "$HOME/.cache" + +{ + wallpaper_path="$(cat "$HOME/.cache/matugen-last-image")" + if [ -n "$wallpaper_path" ]; then + base_name="$(basename "$wallpaper_path")" + dest_path="$HOME/.cache/matugen-wallpapers/$base_name" + + mkdir -p "$HOME/.cache/matugen-wallpapers" + cp -f "$wallpaper_path" "$dest_path" + + ssh mac-attio "mkdir -p ~/.cache/matugen-wallpapers" + scp "$dest_path" "mac-attio:~/.cache/matugen-wallpapers/$base_name" + ssh mac-attio "osascript -e 'tell application \"System Events\" to tell every desktop to set picture to POSIX file \"~/.cache/matugen-wallpapers/$base_name\"'" + fi +} >>"$log_file" 2>&1 diff --git a/matugen/files/templates/wallpaper-path.txt b/matugen/files/templates/wallpaper-path.txt new file mode 100644 index 0000000..33b0c5b --- /dev/null +++ b/matugen/files/templates/wallpaper-path.txt @@ -0,0 +1 @@ +{{image}}