From d0b1d3be4ab4348f3ec1061adea4b800a5c83e42 Mon Sep 17 00:00:00 2001 From: "Thomas G. Lopes" Date: Fri, 13 Mar 2026 18:04:32 +0000 Subject: [PATCH] sync mac scripts --- matugen/files/config.toml | 16 ++-- matugen/files/scripts/sync-mac.sh | 88 +++++++++++++++++++++ matugen/files/scripts/sync-nvim-mac.sh | 12 --- matugen/files/scripts/sync-pi-mac.sh | 13 --- matugen/files/scripts/sync-tmux-mac.sh | 13 --- matugen/files/scripts/sync-wallpaper-mac.sh | 21 ----- matugen/files/scripts/sync-zellij-mac.sh | 13 --- ssh/files/config | 1 + 8 files changed, 99 insertions(+), 78 deletions(-) create mode 100755 matugen/files/scripts/sync-mac.sh delete mode 100755 matugen/files/scripts/sync-nvim-mac.sh delete mode 100755 matugen/files/scripts/sync-pi-mac.sh delete mode 100755 matugen/files/scripts/sync-tmux-mac.sh delete mode 100755 matugen/files/scripts/sync-wallpaper-mac.sh delete mode 100755 matugen/files/scripts/sync-zellij-mac.sh diff --git a/matugen/files/config.toml b/matugen/files/config.toml index 92e2f1b..636d9bf 100644 --- a/matugen/files/config.toml +++ b/matugen/files/config.toml @@ -3,11 +3,12 @@ [templates.ghostty] input_path = '~/.config/matugen/templates/ghostty-theme' output_path = '~/.config/ghostty/themes/matugen' -post_hook = 'pkill -SIGUSR2 ghostty' +post_hook = "pkill -SIGUSR2 ghostty || true && nohup ~/.config/matugen/scripts/sync-mac.sh file ~/.config/ghostty/themes/matugen ~/.config/ghostty/themes/matugen --remote-cmd 'pkill -SIGUSR2 ghostty || true' >/dev/null 2>&1 &" [templates.kitty] input_path = '~/.config/matugen/templates/kitty-colors.conf' output_path = '~/.config/kitty/colors.conf' +post_hook = "nohup ~/.config/matugen/scripts/sync-mac.sh file ~/.config/kitty/colors.conf ~/.config/kitty/colors.conf >/dev/null 2>&1 &" [templates.foot] input_path = '~/.config/matugen/templates/foot-theme' @@ -24,10 +25,12 @@ output_path = '~/.config/gtk-4.0/colors.css' [templates.fish-prompt] input_path = '~/.config/matugen/templates/fish-prompt-colors.fish' output_path = '~/.config/fish/conf.d/prompt-colors.fish' +post_hook = "nohup ~/.config/matugen/scripts/sync-mac.sh file ~/.config/fish/conf.d/prompt-colors.fish ~/.config/fish/conf.d/prompt-colors.fish >/dev/null 2>&1 &" [templates.yazi] input_path = '~/.config/matugen/templates/yazi-theme.toml' output_path = '~/.config/yazi/theme.toml' +post_hook = "nohup ~/.config/matugen/scripts/sync-mac.sh file ~/.config/yazi/theme.toml ~/.config/yazi/theme.toml >/dev/null 2>&1 &" [templates.qt5ct] input_path = '~/.config/matugen/templates/qtct-colors.conf' @@ -44,28 +47,29 @@ output_path = '~/.config/niri/colors.kdl' [templates.tmux] input_path = '~/.config/matugen/templates/tmux-colors.conf' output_path = '~/.config/tmux/colors.conf' -post_hook = 'tmux source-file ~/.config/tmux/tmux.conf 2>/dev/null || true && nohup ~/.config/matugen/scripts/sync-tmux-mac.sh >/dev/null 2>&1 &' +post_hook = "tmux source-file ~/.config/tmux/tmux.conf 2>/dev/null || true && nohup ~/.config/matugen/scripts/sync-mac.sh file ~/.config/tmux/colors.conf ~/.config/tmux/colors.conf --remote-cmd 'export PATH=\"/opt/homebrew/bin:/usr/local/bin:$PATH\" && tmux source-file ~/.config/tmux/tmux.conf 2>/dev/null || true' >/dev/null 2>&1 &" [templates.zellij] input_path = '~/.config/matugen/templates/zellij-colors.kdl' output_path = '~/.config/zellij/themes/matugen.kdl' -post_hook = 'touch ~/.config/zellij/config.kdl && nohup ~/.config/matugen/scripts/sync-zellij-mac.sh >/dev/null 2>&1 &' +post_hook = "touch ~/.config/zellij/config.kdl && nohup ~/.config/matugen/scripts/sync-mac.sh file ~/.config/zellij/themes/matugen.kdl ~/.config/zellij/themes/matugen.kdl --remote-cmd 'touch ~/.config/zellij/config.kdl' >/dev/null 2>&1 &" [templates.jjui] input_path = '~/.config/matugen/templates/jjui-theme.toml' output_path = '~/.config/jjui/themes/matugen.toml' +post_hook = "nohup ~/.config/matugen/scripts/sync-mac.sh file ~/.config/jjui/themes/matugen.toml ~/.config/jjui/themes/matugen.toml >/dev/null 2>&1 &" [templates.nvim] input_path = '~/.config/matugen/templates/neovim.lua' output_path = '~/.config/nvim/lua/plugins/dankcolors.lua' -post_hook = 'nohup ~/.config/matugen/scripts/sync-nvim-mac.sh >/dev/null 2>&1 &' +post_hook = "nohup ~/.config/matugen/scripts/sync-mac.sh file ~/.config/nvim/lua/plugins/dankcolors.lua ~/.config/nvim/lua/plugins/dankcolors.lua >/dev/null 2>&1 &" [templates.pi] 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 &' +post_hook = "cat ~/.pi/agent/themes/matugen.json.tmp > ~/.pi/agent/themes/matugen.json && nohup ~/.config/matugen/scripts/sync-mac.sh file ~/.pi/agent/themes/matugen.json ~/.pi/agent/themes/matugen.json >/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 &' +post_hook = "nohup ~/.config/matugen/scripts/sync-mac.sh wallpaper ~/.cache/matugen-last-image >/dev/null 2>&1 &" diff --git a/matugen/files/scripts/sync-mac.sh b/matugen/files/scripts/sync-mac.sh new file mode 100755 index 0000000..d0f706b --- /dev/null +++ b/matugen/files/scripts/sync-mac.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env sh +set -eu + +host="${MATUGEN_SYNC_HOST:-mac-attio}" +log_file="$HOME/.cache/matugen-sync-mac.log" + +mkdir -p "$HOME/.cache" + +usage() { + echo "usage:" >&2 + echo " sync-mac.sh file [--remote-cmd ]" >&2 + echo " sync-mac.sh wallpaper " >&2 + exit 1 +} + +sync_file() { + source_path="$1" + remote_path="$2" + remote_cmd="${3-}" + + remote_dir="$(dirname "$remote_path")" + remote_tmp="${remote_path}.tmp" + + ssh "$host" "mkdir -p $remote_dir" + scp "$source_path" "$host:$remote_tmp" + ssh "$host" "mv $remote_tmp $remote_path" + + if [ -n "$remote_cmd" ]; then + ssh "$host" "$remote_cmd" + fi +} + +sync_wallpaper() { + wallpaper_path_file="$1" + + [ -f "$wallpaper_path_file" ] || exit 0 + + wallpaper_path="$(cat "$wallpaper_path_file")" + [ -n "$wallpaper_path" ] || exit 0 + [ -f "$wallpaper_path" ] || exit 0 + + base_name="$(basename "$wallpaper_path")" + local_cache_dir="$HOME/.cache/matugen-wallpapers" + local_copy="$local_cache_dir/$base_name" + + mkdir -p "$local_cache_dir" + cp -f "$wallpaper_path" "$local_copy" + + ssh "$host" "mkdir -p ~/.cache/matugen-wallpapers" + scp "$local_copy" "$host:~/.cache/matugen-wallpapers/$base_name" + ssh "$host" "osascript -e 'tell application \"System Events\" to tell every desktop to set picture to POSIX file \"~/.cache/matugen-wallpapers/$base_name\"'" +} + +mode="${1-}" +[ -n "$mode" ] || usage +shift + +{ + echo "[$(date '+%Y-%m-%d %H:%M:%S')] mode=$mode" + + case "$mode" in + file) + [ "$#" -ge 2 ] || usage + source_path="$1" + remote_path="$2" + shift 2 + + remote_cmd="" + if [ "${1-}" = "--remote-cmd" ]; then + [ "$#" -eq 2 ] || usage + remote_cmd="$2" + elif [ "$#" -ne 0 ]; then + usage + fi + + sync_file "$source_path" "$remote_path" "$remote_cmd" + ;; + + wallpaper) + [ "$#" -eq 1 ] || usage + sync_wallpaper "$1" + ;; + + *) + usage + ;; + esac +} >>"$log_file" 2>&1 diff --git a/matugen/files/scripts/sync-nvim-mac.sh b/matugen/files/scripts/sync-nvim-mac.sh deleted file mode 100755 index 65691e6..0000000 --- a/matugen/files/scripts/sync-nvim-mac.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env sh -set -eu - -log_file="$HOME/.cache/matugen-sync-nvim.log" - -mkdir -p "$HOME/.cache" - -{ - ssh mac-attio "mkdir -p ~/.config/nvim/lua/plugins" - scp "$HOME/.config/nvim/lua/plugins/dankcolors.lua" \ - mac-attio:~/.config/nvim/lua/plugins/ -} >>"$log_file" 2>&1 diff --git a/matugen/files/scripts/sync-pi-mac.sh b/matugen/files/scripts/sync-pi-mac.sh deleted file mode 100755 index 359d1c1..0000000 --- a/matugen/files/scripts/sync-pi-mac.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env sh -set -eu - -log_file="$HOME/.cache/matugen-sync-pi.log" - -mkdir -p "$HOME/.cache" - -{ - ssh mac-attio "mkdir -p ~/.pi/agent/themes" - scp "$HOME/.pi/agent/themes/matugen.json" \ - mac-attio:~/.pi/agent/themes/matugen.json.tmp - ssh mac-attio "mv ~/.pi/agent/themes/matugen.json.tmp ~/.pi/agent/themes/matugen.json" -} >>"$log_file" 2>&1 diff --git a/matugen/files/scripts/sync-tmux-mac.sh b/matugen/files/scripts/sync-tmux-mac.sh deleted file mode 100755 index 8db44c3..0000000 --- a/matugen/files/scripts/sync-tmux-mac.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env sh -set -eu - -log_file="$HOME/.cache/matugen-sync-tmux.log" - -mkdir -p "$HOME/.cache" - -{ - ssh mac-attio "mkdir -p ~/.config/tmux" - scp "$HOME/.config/tmux/colors.conf" \ - mac-attio:~/.config/tmux/ - ssh mac-attio 'export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH" && tmux source-file ~/.config/tmux/tmux.conf 2>/dev/null || true' -} >>"$log_file" 2>&1 diff --git a/matugen/files/scripts/sync-wallpaper-mac.sh b/matugen/files/scripts/sync-wallpaper-mac.sh deleted file mode 100755 index cb73758..0000000 --- a/matugen/files/scripts/sync-wallpaper-mac.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/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/scripts/sync-zellij-mac.sh b/matugen/files/scripts/sync-zellij-mac.sh deleted file mode 100755 index d2225df..0000000 --- a/matugen/files/scripts/sync-zellij-mac.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env sh -set -eu - -log_file="$HOME/.cache/matugen-sync-zellij.log" - -mkdir -p "$HOME/.cache" - -{ - ssh mac-attio "mkdir -p ~/.config/zellij/themes" - scp "$HOME/.config/zellij/themes/matugen.kdl" \ - mac-attio:~/.config/zellij/themes/ - ssh mac-attio "touch ~/.config/zellij/config.kdl" -} >>"$log_file" 2>&1 diff --git a/ssh/files/config b/ssh/files/config index 978ec59..16dc08d 100644 --- a/ssh/files/config +++ b/ssh/files/config @@ -52,6 +52,7 @@ Host mac mac-attio LocalForward 8082 localhost:8082 LocalForward 54043 localhost:54043 IdentitiesOnly yes + SetEnv TERM=xterm-256color Host linux-pc 192.168.1.80 HostName 192.168.1.80