-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.command
More file actions
47 lines (41 loc) · 2.23 KB
/
Copy pathinstall.command
File metadata and controls
47 lines (41 loc) · 2.23 KB
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
#!/bin/bash
set -euo pipefail
APP_DIR="$HOME/Applications/PyXClock"
SOURCE_DIR="$(cd "$(dirname "$0")" && pwd)"
LABEL="com.page.pyxclock"
AGENT="$HOME/Library/LaunchAgents/$LABEL.plist"
PYTHON=""
for candidate in /opt/local/bin/python3.14 /opt/local/bin/python3.13 /opt/local/bin/python3.12 /opt/local/bin/python3.11 /usr/local/bin/python3 /opt/homebrew/bin/python3 /usr/bin/python3; do
if [[ -x "$candidate" ]] && "$candidate" -c 'import tkinter' >/dev/null 2>&1; then
PYTHON="$candidate"
break
fi
done
if [[ -z "$PYTHON" ]]; then
echo "Aucun Python avec tkinter n’a été trouvé."
echo "Avec MacPorts et Python 3.14 : sudo port install python314 py314-tkinter"
read -r -p "Appuie sur Entrée pour fermer."
exit 1
fi
mkdir -p "$APP_DIR" "$HOME/Library/LaunchAgents" "$HOME/Library/Logs"
cp "$SOURCE_DIR/pyxclock.py" "$SOURCE_DIR/display_profiles.py" "$APP_DIR/"
cp "$SOURCE_DIR/python-launcher" "$APP_DIR/"
chmod 755 "$APP_DIR/pyxclock.py" "$APP_DIR/python-launcher"
printf '%s\n' "$PYTHON" > "$APP_DIR/.python-path"
launchctl bootout "gui/$UID/$LABEL" 2>/dev/null || true
plutil -create xml1 "$AGENT"
plutil -insert Label -string "$LABEL" "$AGENT"
plutil -insert ProgramArguments -xml "<array><string>$APP_DIR/python-launcher</string><string>$APP_DIR/pyxclock.py</string><string>-geometry</string><string>150x150+1640+2</string><string>-analog</string><string>-hd</string><string>yellow</string><string>-hl</string><string>yellow</string><string>-fg</string><string>yellow</string><string>-bg</string><string>black</string><string>-update</string><string>1</string><string>-norender</string></array>" "$AGENT"
plutil -insert RunAtLoad -bool true "$AGENT"
plutil -insert KeepAlive -bool false "$AGENT"
plutil -insert ProcessType -string Interactive "$AGENT"
plutil -insert StandardOutPath -string "$HOME/Library/Logs/PyXClock.log" "$AGENT"
plutil -insert StandardErrorPath -string "$HOME/Library/Logs/PyXClock.log" "$AGENT"
plutil -lint "$AGENT"
launchctl bootstrap "gui/$UID" "$AGENT"
launchctl kickstart -k "gui/$UID/$LABEL"
echo
echo "PyXClock est installé et démarrera à chaque login."
echo "Python utilisé : $PYTHON"
echo "Pour le retirer, double-clique sur uninstall.command."
read -r -p "Appuie sur Entrée pour fermer."