termux-api icon indicating copy to clipboard operation
termux-api copied to clipboard

termux-notification - multiline doesn't work

Open ourarash opened this issue 5 years ago • 11 comments

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.

image

image

ourarash avatar Jul 21 '19 19:07 ourarash

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"

xalexalex avatar Aug 01 '19 12:08 xalexalex

Any chance this will be fixed?

ourarash avatar Aug 07 '19 18:08 ourarash

Thanks for reporting! Fixed in version 0.44 of the termux-api package.

fornwall avatar Aug 07 '19 20:08 fornwall

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?

ourarash avatar Aug 09 '19 16:08 ourarash

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

xalexalex avatar Aug 09 '19 16:08 xalexalex

\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]:~:$

ghost avatar Aug 09 '19 17:08 ghost

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.

xalexalex avatar Aug 09 '19 19:08 xalexalex

  • \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!

Screenshot_20190810-072326_One UI Home

ourarash avatar Aug 10 '19 14:08 ourarash

"\n" works, but auto-wrap still don't.

langrenfengzi avatar Nov 18 '19 09:11 langrenfengzi

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.

xalexalex avatar Nov 18 '19 21:11 xalexalex

You can do like this if you want to print next line.

termux-notification --content  "$(echo  -e  "line1\nline2")"

sumithemmadi avatar Oct 26 '21 06:10 sumithemmadi