How can I fire custom notification on Ubuntu?
-
In the work right now so I cant describe everything, but basically, I'm trying to trigger a notification on my Ubuntu Desktop with the command below:
{"trigger":"Celular carregado","command":"notify-send -i battery-full-charging \"Celular carregado\" \"A bateria está em 95%\"","ground":"background","voice":"celular carregado","allowParams": "false"}
Other background commands that I have, like shutdown, suspend pc, they work fine (that means my background service is installed correctly). But the notification doesn't.
The command shows up in the dashboard
When triggering the command it shows up in the log and says "command ran"
What I don't understand is that if I run the command manually on the terminal, the notification shows up as expected.
Can someone give me a clue on how to do that???
-
@João-Pedro-Vital, to solve this you're going to need to capture the output from your command. It's probably producing an error that you're not seeing.
Please try using this command so it sends the stderr and stdout output to a /tmp/notify-send.log log file:
notify-send -i battery-full-charging "Celular carregado" "A bateria está em 95%" >> /tmp/notify-send.log 2>&1
In commands.json it would be:
{"trigger":"Celular carregado","command":"notify-send -i battery-full-charging \"Celular carregado\" \"A bateria está em 95%\" >> /tmp/notify-send.log 2>&1","ground":"background","voice":"celular carregado","allowParams": "false"}
FYI, that weird 2>&1 at the end makes it so stderr goes to the log file, not just stdout.
-
@Russ Thank you so much for the tip!
Follow the contents of the .log file generated when I manually triggered the command via dashboard. (I don't seem to have permission to post files in the forum)
Cannot autolaunch D-Bus without X11 $DISPLAY
that's all the content of the file, i'm searching for the error RN to see if I get it solved, but if you know how to, please let me know!
-
@João-Pedro-Vital, I did a little googling. I'm not sure if any of these will work because I haven't tested, but can you try these?
export $(dbus-launch) && notify-send -i battery-full-charging "Celular carregado" "A bateria está em 95%" >> /tmp/notify-send.log 2>&1
or
export DISPLAY=:0.0 && notify-send -i battery-full-charging "Celular carregado" "A bateria está em 95%" >> /tmp/notify-send.log 2>&1
or
export $(dbus-launch) && export DISPLAY=:0.0 && notify-send -i battery-full-charging "Celular carregado" "A bateria está em 95%" >> /tmp/notify-send.log 2>&1
-
@Russ thanks for your reply
I tried the commands you suggested, but I kept jumping across different error messages. After googling for hours and fixing one by one, I gave up, I think the time I was losing, it's not worth only to see a 5 seconds notification.
But thanks a lot for the support!!
-
@João-Pedro-Vital, sorry it didn't work out.