clone of my dotfiles.ssp.sh
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

update

+81 -140
+81 -140
nvim-wp/micro-journal-scripts/Makefile
··· 1 - #!/bin/bash 2 - # Micro Journal Complete Sync Script 3 - # Handles network connection, time sync, and file synchronization 1 + # Makefile for Raspberry Pi Pico Typewriter Syncing 4 2 5 - set -e # Exit on error 3 + # Path definitions for Pi 4 + PI_WRITING_DIR = $(HOME)/microjournal/writing 5 + PI_NVIM_CONFIG_DIR = $(HOME)/config/nvim 6 + PI_CONFIG_DIR = $(HOME)/microjournal/config 7 + PI_SECONDBRAIN_DIR = $(HOME)/microjournal/SecondBrain 6 8 7 - # Path definitions 8 - # Pi paths 9 - PI_WRITING_DIR="$HOME/microjournal/writing" 10 - PI_CONFIG_DIR="$HOME/microjournal/config" #path to shell scripts and utilities 11 - PI_NVIM_CONFIG_DIR="$HOME/config/nvim" #wordprocessor config (Nvim) 12 - PI_SECONDBRAIN_DIR="$HOME/microjournal/SecondBrain" 9 + # Path definitions for Mac 10 + MAC_NVIM_CONFIG_GIT = $(HOME)/Documents/git/general/dotfiles/nvim-wp 11 + MAC_TYPEWRITER_CONFIG = $(HOME)/Documents/git/general/dotfiles/nvim-wp/micro-journal-scripts 12 + MAC_WRITING_DIR = $(HOME)/Simon/SecondBrain/⚛️\ Areas/✍🏻\ Writing/micro-journal 13 + MAC_SECONDBRAIN_DIR = $(HOME)/Simon/SecondBrain 13 14 14 - # Mac paths 15 - MAC_NVIM_CONFIG="$HOME/Documents/git/general/dotfiles/nvim-wp/" 16 - MAC_TYPEWRITER_CONFIG="$HOME/Documents/git/general/dotfiles/nvim-wp/micro-journal-scripts" 17 - MAC_WRITING_DIR="$HOME/Simon/SecondBrain/⚛️ Areas/✍🏻 Writing/micro-journal" 18 - MAC_SECONDBRAIN_DIR="$HOME/Simon/SecondBrain" 15 + # Default target 16 + .PHONY: help 17 + help: 18 + @echo "Typewriter Sync Makefile" 19 + @echo "========================" 20 + @echo "Available targets:" 21 + @echo " to-mac : Sync writing from Pi to Mac" 22 + @echo " from-mac : Sync configs and SecondBrain from Mac to Pi" 23 + @echo " sync-all : Run both to-mac and from-mac syncs" 24 + @echo " install : Install required packages from wp-packages.txt" 25 + @echo " network-on : Start network connection" 26 + @echo " network-off : Stop network connection" 27 + @echo " time-sync : Synchronize system time" 28 + @echo " help : Show this help information" 19 29 20 - # Determine if we're running on the Pi or Mac 21 - if [[ "$(uname)" == "Darwin" ]]; then 22 - IS_MAC=true 23 - echo "Running on MacBook" 24 - else 25 - IS_MAC=false 26 - echo "Running on Raspberry Pi" 27 - fi 30 + # Network management 31 + .PHONY: network-on 32 + network-on: 33 + @echo "Starting network connection..." 34 + @./startnetwork.sh 35 + @echo "Waiting for network connection..." 36 + @for i in $$(seq 1 15); do \ 37 + if ping -c 1 google.com > /dev/null 2>&1; then \ 38 + echo "Network is ready."; \ 39 + break; \ 40 + fi; \ 41 + if [ $$i -eq 15 ]; then \ 42 + echo "WARNING: Network may not be fully ready, but continuing..."; \ 43 + fi; \ 44 + sleep 1; \ 45 + done 28 46 29 - # Function to start network on Pi 30 - start_network() { 31 - if [ "$IS_MAC" = false ]; then 32 - echo "Starting network connection..." 33 - ./startnetwork.sh 34 - # Wait for network to be ready 35 - echo "Waiting for network connection..." 36 - for i in {1..15}; do 37 - if ping -c 1 google.com &> /dev/null; then 38 - echo "Network is ready." 39 - return 0 40 - fi 41 - sleep 1 42 - done 43 - echo "WARNING: Network may not be fully ready, but continuing..." 44 - else 45 - echo "Network management skipped on MacBook." 46 - fi 47 - } 47 + .PHONY: network-off 48 + network-off: 49 + @echo "Stopping network connection..." 50 + @./stopnetwork.sh 48 51 49 - # Function to sync time on Pi 50 - sync_time() { 51 - if [ "$IS_MAC" = false ]; then 52 - echo "Synchronizing system time..." 53 - sudo ./time.sh 54 - else 55 - echo "Time synchronization skipped on MacBook." 56 - fi 57 - } 52 + # Time synchronization 53 + .PHONY: time-sync 54 + time-sync: network-on 55 + @echo "Synchronizing system time..." 56 + @sudo ./time.sh 58 57 59 - # Function to stop network on Pi 60 - stop_network() { 61 - if [ "$IS_MAC" = false ]; then 62 - echo "Stopping network connection..." 63 - ./stopnetwork.sh 64 - else 65 - echo "Network management skipped on MacBook." 66 - fi 67 - } 68 - 69 - # Function to sync writing files from Pi to Mac 70 - sync_writing_to_mac() { 71 - if [ "$IS_MAC" = true ]; then 72 - # Running on Mac, so we're pulling from Pi 73 - echo "ERROR: This script should be run on the Pi when syncing to Mac." 74 - exit 1 75 - else 76 - echo "Syncing writing files from Pi to Mac..." 77 - rsync -avz --delete "$PI_WRITING_DIR/" "$MAC_WRITING_DIR/" 78 - echo "Writing files sync completed!" 79 - fi 80 - } 58 + # Sync from Pi to Mac 59 + .PHONY: to-mac 60 + to-mac: network-on time-sync 61 + @echo "=== Starting Pi to Mac sync process ===" 62 + @echo "Syncing writing files - writing..." 63 + @rsync -avz --delete "$(PI_WRITING_DIR)/" "$(MAC_WRITING_DIR)/" 64 + @echo "Syncing nvim-wp files..." 65 + @rsync -avz --delete "$(PI_NVIM_CONFIG_DIR)/" "$(MAC_NVIM_CONFIG_GIT)/" 66 + @echo "Writing files sync completed!" 67 + @make -s network-off 68 + @echo "=== Pi to Mac sync process completed successfully! ===" 81 69 82 - # Function to sync Neovim config from Mac to Pi 83 - sync_nvim_config() { 84 - if [ "$IS_MAC" = true ]; then 85 - # Running on Mac, so we're pushing to Pi 86 - echo "ERROR: This script should be run on the Pi when syncing Neovim config." 87 - exit 1 88 - else 89 - echo "Syncing Neovim config from Mac to Pi..." 90 - rsync -avz "$MAC_NVIM_CONFIG/" "$PI_NVIM_CONFIG_DIR/" 91 - echo "Neovim config sync completed!" 92 - fi 93 - } 94 - 95 - # Function to sync typewriter utility scripts from Mac to Pi 96 - sync_typewriter_config() { 97 - if [ "$IS_MAC" = true ]; then 98 - # Running on Mac, so we're pushing to Pi 99 - echo "ERROR: This script should be run on the Pi when syncing typewriter configs." 100 - exit 1 101 - else 102 - echo "Syncing typewriter utility scripts from Mac to Pi..." 103 - rsync -avz "$MAC_TYPEWRITER_CONFIG/" "$PI_CONFIG_DIR/" 104 - echo "Typewriter utility scripts sync completed!" 105 - fi 106 - } 107 - 108 - # Function to sync SecondBrain from Mac to Pi 109 - sync_secondbrain_from_mac() { 110 - if [ "$IS_MAC" = true ]; then 111 - # Running on Mac, so we're pushing to Pi 112 - echo "ERROR: This script should be run on the Pi when syncing SecondBrain." 113 - exit 1 114 - else 115 - echo "Syncing SecondBrain from Mac to Pi..." 116 - rsync -avz "$MAC_SECONDBRAIN_DIR/" "$PI_SECONDBRAIN_DIR/" 117 - echo "SecondBrain sync completed!" 118 - fi 119 - } 70 + # Sync from Mac to Pi 71 + .PHONY: from-mac 72 + from-mac: network-on time-sync 73 + @echo "=== Starting Mac to Pi sync process ===" 74 + 75 + @echo "Syncing SecondBrain contents..." 76 + @rsync -avz "$(MAC_SECONDBRAIN_DIR)/" "$(PI_SECONDBRAIN_DIR)/" 77 + @echo "SecondBrain contents sync completed!" 78 + 79 + @make -s network-off 80 + @echo "=== Mac to Pi sync process completed successfully! ===" 120 81 121 - # Main function to run everything in sequence 122 - main() { 123 - echo "Starting Micro Journal sync process..." 124 - 125 - # 1. Open network 126 - start_network 127 - 128 - # 2. Sync time 129 - sync_time 130 - 131 - # 3. Sync writing from Pi to Mac 132 - sync_writing_to_mac 133 - 134 - # 4. Sync Neovim config from Mac to Pi 135 - sync_nvim_config 136 - 137 - # 5. Sync typewriter utility scripts from Mac to Pi 138 - sync_typewriter_config 139 - 140 - # 6. Sync SecondBrain from Mac to Pi 141 - sync_secondbrain_from_mac 142 - 143 - # 7. Close network 144 - stop_network 145 - 146 - echo "Micro Journal sync process completed successfully!" 147 - } 82 + # Complete sync in both directions 83 + .PHONY: sync-all 84 + sync-all: network-on time-sync to-mac from-mac network-off 148 85 149 - # Run the main function 150 - main 86 + # Install packages 87 + .PHONY: install 88 + install: 89 + @echo "Installing required packages..." 90 + @cd install && ./install-wp.sh 91 + @echo "Installation complete!"