14

I am trying to change the format of text appearing in pop-up notification while using notify-send command. Here I saw that it can be done using HTML formatting. But that doesn't seem to be working for me.

Is there any way to achieve this?

  • 2
    Notify-osd uses system font. Try patched version of notify-osd from leolik's ppa: https://launchpad.net/~leolik/+archive/ubuntu/leolik. And then you can modify various things: http://askubuntu.com/questions/128474/ – Khurshid Alam Mar 19 '15 at 10:16

1 Answers1

13

The issue might be that the summary string is not parsed, whereas the body string is parsed. The format should be notify-send <OPTIONS summary body>

You will notice in the code below the summary (or title, or subject, one could say) will not be formatted, but the body string will be.

You can pass an empty string for the summary, but the spacing will still be there. Although the title is optional, it's suggested to include it in the event your notifications are used in other applications such as tickers or feeds that do not require or support anything but plain text.

#!/usr/bin/env bash
phrase="Hey sexy, it's `date +'%l:%M %P'`"
/usr/bin/notify-send --icon=clock -t 4000 "<i>Time Now</i>" "<span color='#57dafd' font='26px'><i><b>$phrase</b></i></span>" >/dev/null 2>&1

according to the docs the summary is:

a single line overview of the notification. For instance, "You have mail" or "A friend has come online". It should generally not be longer than 40 characters, though this is not a requirement, and server implementations should word wrap if necessary. The summary must be encoded using UTF-8."

For more info on styling the body text, see http://www.galago-project.org/specs/notification/0.9/x161.html

  • 1
    I have to add --urgency=critical to make it work on my machine (probably because youtube is running on another screen). – WinEunuuchs2Unix May 31 '18 at 11:01
  • Good call. If you plan on using in a cron job you'll likely need to add DISPLAY=:0.0 at the top of your crontab. Some apps and services that require your display manager's config, such as notify-send, will not work properly without this. aws-cli will likely require HOME=/home/me as well, if you plan on text-to-speeching with Polly, which I highly recommend! – Hunter Frazier Jun 01 '18 at 00:19