• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
TRIGGERcmd
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

How can I fire custom notification on Ubuntu?

General Discussion
2
6
267
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J
    João Pedro Vital
    last edited by João Pedro Vital Jan 26, 2023, 6:23 PM Jan 26, 2023, 6:18 PM

    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
    9ab0d91b-f3f9-4fb5-b5c1-9a6ac3d16616-image.png

    When triggering the command it shows up in the log and says "command ran"
    ed8238fd-a81f-4e85-9b04-db2ed5205e69-image.png

    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???

    R 1 Reply Last reply Jan 27, 2023, 12:49 AM Reply Quote 0
    • R
      Russ @João Pedro Vital
      last edited by Russ Jan 27, 2023, 12:55 AM Jan 27, 2023, 12:49 AM

      @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.

      Russell VanderMey

      J 1 Reply Last reply Jan 27, 2023, 3:55 PM Reply Quote 0
      • J
        João Pedro Vital @Russ
        last edited by Jan 27, 2023, 3:55 PM

        @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!

        R 1 Reply Last reply Jan 28, 2023, 2:57 AM Reply Quote 0
        • R
          Russ @João Pedro Vital
          last edited by Russ Jan 28, 2023, 2:59 AM Jan 28, 2023, 2:57 AM

          @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
          

          Russell VanderMey

          J 1 Reply Last reply Jan 28, 2023, 5:29 PM Reply Quote 0
          • J
            João Pedro Vital @Russ
            last edited by Jan 28, 2023, 5:29 PM

            @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!!

            R 1 Reply Last reply Jan 29, 2023, 12:24 AM Reply Quote 0
            • R
              Russ @João Pedro Vital
              last edited by Jan 29, 2023, 12:24 AM

              @João-Pedro-Vital, sorry it didn't work out.

              Russell VanderMey

              1 Reply Last reply Reply Quote 0
              6 out of 6
              • First post
                6/6
                Last post