termux-api
termux-api copied to clipboard
termux-notification - multiline doesn't work
Problem description
Termux notifications cuts the line and doesn't show strings that don't fit in a line. Using \n
or piping to stdin as recommended here doesn't work either. In fact it looks like the piped value is ignored.
Steps to reproduce
ls $PREFIX | termux-notification --title 'Some folders'
Expected behavior Wrap the strings that don't fit in a single line.
Additional information Non-rooted device. Galaxy Note 8.
$ termux-info Updatable packages:
All packages up to date
Subscribed repositories:
https://dl.bintray.com/grimler/science-packages-21 science/stable
https://dl.bintray.com/grimler/game-packages-21 games/stable
https://termux.net stable/main
https://termux.net stable/main
System information:
Linux localhost 4.9.112-15119493 #2 SMP PREEMPT Thu May 30 19:02:31 KST 2019 aarch64 Android
Termux-packages arch:
aarch64
Android version:
9
Device manufacturer:
samsung
Device model:
SM-N960
The below image shows the of the above command results on my device.
Due to a regression, currently stdin doesn't work to set termux-notification's content (#271).
However, multiline still doesn't work:
#doesn't work
termux-notification --content "line 1\nline 2"
#also doesn't work
termux-notification --content "line 1
line 2"
Any chance this will be fixed?
Thanks for reporting! Fixed in version 0.44 of the termux-api package.
Thanks for fixing! How does the multiline work now? Does it need \n
or will it wrap automatically?
Also, when will this version be available on google Play?
Thanks for fixing! How does the multiline work now? Does it need
\n
or will it wrap automatically?
Just tested and:
- long lines don't wrap, they just get truncated by
...
-
\n
doesn't work. Did it work? (is it a regression?) - actually embedding a newline in the string works. i.e.
termux-notification -c 'hello
world'
Also, when will this version be available on google Play?
termux-api-package
does not end up in google play; just pkg up
in termux to update it
\n doesn't work. Did it work? (is it a regression?)
Just \n
will not work unless it is parsed and replaced with newline character.
[xeffyr]:~:$ echo "a\nb"
a\nb
[xeffyr]:~:$ echo -e "a\nb"
a
b
[xeffyr]:~:$
Whoops, sorry, I was referring to the argument to --content
and had forgotten about stdin entirely.
So termux-notification --content 'a\nb'
won't work, but echo -e 'a\nb' | termux-notification
will.
\n
doesn't work. Did it work? (is it a regression?)- actually embedding a newline in the string works. i.e.
It now works. I call it from a node script. I used it in my package stock-crypto-monitor to show a multi-line notification. Thanks for the fix!
"\n" works, but auto-wrap still don't.
Confirmed; reopening
Edit to clarify: the feature that's missing is auto-wrapping of long lines ( termux-notification -c 'lorem ipsum dolor sit amet lorem ipsum dolor sit amet'
), while multiline notifications work if the user specifies where the line break should be.
You can do like this if you want to print next line.
termux-notification --content "$(echo -e "line1\nline2")"