Live data from Hacker News

Using htop to generate a live website background

drunken-security.at

11–20 of 63 posts

Re: Using htop to generate a live website background

#12

Neat thanks! You can generate HTML (and from that png or whatever) with http://www.pixelbeat.org/scripts/ansi2html.sh like $ COLUMNS=80 timeout 1 htop > t.ansi $ ansi2html.sh --bg=dark t.html I've requested a -b, --batch option for htop, to simplify this mode of operation. https://github.com/hishamhm/htop/issues/282 Then you could just: $ COLUMNS=80 htop -b | ansi2html.sh ...

[deleted]

Re: Using htop to generate a live website background

#14
post #11

Well it's ansi text, so why not just copy the text directly to a DIV, convert the ansi to html (or css) and update it via javascript polling ?

You would have to parse the VT-100 escape codes to generate the correct html + css (e.g. colors and cursor relocation escape sequences). It is not that straight forward, but on the other hand there are libraries for that.

Re: Using htop to generate a live website background

#15
You can make it more efficient by capturing the images to a buffer and rendering a low FPS h264 stream, serving it as HLS fragments and displaying it with hls.js ( https://github.com/dailymotion/hls.js ) as a background element. There is a lot of inter frame compression benefits to be had from this sort of content + it will look more nice with a constant stream of frames. With a low FPS, the CPU usage should be low enough to not be noticeable and also, you can serve a static JPEG as a "preview" when loading the stream in the background for having a background picture on load.

Re: Using htop to generate a live website background

#20

You can make it more efficient by capturing the images to a buffer and rendering a low FPS h264 stream, serving it as HLS fragments and displaying it with hls.js ( https://github.com/dailymotion/hls.js ) as a background element. There is a lot of inter frame compression benefits to be had from this sort of content + it will look more nice with a constant stream of frames. With a low FPS, the CPU usage should be low e…

we lol'd... Its a good idea. The inter frame compression is the point which would be nice to have.
Post reply on HN