So I wrote a little script that makes sure a certain user plugs in a laptop when he logs on (it disables if he doesn't). The script uses notify-send to tell him to plug it in. If he plugs it in, the script quits. Is it possible to clear the notification automatically when he plugs it in? I'm thinking it might require somehow getting the process id spawned by notify-send and killing that PID, but I don't know how to do this.

Here's the current script:


cat /sys/class/power_supply/BAT0/status
OUTPUT="$(cat /sys/class/power_supply/BAT0/status)"
echo "${OUTPUT}"
if [ "${OUTPUT}" = "Charging" ] || [ "${OUTPUT}" = "Unknown" ]; then
    echo charging or full
elif [ "${OUTPUT}" = "Discharging" ]; then
    notify-send -i /home/evamvid/Documents/Programming/OokiNoUse/power25.png "Hey there brother" "plug it in"
while [ "$COUNTER" -le 12 ]
    cat /sys/class/power_supply/BAT0/status
    OUTPUT="$(cat /sys/class/power_supply/BAT0/status)"
    echo "${OUTPUT}"
    if [ "${OUTPUT}" = "Charging" ] || [ "${OUTPUT}" = "Unknown" ]; then
    elif [ "${OUTPUT}" = "Discharging" ]; then
        echo $COUNTER
        sleep 1

4 Answers 4


Alternatively, if you do not want the notification to show up in the notification history at all, you can try:

notify-send --hint int:transient:1 "Title" "Body"

The process you are looking for is notify-osd. You can kill it by either the command:

pkill notify-osd

or by its pid:

kill $(ps -e | grep notify-osd | awk '{ print $1 }')

or, even better, as suggested by @kos (thanks!), using pgrep:

kill $(pgrep ^notify-osd$)
  • It's working in a new Terminal instance, so I guess that somehow the former is corrupted, altough I can't see how! Anyway nevermind, I don't want to clutter your post further, I'll remove my comments (upvoted you answer of course)
    – kos
    Jun 23, 2015 at 6:41
  • @kos I did have an odd thing btw. I even removed the answer at first because I got the message "I didn't have permission" (although it worked...) after a restart it worked fine. Jun 23, 2015 at 6:45
  • @kos WOuld you mind if I borrowed your pgrep? option? Is actually better... Jun 23, 2015 at 6:46
  • Not at all, go ahead :) yes I've got the same message at first but I it was when I wrongly killed fsnotify_mark instead, perhaps you were testing using [...] | grep notify | [...]?
    – kos
    Jun 23, 2015 at 6:50
  • 2
    For me, using xfce, the process was not named notify-osd but instead xfce4-notifyd, more specifically /usr/lib/x86_64-linux-gnu/xfce4/notifyd/xfce4-notifyd. I could instead do pkill xfce4-notifyd and it would kill the existing notification. The next time notify-send ran, it auto created the xfce4-notifyd process again, so it seemed safe.
    – Scott
    Aug 15, 2016 at 18:39

I am using Mint MATE 17 The process is listed (example) 15107 ? Sl 0:00 /usr/lib/mate-notification-daemon/mate-notification-daemon

I tried pkill as $ pkill mate-notification-daemon and even $ pkill mate-notification And did not work. However, if I truncated the 'notification' word, it worked: $ pkill mate-notificati Adding the 'on' to the word makes it not work. Don't know why. I imagine this would pertain to Ubuntu MATE editions as well.


For xfce desktop(Lubuntu 18.04) notify-send:

pkill xfce4-notifyd

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .