termux-app
termux-app copied to clipboard
Support for terminal bell as a notification
The terminal bell works when the app is running in the foreground with the screen on but after screen turns off or the app is running in the background it no longer plays a sound or vibrates based on the bell-character setting in termux.properties.
This option is useful for being notified of events if connected to another machine via ssh (where termux-notification will not work). Please add support for terminal bell as a notification.
As a work around I'm using tmux v2.2 to handle the terminal bell in termux with the following:
apt install tmux play-audio
usr/etc/profile.d/tmux.sh
if [ $TMUX ] ; then
tmux set-hook -g alert-bell 'run "notif.sh ; return 0"'
fi
usr/bin/notif.sh
#!/data/data/com.termux/files/usr/bin/sh
# enable terminal bell via tmux
if [ ! $SSH_CONNECTION ]; then # Do not notify if attached via ssh
termux-notification -i 4848 -t "Termux Terminal Bell" -c "Termux Terminal Bell Notification" &
play-audio -s notification /system/media/audio/notifications/Xenon.ogg &
termux-vibrate -d 150 &
fi
The profile script is another workaround for tmux 2.2 that will be fixed in 2.3 (already fixed in tmux master branch). In tmux v2.3, the profile script will not be needed and the set-hook option can be added directly to your tmux.conf file. The notif.sh script can be modified to your liking and is run whenever there is a terminal bell.
Update: added ssh check
Is this still relevant? I can not make system play system bell sound on both Termux and Konsole (I tried echo -en '\a'
, echo ^G
, tput bel
, nothing works).
Is this still relevant? I can not make system play system bell sound on both Termux and Konsole (I tried
echo -en '\a'
,echo ^G
,tput bel
, nothing works).
@twaik
printf '\a'
, echo -en '\a'
and tput bel
output a BEL control character to the terminal.
echo ^G
does not, the GNU Bash or POSIX version of echo
does not interpret caret notation.
A BEL char being printed to the terminal causes Termux to send a short vibration to Android on my Device (Android 10), check if you have vibration enabled in the Android quick settings.
A BEL char being printed to the terminal causes Termux to send a short vibration to Android on my Device (Android 10), check if you have vibration enabled in the Android quick settings.
You are right. I succeed making constantly vibrating phone with while :; do tput bel; done
.
But it stops vibrating while screen is locked or application is not on screen. Interesting thing: device keeps vibrating if I keep termux's window (in freeform mode) opened but focusing some other window.
There is actually a dedicated escape sequence for notifications,
it's a urxvt
escape sequence extension, OSC 777
.
i.e \e]777;notify;<title>;<body>\e\\
- See: https://codeberg.org/dnkl/foot/pulls/236
I don't think Termux implements it.
But it is implemented by: urxvt
(obviously), foot
and GNOME terminal
/libvte
(which a lot of terminals use as a base)