tangled
alpha
login
or
join now
tsiry-sandratraina.com
/
rockbox-zig
2
fork
atom
A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
2
fork
atom
overview
issues
pulls
pipelines
Add macOS LaunchAgent and postinstall script
tsiry-sandratraina.com
2 months ago
28c6d0f3
a7e9cf5d
+94
-1
3 changed files
expand all
collapse all
unified
split
cli
LaunchAgents
com.github.rockbox.plist
packaging
macos
build-pkg.sh
postinstall
+32
cli/LaunchAgents/com.github.rockbox.plist
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
<?xml version="1.0" encoding="UTF-8" ?>
2
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
3
+
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
4
+
<plist version="1.0">
5
+
<dict>
6
+
<key>Label</key>
7
+
<string>com.github.rockbox</string>
8
+
9
+
<key>ProgramArguments</key>
10
+
<array>
11
+
<string>/usr/local/bin/rockbox</string>
12
+
</array>
13
+
14
+
<key>RunAtLoad</key>
15
+
<true />
16
+
17
+
<key>KeepAlive</key>
18
+
<true />
19
+
20
+
<key>StandardOutPath</key>
21
+
<string>/tmp/rockbox.log</string>
22
+
23
+
<key>StandardErrorPath</key>
24
+
<string>/tmp/rockbox.err.log</string>
25
+
26
+
<key>EnvironmentVariables</key>
27
+
<dict>
28
+
<key>PATH</key>
29
+
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
30
+
</dict>
31
+
</dict>
32
+
</plist>
+4
-1
packaging/macos/build-pkg.sh
···
19
VERSION=$(git describe --tags --abbrev=0)
20
21
mkdir -p "$TMP/usr/local"/{bin,lib,share}
0
22
23
cp /usr/local/bin/rockbox* "$TMP/usr/local/bin"
24
cp -R /usr/local/lib/rockbox "$TMP/usr/local/lib"
25
cp -R /usr/local/share/rockbox "$TMP/usr/local/share"
0
26
27
pkgbuild \
28
--identifier "com.github.rockbox-zig" \
29
--version "$VERSION" \
30
--root "$TMP" \
0
31
--install-location "/" \
32
"rockbox-${VERSION}-${ARCH}.pkg"
33
34
-
rm -rf "$TMP"
···
19
VERSION=$(git describe --tags --abbrev=0)
20
21
mkdir -p "$TMP/usr/local"/{bin,lib,share}
22
+
mkdir -p "/tmp/scripts"
23
24
cp /usr/local/bin/rockbox* "$TMP/usr/local/bin"
25
cp -R /usr/local/lib/rockbox "$TMP/usr/local/lib"
26
cp -R /usr/local/share/rockbox "$TMP/usr/local/share"
27
+
cp ./packaging/macos/postinstall "/tmp/scripts"
28
29
pkgbuild \
30
--identifier "com.github.rockbox-zig" \
31
--version "$VERSION" \
32
--root "$TMP" \
33
+
--scripts "/tmp/scripts" \
34
--install-location "/" \
35
"rockbox-${VERSION}-${ARCH}.pkg"
36
37
+
rm -rf "$TMP" "/tmp/scripts"
+58
packaging/macos/postinstall
···
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
···
1
+
#!/bin/bash
2
+
set -euo pipefail
3
+
4
+
LABEL="com.github.rockbox"
5
+
BIN="/usr/local/bin/rockbox"
6
+
7
+
# Find the active console user (the one sitting at the Mac)
8
+
USER_NAME=$(stat -f "%Su" /dev/console)
9
+
if [[ "$USER_NAME" == "root" || -z "$USER_NAME" ]]; then
10
+
echo "No logged-in GUI user found; LaunchAgent will start at next login."
11
+
exit 0
12
+
fi
13
+
14
+
USER_UID=$(id -u "$USER_NAME")
15
+
USER_HOME=$(dscl . -read "/Users/$USER_NAME" NFSHomeDirectory | awk '{print $2}')
16
+
17
+
AGENTS_DIR="$USER_HOME/Library/LaunchAgents"
18
+
PLIST="$AGENTS_DIR/$LABEL.plist"
19
+
20
+
if [[ ! -x "$BIN" ]]; then
21
+
echo "Expected daemon binary not found or not executable: $BIN"
22
+
exit 1
23
+
fi
24
+
25
+
mkdir -p "$AGENTS_DIR"
26
+
27
+
cat > "$PLIST" <<EOF
28
+
<?xml version="1.0" encoding="UTF-8"?>
29
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
30
+
<plist version="1.0">
31
+
<dict>
32
+
<key>Label</key><string>$LABEL</string>
33
+
<key>ProgramArguments</key>
34
+
<array>
35
+
<string>$BIN</string>
36
+
</array>
37
+
<key>RunAtLoad</key><true/>
38
+
<key>KeepAlive</key><true/>
39
+
<key>StandardOutPath</key><string>/tmp/rockbox.log</string>
40
+
<key>StandardErrorPath</key><string>/tmp/rockbox.err.log</string>
41
+
<key>EnvironmentVariables</key>
42
+
<dict>
43
+
<key>PATH</key>
44
+
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
45
+
</dict>
46
+
</dict>
47
+
</plist>
48
+
EOF
49
+
50
+
chown "$USER_NAME" "$PLIST"
51
+
chmod 0644 "$PLIST"
52
+
53
+
# Reload + start
54
+
launchctl bootout "gui/$USER_UID" "$PLIST" 2>/dev/null || true
55
+
launchctl bootstrap "gui/$USER_UID" "$PLIST"
56
+
launchctl kickstart -k "gui/$USER_UID/$LABEL"
57
+
58
+
exit 0