summarylogtreecommitdiffstats
path: root/librepods-git.install
blob: 095a749ef5a83cd01128d23e1146e4de58cf7b22 (plain)
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
post_install() {
    echo "    Set the PHONE_MAC_ADDRESS environment variable to your AirPods'"
    echo "    Bluetooth MAC address using 'export' (bash) or 'set -gx' (fish)."
    echo ""
    echo "    Make sure that your device is already paired before running"
    echo "    Librepods, as it causes issues with pairing during runtime."

    mkdir -p "$HOME/.config/wireplumber/wireplumber.conf.d"

    cd "$HOME/.config/wireplumber/wireplumber.conf.d" || return

    if [ ! -f "51-bluez-avrcp.conf" ]; then
        cat >"51-bluez-avrcp.conf" <<EOF
monitor.bluez.properties = {
  # Enable dummy AVRCP player for proper media control support
  # This is required for AirPods and other devices to send play/pause/skip commands
  bluez5.dummy-avrcp-player = true
}
EOF
        systemctl --user restart wireplumber
    fi
}

post_upgrade() {
    # fix missing avrcp field for existing installs
    local conf_file="$HOME/.config/wireplumber/wireplumber.conf.d/51-bluez-avrcp.conf"
    if [ -f "$conf_file" ] && ! grep -q "bluez5.dummy-avrcp-player" "$conf_file"; then
        echo "    Updating 51-bluez-avrcp.conf to include missing avrcp field..."
        sed -i '/monitor.bluez.properties = {/a \  bluez5.dummy-avrcp-player = true' "$conf_file"
        systemctl --user restart wireplumber
    fi
}