-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·102 lines (87 loc) · 2.98 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# Ensure workflow-tools repository path exists
WORKFLOW_TOOLS_PATH="$HOME/workflow-tools"
SKETCHYBAR_CONFIG_PATH="$HOME/.config/sketchybar"
# Define the local timer data directory - outside of the repo structure
LOCAL_TIMER_DATA_DIR="$HOME/.local/share/sketchybar_timer_data"
LOCAL_TIMER_STATE_FILE="$LOCAL_TIMER_DATA_DIR/timer_state.json"
# Define T7 timer data directory
T7_TIMER_DIR="/Volumes/T7/Ableton Timer Data"
T7_TIMER_STATE_FILE="$T7_TIMER_DIR/timer_state.json"
# Create necessary directories
mkdir -p "$SKETCHYBAR_CONFIG_PATH"
mkdir -p "$LOCAL_TIMER_DATA_DIR"
# If T7 is connected, create the directory there too
if [ -d "/Volumes/T7" ]; then
mkdir -p "$T7_TIMER_DIR"
echo "Created T7 timer directory at $T7_TIMER_DIR"
fi
# Yabai configuration
mkdir -p ~/.config/yabai
ln -sf "$WORKFLOW_TOOLS_PATH/yabairc" ~/.config/yabai/yabairc
# Sketchybar configuration
rm -rf "$SKETCHYBAR_CONFIG_PATH"
ln -sf "$WORKFLOW_TOOLS_PATH/sketchybar" "$SKETCHYBAR_CONFIG_PATH"
# Initialize Yabai status file
if pgrep -q yabai; then
echo "running" > /tmp/yabai_status
echo "Initialized Yabai status as running"
else
echo "stopped" > /tmp/yabai_status
echo "Initialized Yabai status as stopped"
fi
# === Install Ableton Project Timer ===
echo "Installing Ableton project timer..."
# Function to determine which timer file to use
get_timer_file() {
if [ -d "/Volumes/T7" ]; then
# T7 is connected
if [ -f "$T7_TIMER_STATE_FILE" ] && [ -s "$T7_TIMER_STATE_FILE" ]; then
# T7 timer file exists and has content
echo "$T7_TIMER_STATE_FILE"
elif [ -f "$LOCAL_TIMER_STATE_FILE" ] && [ -s "$LOCAL_TIMER_STATE_FILE" ]; then
# Local file exists and has content, copy to T7
mkdir -p "$T7_TIMER_DIR"
cp "$LOCAL_TIMER_STATE_FILE" "$T7_TIMER_STATE_FILE"
echo "$T7_TIMER_STATE_FILE"
else
# Create new file on T7
mkdir -p "$T7_TIMER_DIR"
echo "$T7_TIMER_STATE_FILE"
fi
else
# T7 is not connected, use local file
echo "$LOCAL_TIMER_STATE_FILE"
fi
}
# Get the appropriate timer file to use
TIMER_FILE=$(get_timer_file)
echo "Using timer state file: $TIMER_FILE"
# Ensure the timer state file exists with a default structure
if [ ! -f "$TIMER_FILE" ]; then
echo '{
"running": false,
"current_project": "Untitled",
"projects": {
"Untitled": 0
}
}' > "$TIMER_FILE"
echo "Created new timer state file at $TIMER_FILE"
else
echo "Using existing timer state file at $TIMER_FILE"
fi
# Also maintain a local copy for when T7 is disconnected
if [ "$TIMER_FILE" = "$T7_TIMER_STATE_FILE" ] && [ ! -f "$LOCAL_TIMER_STATE_FILE" ]; then
cp "$T7_TIMER_STATE_FILE" "$LOCAL_TIMER_STATE_FILE"
echo "Created local backup copy of timer state"
fi
# Ensure other necessary timer data files exist
echo '{
"running": false,
"last_check_time": 0
}' > "$LOCAL_TIMER_DATA_DIR/last_ableton_state.json"
echo '{
"enabled": false,
"timestamp": 0
}' > "$LOCAL_TIMER_DATA_DIR/manual_override.json"
echo "Ableton project timer installed successfully"