Reputation: 659
I have have some code like this:
system("notify-send -i
#{Dir.pwd}/#{file}
#{parsed_songlist["song"][0]['title']}
#{parsed_songlist["song"][0]['artist'].concat("#{parsed_songlist["song"][0]['albumtitle']}")} )
The albumtitle follows the artist name. How can I add a newline between them?
Upvotes: 0
Views: 131
Reputation: 3072
I think \n
is enough :
"#{parsed_songlist["song"][0]['artist']".concat("\n#{parsed_songlist["song"][0]['albumtitle']")
Upvotes: 0
Reputation: 37507
Use join
.
system("notify-send -i
#{Dir.pwd}/#{file}
#{parsed_songlist["song"][0]['title']}
#{ [
parsed_songlist["song"][0]['artist'],
parsed_songlist["song"][0]['albumtitle']
].join("\n") }"
)
Upvotes: 0
Reputation: 8840
Try this :
"\'#{parsed_songlist['song'][0]['title']}\'
\'#{parsed_songlist['song'][0]['artist']}\n#{parsed_songlist['song'][0]['albumtitle']}\'"
The problem in your command is if your title/artist/albumtile contain multi-words like hello hi
then in command it will appear as notify-send -i /home/username/file hello hi ...
So you could see how that multi-words 'title' converted as two argumenst for notify-send
.
To tackle such problem use \'
as I used above.
However, '\n' is enough for adding a newline in a double qouted string.
Here, is what I get when I used above
Upvotes: 1