Send a System-Message from sh-script

Is there a dbus-command or sililar to push a System-Message like “Done this script”?

Have a look at this thread:

1 Like
gdbus call --session --dest org.freedesktop.Notifications --object-path /org/freedesktop/Notifications --method org.freedesktop.Notifications.Notify MyApp 42 "icon-s-filled-warning" "Summary" "Body" "[]" "{'x-nemo-preview-summary':<'Popup summary'>, 'x-nemo-preview-body':<'Popup body text'>}" 0

I take this from your Link, thank you pherjung!

2 Likes

If you want to use notificationtool, install first the package lipstick-qt5-tools.

1 Like

I´m using gdbus, because its working out-of-the-box on vanilla SFOS4.4.

Is it possible instead of a string for body-text to use a small textfile for the content?

I’m not sure to understand, but here is my proposition. Save the content of your file in a variable with body=$(cat your file) and write $body instead of any content.

1 Like

I would download the text-content with curl to info.txt and then send the content of info.txt as System-Mesage.

In that case, simply do:

body=$(curl YOUR_URL)

It depends how your file is stored on the website. If it’s a simple page with plain text, it’s fine. Just check if your variable contains what you expect.

Its plaintext.

body=$(curl https://www.mydomain.com/info.txt)

-bash: curl https://www.mydomain.com/info.txt": not found

I tried also set the command inside the () into " " and gives output path “-o info.txt”

Seems your URL is wrong. It’s difficult to help without the right one.

It´s a replacement, i dunno want to public the real url.

WIth my domain the error is the same, so the content doesn´t matter.

Probably forum formatting the link is also impacting it but shouldn’t it be command not found? Also you’re passing -o to curl? So maybe do the downloading first and then just cat the resulting info.txt?

Is curl installed on your phone?

Yes, and i have downloaded this text-file to /home/defaultuser/info.txt

@ throwaway69
cat info.txt doesn´t work.

Weird, something like this works for me:
#!/bin/bash

curl http://www.google.com -o info.txt
body=$(cat info.txt)
echo $body

Maybe add the full paths (/home/defau… and maybe even /usr/bin for the curl and cat)? How are you calling the script?

This Part:

body=$(cat info.txt)

get the content and tries to parsing it(??) and triggering this error:

Error parsing parameter 6 of type “as”: unknown keyword:
  mit
  ^^^

“mit” is a word thats inside the .txt-file.

Replacing it with $body with the same results.

All inside this command-line of course:

gdbus call --session --dest org.freedesktop.Notifications --object-path /org/freedesktop/Notifications --method org.freedesktop.Notifications.Notify "AppName" 42 "icon-s-Do-it" body=$(cat info.txt) "Copyright" "[]" "{'x-nemo-preview-summary':<'Popup summary'>, 'x-nemo-preview-body':<'Popup body text'>}" 0

No, define body beforehand and use “$body” something like this:
#!/bin/bash
curl -v --silent http://www.google.com 2>&1 | grep expire > info.txt
body=$(cat info.txt)
gdbus call --session --dest org.freedesktop.Notifications --object-path /org/freedesktop/Notifications --method org.freedesktop.Notifications.Notify MyApp 42 “icon-s-filled-warning” “Summary” “$body” “[]” “{‘x-nemo-preview-summary’:<‘Popup summary’>, ‘x-nemo-preview-body’:<‘Popup body text’>}” 0

edit:all 4 lines above of course in an executable (chmod +x) file called whatever.sh and called from shell ./whetever.sh, it’s not a oneliner

Finally it works!

Thanks to pherjung and throwaway69!

1 Like

@fingus

in case you didn’t already do something like that, you can have an “app icon” to run your .sh with the following way:

create a file whatever.desktop in the directory: /home/defaultuser/.local/share/applications

In there write the following:

[Desktop Entry]
Type=Application
Exec=sh -c '/home/defaultuser/whatever.sh'
Name=Whatever
Icon=/home/defaultuser/icon-256x256px.png
Comment="no ideas what this line does"

Where in Exec line put where is your (executable) script, Name what will show in the app grid, Icon if you make an icon for your App, this will be, and Comment… well, this I don’t remember why it is there and I don’t know / tried to remove it. If you want to comment something, the ‘#’ works.

Also, if you are interested for different icon, you can choose from here:

Cheers

3 Likes