Show HN: Bash Screensavers
(github.com)246 points by attogram 6 days ago
A github project to collect a bunch of bash-based screensavers/visualizations.
246 points by attogram 6 days ago
A github project to collect a bunch of bash-based screensavers/visualizations.
> My favourite API: lov_die_with_honor()
A friend of mine fancied the following when making an infinite loop in C:
#define MONEY 1
#define POWER 1
while (MONEY == POWER)
{
...
}Gallery of current screensavers: https://github.com/attogram/bash-screensavers/blob/main/gall...
You can put them onto your Plasma wallpaper and/or lockscreen background with plasma-wallpaper-application: https://invent.kde.org/dos/plasma-wallpaper-application
(thought I'd share that since its raison d'être was to put Asciiquarium there :))
Plasma wallpaper plugins are, well, for Plasma.
When it comes to wallpapers, you could do a similar trick on X11 DEs by putting it onto the root window (with a tool like xwinwrap) and on Wayland DEs that support layer-shell (with a tool like windowtolayer). I'm not aware of screen lockers that do something like that, but you could always write your own one.
I've used Emacs for years but just recently learned about zone.el. I wonder if this is based on it too. I see some of the same screensavers here.
Recommendation: Use the terminal control codes 1049h and 1049l [1][2] to keep the terminal 'clean'.
[1]: https://en.wikipedia.org/wiki/ANSI_escape_code#Control_Seque...
Nice! I won't use this since screensavers are much more interesting when not limited to characters, but this is a neat project.
Screensavers are a lost art. I still enjoy them, but at some point we just gave up on them. In the era of CRTs they had a practical purpose (they're screen savers, after all), but modern OLED displays also suffer from burn-in for which screensavers would be useful. My enjoyment is purely aesthetic, though. Sometimes I just want to have something pleasing to glance at in the background, instead of a black screen.
Nowadays most operating systems and desktop environments don't even support them. The state of the art on Linux still seems to be `xscreensaver`, which does have many great ones, but the collection is static, and most of it is visually stuck in the 90s. I wouldn't even try getting it to run on Wayland, and when I last looked into it, it required some hacks and 3rd-party tools.
Also, I've always found the feature of screen locking and screen saving to be orthogonal. Often I want to see pretty graphics without locking my screen, and viceversa.
I've never seen a repo that invites AI coders and then tells them how to behave [0]. I imagine we'll see more of this in the future.
[0] https://github.com/attogram/bash-screensavers/blob/main/AGEN...
AGENTS.md is an attempt to standardise around the different conventions each of the agents uses[0]. It's an initiative by OpenAI. Anthropic don't seem to be in a hurry to support it though[1], possibly to maintain some kind of walled garden, but that's purely speculation on my part.
Never a nice surprise when I find rm -rf / --no-preserve-root in a public repo, apart from this time!
Also, found one of the easter eggs!
Good catch!
For folks curious about the rm -rf see https://github.com/attogram/bash-screensavers/blob/main/gall... line 339
For the 'life' screensaver it might make sense to use half blocks as a base rendering unit. ASCII 220 and 223.
You can also experiment and make your own[1] using TerminalTextEffects[2]. I added this to my ~/.zshrc
> /home/keeb/code/projects/login/motd.sh
Which has.. #!/usr/bin/env zsh
values=("bubbles" "slide" "beams" "rain" "pour" "synthgrid" "unstable" "poop")
len=${#values[@]}
index=$(( (RANDOM % (len - 1)) + 1 ))
selected=${values[$index]}
cat /home/keeb/code/projects/login/motd | tte $selected
Change motd to have an ascii art of your choice. Run it in a loop if you want :)1: https://keeb.dev/static/login.mp4 2: https://github.com/ChrisBuilds/terminaltexteffects
In the good ol' days, ~1990, Norton Commander had a screensaver with stars, similar to the one in the gallery readme, but with fewer stars, that grew from a dot to bigger dot, to shining, then bursted. Nice to see something like that again.
a simple one:
#!/usr/bin/env bash
_cleanup_and_exit() {
tput cnorm
tput sgr0
clear
exit 0
}
trap _cleanup_and_exit SIGINT
while true; do
width=$(tput cols)
height=$(tput lines)
tput setab 0
clear
tput civis
x=$((RANDOM % width + 1))
y=$((RANDOM % height + 1))
color_code=$((RANDOM % 256))
printf "\e[${y};${x}H\e[38;5;${color_code}m"
sleep 1
doneJust an empty screen here... You're picking random positions on screen, and random colors, but then you don't display ANY text so the info is discarded and cells remain clear.
After the printf, perhaps you want: tput smso; echo -n " "
Then I find moving the second "clear" before the "while" makes it more interesting. Not sure if that's more like what you intended.
ive always wanted to build something like this for divination, an X by Y field in which each cell is randomly assigned a character from a set which refreshes on a tick that you're meant to just gaze on and look for spontaneous patterns in, maybe with some conway game of life style rules about how cells can be more or less likely to update based on the states of their neighbors. Fork incoming.
fwiw I've noticed that Omarchy[1] uses some terminal-based screensavers, using something called tte[2] to do so.
Check hollywood out then: https://github.com/dustinkirkland/hollywood
Of course, if used as an actual screensaver on a phosphor or plasma based screen, eventually the character grid would be burned into your screen.
A lot of screensavers, even historically, forget the original purpose of what "saving" your screen means.
Looks like an attempt to make the main GitHub page (the part above the README) display something interesting. It is messed up now because of further commits, but you can see what it looked like at the time here:
https://github.com/attogram/bash-screensavers/tree/a7369a93c...
See the spread-the-word script in https://github.com/attogram/bash-screensavers/tree/main/spot... This script generates a series of shell commands to create a "spotlight" message on the main GitHub repository page. It does this by generating commands that make trivial changes to the top 12 files and directories and then commit those changes with custom messages.
I thought the same thing. I remember being in elementary school and seeing one of these terminate-and-stay-resident / TSR joke things that made the smiley face ascii character bounce around the screen. That led me to finally move on from Pascal and dive into C to make one of my own, though I'm pretty sure it would be possible in Pascal, all the (very obscure) information I could find as a child used C examples. When I finally had one running that would "Moo!" at random places I felt like a real hacker.
Doesn't work for me on MacOS:
I get "mapfile: command not found"
I encountered this in another project. This should hopefully fix it:
zmodload zsh/mapfile
OLEDs are famous for burning in[1], so potentially "yes".
1: https://www.pcworld.com/article/2918628/your-oled-displays-w...
Don't tell me they burn when showing nothing or going to sleep?
We used to have screensavers with CRT because it took them a lot of time to power on and most early CRTs didn't have power saving capabilities so showing something wasn't significantly worse than having a black screen in term of power usage.
How can anyone have a bad day when great projects like this pop up on the front page of HN?
Did you see the library of viz? https://github.com/attogram/bash-screensavers/blob/main/libr...
My favourite API: lov_die_with_honor()