top | item 41735761

Show HN: Screensavers for your terminal (Bevy/Ratatui)

119 points| cxreiff | 1 year ago |github.com

21 comments

order

cxreiff|1 year ago

I made some screensavers that you can have run after a period of inactivity in your terminal. I'm using bevy to generate frames and then ratatui/ratatui-image, through my plugin bevy_ratatui_render (https://github.com/cxreiff/bevy_ratatui_render), to render those frames. The period of inactivity part only works in ZSH because I'm using the TMOUT env variable– please let me know if you know another way!

oxygen_crisis|1 year ago

GNU screen has a `lockscreen` option with a $LOCKPRG environment variable, and an `idle` command that can do `idle 300 lockscreen`.

tmux has `lock-command` / `lock-after-time`.

You could implement a screensaver on top of those... they only "lock" as much the $LOCKPRG / lock-command chooses to lock them, no reason a single keypress can't "unlock" the screen if it's just a screensaver.

Those will be invoked regardless of whether a program is running or it's sitting at the prompt. Since tmux and screen are terminal emulators, the underlying shell and programs running in them won't even be aware of the screen saver.

I have my friend's garage NAS set to use `cmatrix` as a lockscreen on the system console and mine uses `glances`.

alkh|1 year ago

I am personally using https://github.com/st3w/neo (from the Matrix) as my screensaver. Feels good to feel yourself looking at that side of the world from time to time :)

LarsDu88|1 year ago

Wow, didn't know you could do that with bevy!

cxreiff|1 year ago

Bevy lets you create a custom render pipeline, so you just have to get the rendered image and send it to ratatui instead of a window. I handled that part in bevy_ratatui_render (https://github.com/cxreiff/bevy_ratatui_render) which just gives you a bevy Camera and a ratatui Widget that draws the latest frame.

wutwutwat|1 year ago

alias snow='for((I=0;J=--I;))do clear;for((D=LINES;S=++J*3%COLUMNS,--D;))do printf %*s.\\n $S;done;sleep .1;done'

nusl|1 year ago

zsh: parse error near `)'

sans_souse|1 year ago

the DOOM one is fun.

I would personally like to see a set of screensavers that utilizes terminal-text-effects

cxreiff|1 year ago

Its an old windows screensaver! https://www.youtube.com/watch?v=MHGnSqr9kK8

That would be cool! But this is a fairly different/incompatible approach- here each frame is generated by the GPU using an actual game engine (bevy) and then printed to the terminal instead of a window- no logic for different types of characters. Maybe in the future if I replace the ascii rendering library.