2

I am on Linux Mint 18.1, MATE.

I am using the notify-send command to visualize the name of keys (such as <enter>), while sending them to the current window via a python script.For about two weeks, notify-send has shown a weird behavior. I know the basic syntax in bash is notify-send [OPTIONS] <summary> [body].

Basic problem

When executing notify-send -t 0 '<enter>' 'text body', everything looks fine: enter image description here

However, when trying to print the key name in the message body with notify-send -t 0 'Summary' '<enter>', I get:

enter image description here

The same happens with notify-send -t 0 'Summary' '<', notify-send -t 0 'Summary' '>' or notify-send -t 0 'Summary' \<

Any ideas why the body text is printed blank if it contains < or > ?


Workaround (fails)

I have tried to use a python module istead:

from gi.repository import Notify
Notify.init("App Name")
Notify.Notification.new("Summary","<enter>").show()

But the result is the same as in picture 2 above.


Additional info:

When trying zenity --info --title='Summary' --text='<enter>' in bash, I get an error message:

(zenity:4952): Gtk-WARNING **: Failed to set text '<enter>' from markup due to error parsing markup: Error on line 1 char 24: Element 'markup' was closed, but the currently open element is 'enter'

And instead of the text <enter>, the opening info dialog has the surprising text: All updates are complete.

  • 2
    For the zenity issue, try adding --no-markup – steeldriver Jun 11 '17 at 23:44
4

The notification spec says that body can include simple markup, so any tags inside "<...>" will be removed and interpreted if possible. For example, "<b>hello</b>" will show the word in bold.

You can use the standard html entity mechanism and show a < with &lt; and > with &gt; giving, for example,

notify-send 'Summary' '&lt;enter&gt;'

If you prefer you can just use a multiline summary, eg:

notify-send 'Summary
<enter>'
  • dynamically: notify-send 'Summary' "$(recode ascii..html <<< "$body")" – Blauhirn Oct 9 '17 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.