clone of my dotfiles.ssp.sh
1# Makefile for Raspberry Pi Pico Typewriter Syncing
2
3# Path definitions for Pi
4PI_WRITING_DIR = $(HOME)/microjournal/writing
5PI_NVIM_CONFIG_DIR = $(HOME)/config/nvim
6PI_CONFIG_DIR = $(HOME)/microjournal/config
7PI_SECONDBRAIN_DIR = ~/microjournal/documents/SecondBrain
8
9# Mac connection details
10MAC_USER = your_mac_username
11MAC_HOST = your_mac_hostname_or_ip
12PI_USER = microjournal
13PI_HOST = mj
14# Path definitions for Mac (remote)
15MAC_NVIM_CONFIG_GIT = $(MAC_USER)@$(MAC_HOST):$(HOME)/Documents/git/general/dotfiles/nvim-wp
16MAC_TYPEWRITER_CONFIG = $(MAC_USER)@$(MAC_HOST):$(HOME)/Documents/git/general/dotfiles/nvim-wp/micro-journal-scripts
17MAC_WRITING_DIR = $(MAC_USER)@$(MAC_HOST):$(HOME)/Simon/SecondBrain/⚛️\ Areas/✍🏻\ Writing/micro-journal
18MAC_SECONDBRAIN_DIR = ~/Simon/SecondBrain
19
20# Default target
21.PHONY: help
22help:
23 @echo "Typewriter Sync Makefile"
24 @echo "========================"
25 @echo "Available targets:"
26 @echo " to-mac : Sync writing from Pi to Mac"
27 @echo " from-mac : Sync configs and SecondBrain from Mac to Pi"
28 @echo " sync-all : Run both to-mac and from-mac syncs"
29 @echo " install : Install required packages from wp-packages.txt"
30 @echo " network-on : Start network connection"
31 @echo " network-off : Stop network connection"
32 @echo " time-sync : Synchronize system time"
33 @echo " help : Show this help information"
34
35# Network management
36# .PHONY: network-on
37# network-on:
38# @echo "Starting network connection..."
39# @./startnetwork.sh
40# @echo "Waiting for network connection..."
41# @for i in $$(seq 1 15); do \
42# if ping -c 1 google.com > /dev/null 2>&1; then \
43# echo "Network is ready."; \
44# break; \
45# fi; \
46# if [ $$i -eq 15 ]; then \
47# echo "WARNING: Network may not be fully ready, but continuing..."; \
48# fi; \
49# sleep 1; \
50# done
51
52# .PHONY: network-off
53# network-off:
54# @echo "Stopping network connection..."
55# @./stopnetwork.sh
56
57# Time synchronization
58.PHONY: time-sync
59time-sync: network-on
60 @echo "Synchronizing system time..."
61 @sudo ./time.sh
62
63# Sync from Pi to Mac
64# .PHONY: to-mac
65# to-mac: network-on time-sync
66# @echo "=== Starting Pi to Mac sync process ==="
67# @echo "Syncing writing files - writing..."
68# @rsync -avz --delete "$(PI_WRITING_DIR)/" "$(MAC_WRITING_DIR)/"
69# @echo "Syncing nvim-wp files..."
70# @rsync -avz --delete "$(PI_NVIM_CONFIG_DIR)/" "$(MAC_NVIM_CONFIG_GIT)/"
71# @echo "Writing files sync completed!"
72# @make -s network-off
73# @echo "=== Pi to Mac sync process completed successfully! ==="
74
75# Sync from Mac to Pi
76
77.PHONY: sync-secondbrain-to-mj
78sync-secondbrain-to-mj:
79 @echo "=== Starting Mac to Pi sync process ==="
80
81 @echo "Syncing SecondBrain contents..."
82 @rsync -avz --delete --include="*.md" --include="*.txt" --include="*/" --exclude="*" $(MAC_SECONDBRAIN_DIR)/ mj:$(PI_SECONDBRAIN_DIR)/
83 @echo "SecondBrain contents sync completed!"
84
85 @echo "Creating last-loaded.md file with timestamp..."
86 @ssh mj "echo '$$(date)' > $(PI_SECONDBRAIN_DIR)/last-loaded.md"
87 @echo "Timestamp file created!"
88
89 @echo "=== Mac to Pi sync process completed successfully! ==="
90
91# Complete sync in both directions
92.PHONY: sync-all
93sync-all: network-on time-sync to-mac from-mac network-off
94
95# Install packages
96.PHONY: install
97install:
98 @echo "Installing required packages..."
99 @cd install && ./install-wp.sh
100 @echo "Installation complete!"