Skip to content

Instantly share code, notes, and snippets.

@jpralves
Created May 18, 2020 22:02
Show Gist options
  • Save jpralves/5923015c97ce3a62aa7d3fc4b76a6720 to your computer and use it in GitHub Desktop.
Save jpralves/5923015c97ce3a62aa7d3fc4b76a6720 to your computer and use it in GitHub Desktop.
batch notify to desktop from scripts

batch notify to desktop from scripts

To be able to send notifications to the logged in user you must add the file session-local.conf to folder /etc/dbus-1/session.d Then you can use the command in notify-command.sh to display a message. Don't forget to match the UID with the one currently running the session.

This was tested in Fedora 31/32.

#!/bin/bash
UID=1000
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$UID/bus"
export DISPLAY=:0
notify-send 'Hello world!' 'This is an example notification.'
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy context="default">
<!-- Allow everything to be sent -->
<allow send_destination="*" eavesdrop="true"/>
<!-- Allow everything to be received -->
<allow eavesdrop="true"/>
<!-- Allow anyone to own anything -->
<allow own="*"/>
<!-- Allow root on our session busses -->
<allow user="root"/>
</policy>
</busconfig>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment