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