LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Using notify-send with multiple lines in body (https://www.linuxquestions.org/questions/linux-desktop-74/using-notify-send-with-multiple-lines-in-body-793399/)

Mleahy 03-05-2010 08:21 AM

Using notify-send with multiple lines in body
 
Hey all,

I'm trying to setup a hotkey in KDE that will popup a notification with the current playlist I have running in an xmms2 server.

I currently have some hotkeys such as the following actions, which work fine:

Code:

xmms2 prev; notify-send "Currently Playing" "`xmms2 current`"
xmms2 next; notify-send "Currently Playing" "`xmms2 current`"

That works fine. However, if I want to popup the current playlist, I would want to do something like the following:

Code:

notify-send "Current Playlist" "`xmms2 list`"
But the playlist has newline characters, which apparently notify-send doesn't like...so I've been looking for a way to clear out the newline characters - and ideally replace them with something notify-send can display as newlines (e.g., HTML with <br> tags?).

I've tried using sed to do this, but I don't know enough about it. From what I can tell, the following has no effect on the output (nor do any variations I have tried thus far):

Code:

xmms2 list | sed '{s/\n/<br>/g}'
I've searched around online, but there are far too many examples of what I don't want to do that are drowning out what I do want to do. I'm pretty sure I've even asked something very similar myself, but can't find where that was.

Anyone have any recommendations?

estabroo 03-06-2010 07:53 PM

I think xmms2 has configuration options to modify the output of the list command, maybe it has an html/xml option

i92guboj 03-10-2010 04:09 AM

I've never seen any problem when dealing with notify-send in this regard.

Can you test something simple like this and see if it works?

Code:

$ notify-send foo "bar
moo
cow"


jg70 08-14-2021 07:06 PM

Quote:

Originally Posted by i92guboj (Post 3892655)
I've never seen any problem when dealing with notify-send in this regard.

Can you test something simple like this and see if it works?

Code:

$ notify-send foo "bar
moo
cow"


That does work on the command line but might not do so well in a script.

ondoho 08-15-2021 03:15 AM

It depends on which program provides the notifications!
Which notification daemon does your system use?
Code:

dpkg -l | grep -i notfication
should answer that question.

FWIW, I use dunst and something like
Code:

notify-send Title "$(mpc)"
works as expected, and so does e.g.
Code:

notify-send Title "bla\nbla\nbla"

jg70 08-16-2021 10:01 AM

Summary required
 
OMG, I had tried using \n already but with no luck. Since you posted using the same I tried again and it failed... then I tried with Title and it worked. That is called {summary} in the man page and otherwise doesn't seem to be required but it did make \n work.

notify-send "bla\nbla" puts bla\nbla on the screen

notify-send Title "bla\nbla" puts on the screen:
Title
bla
bla

OS = Linux Mint 20.2

Thank you Ondoho


All times are GMT -5. The time now is 08:41 PM.