[HN Gopher] Let the (terminal) bells ring out
___________________________________________________________________
Let the (terminal) bells ring out
Author : hasheddan
Score : 33 points
Date : 2023-12-24 19:00 UTC (3 hours ago)
(HTM) web link (muxup.com)
(TXT) w3m dump (muxup.com)
| Animats wrote:
| I'd wanted a bell in the Rust Egui/Winit system. There's no
| simple cross-platform "beep" or bell feature, short of bringing
| up a whole audio system.
|
| The original Teletype bell in a Model 15 Teletype is a 3-inch
| gong with a satisfying "bong" sound. That was intended to be
| heard across a room of noisy machines. There's also a little end
| of line bell for typists, but that's not loud.
| 10000truths wrote:
| > The original Teletype bell in a Model 15 Teletype is a 3-inch
| gong with a satisfying "bong" sound. That was intended to be
| heard across a room of noisy machines. There's also a little
| end of line bell for typists, but that's not loud.
|
| What would the machine do if a mischievous prankster ran a
| program that endlessly outputted ASCII BEL characters in a
| tight loop?
| Animats wrote:
| Ring the bell. Doesn't hurt anything. Eventually someone will
| turn the machine off.
|
| The later ASCII machines don't have the big gong, just a
| smaller bell.
| wanderingjew wrote:
| If you've ever wondered why it's ctrl+g:
|
| https://twitter.com/ViolenceWorks/status/1335382435031252992...
| efitz wrote:
| I thought this was going to be an article about how someone used
| a Raspberry Pi and some maker fu to connect 0x7 on their terminal
| to a cathedral or something.
| mprovost wrote:
| 'Wuff, Wuff!!'
| anilakar wrote:
| Spawning a screen session by default is a good habit indeed.
| Especially on remote hosts when you are doing something
| critical.
| wolfgang42 wrote:
| The article mentions not wanting to put a bell in their terminal
| prompt because it would cause too many notifications, but I found
| it difficult to remember to put `;tput bel` on every command that
| would be slow, so I compromised by configuring my shell to notify
| only on commands that took longer than 10 seconds. I also use a
| popup instead of a straight bell so I'll see a reminder of what
| it was that was happening (this is for MacOS, on Linux it would
| use `notify-send` instead): function preexec()
| { lrn_timer=${timer:-$SECONDS}
| lrn_command="$1" } lrn_timer=0 function
| precmd() { [[ -v lrn_timer ]] || return # preexec()
| doesn't set timer if no command run (e.g. from ^C before running)
| timer_show=$(($SECONDS - $lrn_timer)) unset lrn_timer
| # 10 is the notification threshold in seconds if ((
| ${timer_show} > 10 )); then terminal-notifier -sound
| default -message "Exit $? in ${timer_show}s: $lrn_command"
| fi }
|
| (Based on
| https://gist.github.com/petethepig/2d29e8b7e2ebc808bfe760b63...)
| mklein994 wrote:
| > [...] but I found it difficult to remember to put `;tput bel`
| on every command that would be slow [...]
|
| What I do in these situations (assuming the job is still in the
| foreground, and can be interrupted), is suspend the task with
| ctrl+z and resume with `fg`, chaining it with some other
| command: fg; notify-send "done"
|
| This uses the "job control" feature of `bash`, so it requires
| no extra setup. Your approach has the simple advantage however,
| that once it's set up, it just works, automatically.
| JNRowe wrote:
| One of the smart things with zsh is that the hooks1 like precmd
| can be replaced with arrays of functions, so that you can
| cleanly have multiple hooks per hook point. It even provides a
| nice tool to work with the the arrays too2, which makes
| editing/enabling/disabling far easier.
|
| It makes life far easier when you see people post useful
| snippets(like wolfgang42's), but don't want to have to mangle
| them in to your already messy monolithic function.
|
| 1
| https://zsh.sourceforge.io/Doc/Release/Functions.html#Hook-F...
|
| 2 https://zsh.sourceforge.io/Doc/Release/User-
| Contributions.ht...
| jhaenchen wrote:
| I use BEL + IFFTT webhooks to trigger a notification on my laptop
| and my iPhone whenever something finishes. Echo hi; notification
|
| With an alias for notification
___________________________________________________________________
(page generated 2023-12-24 23:00 UTC)