#!/usr/bin/env bash
# Media-key wrapper for XF86AudioPlay / XF86AudioPause.
# If the music player is running it gets the key; otherwise the key is passed
# on to whichever MPRIS player is active, via playerctl when installed.
export PATH="$HOME/.local/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
music="$(dirname "$(readlink -f "$0")")/music"
if "$music" now >/dev/null 2>&1; then
    exec "$music" toggle
fi
command -v playerctl >/dev/null && exec playerctl play-pause
exit 0
