fedora – run bash script when headphones are connected

I tried searching everywhere for this but couldn’t find anything…

I need to run a bash script when my bluetooth headphones are connected.

I use Fedora 40 KDE (pipewire)

KERNEL[1828.123035] add      /devices/pci0000:00/0000:00:1b.2/0000:02:00.0/usb3/3-1/3-1:1.0/bluetooth/hci0/hci0:3 (bluetooth)
UDEV  [1828.129031] add      /devices/pci0000:00/0000:00:1b.2/0000:02:00.0/usb3/3-1/3-1:1.0/bluetooth/hci0/hci0:3 (bluetooth)
KERNEL[1829.045300] add      /devices/virtual/input/input35 (input)
KERNEL[1829.045449] add      /devices/virtual/input/input35/event24 (input)
UDEV  [1829.047715] add      /devices/virtual/input/input35 (input)
UDEV  [1829.071356] add      /devices/virtual/input/input35/event24 (input)

Read more here: Source link