termux / termux-api

Termux add-on app which exposes device functionality as API to command line programs.
https://f-droid.org/en/packages/com.termux.api/
2.33k stars 458 forks source link

termux-notification - multiline doesn't work #274

Open ourarash opened 5 years ago

ourarash commented 5 years ago

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

xalexalex commented 5 years ago

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"
ourarash commented 5 years ago

Any chance this will be fixed?

fornwall commented 5 years ago

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

ourarash commented 5 years ago

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?

xalexalex commented 5 years ago

Thanks for fixing! How does the multiline work now? Does it need \n or will it wrap automatically?

Just tested and:

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

ghost commented 5 years ago

\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]:~:$
xalexalex commented 5 years ago

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.

ourarash commented 5 years ago
  • \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

langrenfengzi commented 4 years ago

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

xalexalex commented 4 years ago

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.

sumithemmadi commented 3 years ago

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

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