You format text with html code
notify-send -i terminal "<font size=16 color=blue><b><i>'bash -c ls'</b></i></font>" "execution complete"
change what is in the single quotes with the command you wish, feel free to change the size and color to what you wish.
If you need assistance, post your code and more detailed information on what you wish to change
Thanks to Chris Williams (chrisawi) from the Gnome IRC Channel the following solution was found:
Create a script called notifier
in /.local/bin/
with this content:
#!/usr/bin/python3
# License: MIT
# Author: Chris Williams
APP_ID = "com.example.Notifier"
import sys
from gi.repository import GLib, GObject, Gio
class Notifier(Gio.Application):
def __init__(self):
Gio.Application.__init__(self, application_id=APP_ID, flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE)
self.set_option_context_parameter_string ("ID TITLE [MESSAGE...]")
self.add_main_option("icon", ord('i'), GLib.OptionFlags.NONE, GLib.OptionArg.STRING, "Icon name or file", None)
#self.add_main_option("quit", ord('q'), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, "Quit", None)
self.add_main_option(GLib.OPTION_REMAINING, 0, GLib.OptionFlags.NONE, GLib.OptionArg.STRING_ARRAY, "", None)
def do_command_line(self, cl):
Gio.Application.do_command_line(self, cl)
opts = cl.get_options_dict().end().unpack()
#if opts.get("quit"):
# self.quit()
args = opts.get(GLib.OPTION_REMAINING, [])
if len(args) >= 2:
notification = Gio.Notification()
notification.set_title(args[1])
if len(args) >= 3:
notification.set_body(" ".join(args[2:]))
icon_str = opts.get("icon")
if icon_str:
try:
icon = Gio.Icon.new_for_string(icon_str)
except GLib.Error as e:
if not e.matches(Gio.io_error_quark(), Gio.IOErrorEnum.INVALID_ARGUMENT):
raise
else:
notification.set_icon(icon)
self.send_notification(args[0], notification)
else:
print ("not enough arguments")
return 0
if __name__ == '__main__':
app = Notifier()
app.run(sys.argv)
Mention it in the original notify-send script, that also lies in /.local/bin/
:
#!/bin/bash
while : ; do
notifier -i emote-love-symbolic idxyz "$(sort -R ~/Sonstiges/Affirmationen/Affirmationen.txt | head -n 1)"
sleep 30m # time in minutes
done
You also have to create a .desktop
file, either in /.local/share/applications/
or in /.config/autostart/
if you want this script to be executed at startup. My /affirmationen.desktop
in /.config/autostart/
looks like this:
[Desktop Entry]
Name=Affirmationen
Exec=affirmationen
Icon=emote-love-symbolic
Type=Application
StartupNotify=true
Hidden=false
NoDisplay=false
Terminal=false
X-GNOME-UsesNotifications=true
X-GNOME-Autostart-enabled=true
Enjoy!
Best Answer
Even didn't need a full script...
...but put it in the form of a script:
To run it
keep_log.sh
Run it with the logfile as argument with the command
The answer was retrieved from an earlier answer (not a dupe), in which this application of the method was mentioned as an example.
The answer I gave there, on its own turn, was based on this very nice answer, in which is explained that the method uses
dbus-monitor
to intercept the contents of notify-send. By editing the example there, we can make it writenotify-send
messages to a (log-) file.Or, more elegant
...would be to add the date to the logfile, producing a logfile like:
In that case, the script would be: