Hacker News new | past | comments | ask | show | jobs | submit login
Let it snow in your terminal (github.com/sontek)
195 points by ensocode on Dec 15, 2023 | hide | past | favorite | 71 comments



Wow, surprising to see this on the frontpage this morning! This is my old script, the better one to use is called snowmachine:

    * https://github.com/sontek/snowmachine
    * https://pypi.org/project/snowmachine/
Which is also on docker, homebrew, nix, etc. It probably makes sense to update the post to link to one of these since they'll provide a better experience


Bug Report: My terminal color settings are a bit unusual and I'm getting yellow snow.


PSA: Never eat the yellow snow


There is a `--snow-color` option :D


It didnt work :(


It has 2 options: light and dark. /s


I thought your handle sounded familiar. You used to hang out in the pyramid irc channel.

Thanks for your help those many years ago.


Pyramid is still the best web framework


Ok, we'll switch to that github link from https://pypi.org/project/snowjob/ above. Thanks!


Hopefully this post inspires someone to take on the snow plow character feature request


I feel inspired to take it on. I have questions on how they pictured it because it could be implemented in quite a few ways.


I've forked it and made changes as well as submitted a pull request to Sontek.

https://github.com/batfasturd/snowmachine


Okay, I have a working prototype of a snowplow idea, it took me a long time to wrap my head around how things were rendered to the screen and how it kept track of snow particles.

Now I am going to work on a few bugs and clean up the code so I can either fork it or submit a pull request.


sontek, thanks for the update, didn't notice that new version. I requested a link change.


I'm running ubuntu 23.10 and was pleased to see that xsnow (apt install xsnow) has been updated and "just works". A nice update on xsnow from decades back, but there's a vintage mode for the nostalgic.

The new xsnow added stars, aurora, birds, moon, stars, wind, blowing snow, moose, meteors, reindeer, snow that builds up slowly (the flakes compress) etc. Sadly snow builds up on the settings window, but with weyland it doesn't build up on normal windows.


Time marches on, but I wonder how many new linux users will never see so many cool old programs as they just do not know about them.

Does that thing everyone keeps trying to get us all to move to (I am a hardcore ICEwm / *boxwm user) support all of the old X stuff like xsnow, xscreensaver, etc?

I was sad to realize that xroach is no longer in Debian (or Gentoo, there is a bug report from 2009), however, others still exist: https://unix.stackexchange.com/questions/204241/x-windows-sp...

As SE says, do not forget the "santa" option to xsnow. I forgot about it.

This always reminds me, anyone remember Koules? https://www.ucw.cz/~hubicka/koules/English/koules.html


Yes, I remember koules, played that a lot.

That is the saddest thing about Wayland, a lot of cool little X applications will stop working and be forgotten about.

There is xfishtank, I posted this screen to remind people about it years ago. I kick that off every so often for fun.

https://old.reddit.com/r/unixporn/comments/m9gk2l/ctwm_on_sl...

There are many many more of these little clients that will disappear once Linux disables X. Never mind other cool things, a couple I remember: lavaclock, bubblefishymon, catclock, xplanet.


I think only the parts of X that talk directly to the graphics hardware are being abandoned and that many of the things you mention will continue to work.


Some may, but xfishtank, xplanet and xscreensaver on root window will not.

You can do this to get a matrix wallpaper, this will work with many xscreensaver "utilities"

/usr/libexec/xscreensaver/xmatrix --root

where this is on your distro may be different.


On wayland, I have an animated wallpaper of a forest: https://www.reddit.com/r/unixporn/comments/11w3zzj/hyprland_...

Why can't we bring the apps you mention to wayland as a background?

For the foreground, the compositor could even use the alpha channel to draw see through snowflakes: I have foot in quaketerm mode showing what's behind. Replace foot by a smaller snowflake, make more than one of them, and it should be the same!

Or am I missing something?


There is xwayland, yes.


How does xwayland help here? In order to see what xsnow is about look here [1]. From my understanding such a program is fundamentally against wayland design philosophy. I feed it will be just impossible with Wayland unless you implement it as part of the display server.

[1]: https://www.youtube.com/watch?v=T2Mzg2i6t0I


> From my understanding such a program is fundamentally against wayland design philosophy

Against the philosophy but, I think, not completely impossible. Wayland is “just a protocol”, so somebody could write a Wayland server that runs in a Wayland window. Then, you could draw anywhere in the outer window, including outside of the inner one(s).

Make the outer window not have a title bar, etc. and run in full screen, and you’re done.

Isn’t that what XWayland does, except for the fact that it runs X Windows windows inside a full screen Wayland window?


> Isn’t that what XWayland does, except for the fact that it runs X Windows windows inside a full screen Wayland window?

I don't know. But if it does so, how does it integrate wayland windows with X windows? How does it stop X programs from observing the window contents of wayland programs?


xsnow even works well under Windows WSL. The whole screen was full with snowflakes, birds, etc.

Impressive that the X11 XShape (Nonrectangular Window Shape Extension) works so well.


I always loved xfishtank. I still have a strong preference for animated root windows today.


What a cute program.

It doesn’t work very well in i3, sadly. I’m not sure what I expected it to do in a tiling window manager, but it only produces snow on empty workspaces, I guess because otherwise the screen is fully occupied (no room for snowflakes). Also the menu seems to follow me around.

Still neat, though. Maybe I’ll try out a non-tiling WM for the holidays…


Under settings there is a a button in the center that says "below windows". Click it. It should put the snow in front of the windows. Notice that it will say click again to confirm.


Hmm, odd, I found that button but it is greyed out.

Thanks for the suggestion though. If I want to see snowflakes I’ll can switch to another workspace or look out the window and wait a few days. :)

Edit: When I turn on a compositor, picom, the option becomes clickable. But when I turn on picom, the flakes stop rendering for some reason. It looks like somebody came up with a patched version for i3 + picom, so I guess this is a problem that people have worked on already.


I'm running Slackware. After updating to 15.0 i was shocked that xsnow , instead of starting, displayed a config dialogue. I removed it and installed the older 1.42 version.


Python? We don't need no stinkin' Python.

    while sleep 0.1; do printf "%-$(( ( RANDOM % `tput cols` ) - 1))s\e[0;$(( 30 + ($RANDOM % 8) ))m*\n" ; done


Shout out to Alphapapa's excellent snow.el script for Emacs

https://github.com/alphapapa/snow.el


by bash wants more ()s

  while sleep 0.1; do printf "%-$(( ( RANDOM % $(tput cols) ) - 1))s\e[0;$(( 30 + ($RANDOM % 8) ))m\*\n" ; done


Nice - if you can do a handstand :)


Impressive, but mine was also floating up vs down. :)


hahhah I just tried this. I'm impressed!


> You can pass –stack if you want the snow to pile up

The flag is --stack of course (I checked), but somewhere a helpful formatting engine replaced two hyphens with an en dash.


Your experience has been Improved by a smart feature. Pray they don't improve it further!


Hilariously old-school. Even the name, snowjob, feels wonderfully anachronistic in 2023.

Definitely getting TRS-80, Robert Frost (1) vibes from this one.

(1) https://youtu.be/j-Zcog5o_p0?t=10


  cat /dev/random | tr -c 'ox0.@' ' '
(poor man's version)


$ cat /dev/random | tee >(aplay -r 8000) | tr -c 'ox0.@' ' '

If you really want to conjure a howling blizzard (R.I.P headphone users though)


Nice. Here's a version with snow falling down instead of up.

clear ; while true ; do tput cup 0 0 ; tput ri ; head -n 1 /dev/random | cut -c "1-$COLUMNS" | tr -c '.,x*oO@'$'\n' ' ' ; done


oh I love this!


> ruby -e 'C=`stty size`.scan(/\d+/)[1].to_i;S=["2743".to_i(16)].pack("U*");a={};puts "\033[2J";loop{a[rand(C)]=0;a.each{|x,o|;a[x]+=1;print "\033[#{o};#{x}H \033[#{a[x]};#{x}H#{S} \033[0;0H"};$stdout.flush;sleep 0.1}'


Saving that alias as I love things done in ruby, really nice. If anyone else was curious about a breakdown on some of the parts.

ruby -e:

This command tells the system to execute the following Ruby code.

C=`stty size`.scan(/\d+/)[1].to_i This part gets the size of the terminal window. stty size returns the dimensions of the terminal (rows and columns) .scan(/\d+/) extracts the numbers from this output, and[1] gets the second number, which represents the number of columns and then to_i converts this number to an integer. The result is stored in the variable C.

S=["2743".to_i(16)].pack("U*") This line creates the snowflake character. "2743".to_i(16) converts the hexadecimal number 2743 (which represents the Unicode code point for a snowflake) into an integer, and .pack("U*") converts this integer into a UTF-8 character.

a={} Initializes an empty hash a. This hash will keep track of the position of each snowflake.

puts "\033[2J" This ANSI escape code clears the terminal screen.

loop{...} An infinite loop to keep the animation going.

Inside the loop.

a[rand(C)]=0 Randomly places a new snowflake in the top row at a random column.

a.each{|x,o|;...} Iterates over each snowflake.

Inside the iteration.

a[x]+=1 Moves the snowflake down one row. print "\033[#{o};#{x}H \033[#{a[x]};#{x}H#{S} \033[0;0H" This part uses ANSI escape codes to move the cursor and draw the snowflakes. It moves the cursor to the old position of the snowflake, prints a space (to erase the old snowflake), then moves to the new position and prints the snowflake character. $stdout.flush Flushes the standard output buffer, ensuring that all output is displayed immediately. sleep 0.1 Pauses the loop for a short time (0.1 seconds) to control the speed of the animation.


Any reason for "S=["2743".to_i(16)].pack("U*")" instead of S="\u2743"?


This is amazing.


awesome!


It's impressive that this can be done in a few lines of bash:

https://gist.github.com/sontek/1505483


Script runs in my WSL/Ubuntu but it seems

     u274$[($RANDOM%6)+3]
wasn't understood properly. I got question boxes. The Slow Rain of Unknowns works for me tho.


Your font is missing the relevant glyphs from u2743 onwards. See[1] for what they're meant to look like.

[1] https://www.compart.com/en/unicode/block/U+2700


Sounds like an issue with Windows Console Host, not WSL itself as it works for me in WSL in WezTerm.


could you try 0x274?


There use to be a tiny software at the time of windows XP. It created a falling snow effect on your screen (they were just tiny white pixels as i remember) which collected on sharp edges including icons, taskbar and text and accumulate over time. It would disappear when a window was moved. Anyone remember its name?


The original concept was a screensaver for Macintosh, which was soon after ported to X Windows as "Xsnow". Several different versions were made for Windows. Here's one: https://janswaal.home.xs4all.nl/WinSnow/


Found the tool I was talking about after searching in my backup drive with old stuff. It was a small tool df_snowfall from 2006 downloaded from a now defunct warez site www.darfun.tk. Might have downloaded it along with some other software. Windows 10 kept complaining it's a trojan and didn't run it correctly even with compatibility mode.


Didn't work in zsh on my Mac. Fixed the issues and added a couple of effects:

https://github.com/lasanthak/snowjob/blob/main/snowjob.sh


[Because linking to cool zsh features seems to be a hobby of mine…]

If you're using zsh for this you can access terminfo directly¹, instead of hardcoding escapes(for example, "echoti cup $snowflakes[$i] $i"²) or shelling out to tput. You can also use zselect to replace sleep. Extra points for "echoti smcup" to use the secondary screen when available, instead of wiping the screen.

¹ https://zsh.sourceforge.io/Doc/Release/Zsh-Modules.html#The-...

² To be fair it would need a minor change to array structure, as cup is zero-indexed.

³ https://zsh.sourceforge.io/Doc/Release/Zsh-Modules.html#The-...


You can have a roaring fire in another tty:

https://github.com/dmo9000/ttyfire


An unrelated version of snow on the ASCII playground (runs in the browser, interactive):

https://play.ertdfgcvb.xyz/#/1640473937099


Going to try this in my pfsense console because I am a bad admin.



Screen captures?


https://github.com/sontek/snowmachine#snowmachine

There are some asciinema recording links in the Github readme.


Awesome, thanks


This is awesome...cmatrix is a similar program I like based on The Matrix, available on homebrew


Me in Brazil letting it snow on my terminal while it's currently 100°F


snowjob, haha. Reminds me of the notorious pronview flamewar on debian-devel. Nice to see that language police hasn't fully overtaken FLOSS yet.



Interesting, a new meaning I have learned. There have been some new terms in the last few years, like gaslighting etc. In germany we don't even have translations for those, we just adopt the english wording. Let's see when "snow job" comes into our language, I haven't heard it here yet.


Young people today.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: