How to send a desktop notification in KDE from a daemon

5.5k views Asked by At

I have a daemon (netplugd) which can take some actions when my cable is being plugged in or out. These actions can be defined via a bash script. How can I send a notification (as a different user) to my desktop (using bash) that will inform me about the state of the cable.

I have tried the following:

notify-send and knotify --passivepopup but the daemon shows that $DISPLAY is not set.

2

There are 2 answers

1
AstroFloyd On BEST ANSWER

You could use the write command, which can be caught by KDE's Write daemon, and will be displayed in the Notification area in your KDE desktop. The Write daemon is running by default; if not, you can change this in System settings -> System administration -> Startup and Shutdown -> Service manager.

By default the notification produces a sound, and a pop-up which lasts for about four seconds. After that, you'll find a reminder of the notification on your taskbar. You can manage the behaviour of this notification to some extent in System settings -> Common appearance and Behaviour -> Applications and System notifications -> Manage notifications -> Applications tab -> Event source: Local system message service.

1
Ramast On

You can also try

echo hello > /dev/pts/0