Is it possible to add those effects in normal terminal? Modified terminal? Code something from 'scratch' for fun? Play sound every 3 seconds and lower the intensity of cursor highlight smoothly over 3 seconds time.
Is it possible to add those effects in normal terminal? Modified terminal? Code something from 'scratch' for fun? Play sound every 3 seconds and lower the intensity of cursor highlight smoothly over 3 seconds time.
This is a fun idea. I'd use that.
Unfortunately, terminals don't support fading text or fading reverse video. So you get to select some ANSI colors to cycle through and rewrite the screen yourself. This puts you squarely in the "code something from 'scratch' for fun" territory.
This task can be completed in Bash, Python, C or any one of hundreds of other languages capable of execing shell commands. Pick a language you want to learn, or are already familiar with.
Assuming you are working in bash or another shell, you can play audio with the
play
command (from the sox package). There are many other command line media players to choose from, depending on the audio format.It will be a bit difficult to parse the output of
watch -d
in order to identify changes. Most command pipelines like to work with a complete file. Detecting the screen refresh from an unending file, like stdout fromwatch -d
, and splitting it into chunks is the crux. You might find it easier to stash the output of your watched command in a variable or temp file that you can diff against in the next run.Here is an example of how you might get the ball rolling in bash:
Which we can run like this:
./submarine-watch.sh date
Check out the output animation:This example has a hard-coded refresh rate of 5 seconds. You can add argument parsing or just change the hard-coded delay to suit your needs. This example does zero input validation before running whatever command is provided. Your security spidey-sense should be tingling in a big way. Do not use this example with any sort of elevated privileges on a shared system.