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

    How can I fire custom notification on Ubuntu?

    General Discussion
    2
    6
    182
    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.
    • João Pedro VitalJ
      João Pedro Vital
      last edited by João Pedro Vital

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

      RussR 1 Reply Last reply Reply Quote 0
      • RussR
        Russ @João Pedro Vital
        last edited by Russ

        @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

        João Pedro VitalJ 1 Reply Last reply Reply Quote 0
        • João Pedro VitalJ
          João Pedro Vital @Russ
          last edited by

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

          RussR 1 Reply Last reply Reply Quote 0
          • RussR
            Russ @João Pedro Vital
            last edited by Russ

            @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

            João Pedro VitalJ 1 Reply Last reply Reply Quote 0
            • João Pedro VitalJ
              João Pedro Vital @Russ
              last edited by

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

              RussR 1 Reply Last reply Reply Quote 0
              • RussR
                Russ @João Pedro Vital
                last edited by

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

                Russell VanderMey

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post