Skip to content

zlogic/hypno-toadface

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hypno Toadface

This is a weekend project, attempting to display some graphics using Linux DRM (Direct Rendering Manager) Vulkan's VK_KHR_surface and VK_KHR_display extensions.

In addition, it can also play audio using the ALSA API, without an audio server - using kernel ioctls.

demo.mov

Why?

Do something cool with a headless server that has HDMI output and barebones CoreOS. No X or Wayland is required, because it renders directly to the display surface.

When connected to a 4K TV, show something interesting instead of a login console with a tiny font.

This works well on an off-brand digital signage appliance (NUC) with a Celeron CPU N3350 CPU and 4GB RAM, and maxes out at 30 FPS when rendering 4K images (most likely it's limited by the HDMI interface).

How to run it

Build and run as a regular Rust project:

./hypno-toadface [--speed=<speed>] [--sound=<devicepath>] [--no-print-fps]

--speed=<speed> is an optional argument to specify how fast the animation should be playing, for example --speed=0.1. The default speed is 0.04. Negative values make the animation run in reverse.

--sound=<devicepath> specifies a path to the ALSA sound device, for example --sound=/dev/snd/pcmC0D3p. If not specified, no sound will be played.

--no-print-fps turns off printing the FPS counter.

⚠️ This project works without a windowing manager, but in Linux only one device can have exclusive access to the GPU. If X or Wayland is running, using the GPU would be impossible. To run this project, stop any windowing managers.

As accessing displays and audio requires elevated privileges, the safest way to get them is by adding a user to the video and audio groups:

# Required for CoreOS with a sparse /etc/group
getent group video >> /etc/group
getent group audio >> /etc/group
usermod -a -G video,audio $USERNAME

If SELinux is enabled, make sure that /etc/group has the right label by running ls -Z /etc/group, it should look something like this:

system_u:object_r:passwd_file_t:s0 /etc/group

Run as a systemd service

Create a systemd unit file:

cat <<EOF > ~/.config/systemd/user/hypno-toadface.service
[Unit]
Description=Hypno Toadface

[Service]
Type=exec
ExecStart=/var/home/core/.local/bin/hypno-toadface --no-print-fps --sound=/dev/snd/pcmC0D3p
KillMode=process
Restart=on-failure

[Install]
WantedBy=default.target
EOF

and start it without logging in:

sudo loginctl enable-linger $USER

References:

ALL GLORY TO THE HYPNOTOAD