Perform actions based on notification content

From Lucca's Wiki
Revision as of 00:00, 6 October 2025 by Lucka (talk | contribs)
Jump to navigationJump to search

I put together this script based on some info I found on a forum to execute commands when notifications are received that contain specific text.

#!/usr/bin/env bash
n1='buff luigi'  
n2='ripped mario'  

dbus-monitor "interface=org.freedesktop.Notifications" |
grep -i -e "$n1" -e "$n2" --line-buffered |
while read found_line; do
  echo "$found_line" 
  mpv "${HOME}/share/audio/dark_souls_2_parry.mp3" # replace with your command
done