ASCII Art Ghost in the Shell at Linux Boot
\0 Hackerz,
Once again, early in the evening, I had a wacky idea (as always): displaying a Ghost in the Shell video in ASCII Art at my Linux boot.
Nothing too complicated, as we’ll see, but I thought the result looked pretty cool, so I decided to write this post.
1. Getting the Ghost in the Shell video
First off, we need a relatively short video that ideally shows the famous Ghost in the Shell logo (because it’s pretty cool, right?). After a bit of searching, I found this YouTube video that fit my criteria.
Of course, this video is on YouTube and not in ASCII format. We’ll have to download it from YouTube as an .mp4
file, then try to convert it. For the first step (downloading the .mp4
), there are plenty of tools available (command line, online sites, etc.).
Since I’m lazy (yes, yes…), I opted for a site full of ads to do it quickly.
Once the video was downloaded, I went off in search of my Holy Grail: the tool that would allow me to transform this video into ASCII.
2. Converting to ASCII
After checking out a few GitHub repositories, I came across the collidingscopes project and their site:
https://collidingscopes.github.io/ascii/
Honestly, it’s super cool! Thanks to that tool, I managed to get this magnificent Ghost in the Shell video directly in ASCII Art.
3. Overall idea: autologin + startup script
Once I had the ASCII video, I started brainstorming how to achieve our objective: automatically launch the ASCII video at boot, then get back to the login screen (the Display Manager) right afterwards.
So I went with the following idea:
- Create a dedicated user (let’s call them
anim
). - Enforce auto-login on
anim
on TTY1. - Run a script that plays the ASCII video.
- Log out, handing control over to our graphical login manager.
I believe this is the simplest method.
4. Overriding the getty@tty1 service
To do this, I first had to override the systemd getty
service, specifically for TTY1.
In /etc/systemd/system/getty@tty1.service.d/override.conf
, I added:
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin anim --noclear %I $TERM
Type=simple
Quick explanations
-
ExecStart=
(empty) cancels the defaultExecStart
line ingetty@tty1.service
. -
ExecStart=-/usr/bin/agetty --autologin anim --noclear %I $TERM
:--autologin anim
tells it to auto-login as useranim
.--noclear
prevents clearing the screen before starting the session (useful if you want ASCII already visible).%I $TERM
are variables passed automatically by systemd, specifying the TTY name and the terminal environment variable.
-
Type=simple
indicates the service runs in the foreground (see systemd docs for more details).
In short, this allows you to be directly logged in as anim
on TTY1 without being asked to enter a username.
5. The shell script to play the video
Next, I wrote a small shell script, for example in ~/play-video-then-dm.sh
(for user anim
):
#!/usr/bin/env bash
clear
mpv --vo=tct --ao=null --really-quiet /home/anim/ghost_in_the_shell_ascii.mp4
sleep 1
clear
systemctl start graphical.target
logout
Note:
--vo=tct
is a video output driver that “draws” in the terminal (true-color pixel mode).--ao=null
disables audio.--really-quiet
suppresses mpv’s messages.
6. Editing .bash_profile
Finally, I modified the ~anim/.bash_profile
file to run this script as soon as we log in, then log out:
if [[ -z "$SSH_CONNECTION" ]]; then
/home/anim/play-video-then-dm.sh
fi
The check
[ -z "$SSH_CONNECTION" ]
is to avoid playing the video if I’m connecting via SSH (wouldn’t be very useful in that case).
Thus, once getty@tty1
auto-logs user anim
, the script launches, the video is displayed in ASCII, then the script ends with a logout
, giving me back control of TTY1—or, if I have systemctl start graphical.target
in the script, it launches the Display Manager (GDM/LightDM/SDDM), and I get the graphical login screen.
7. Final result
On boot, Linux starts in text mode (multi-user.target
).
On TTY1, systemd runs agetty with --autologin anim
.
User anim
is automatically connected, then .bash_profile
runs the video script.
I get a beautiful Ghost in the Shell ASCII Art at boot, and when the video finishes, it hands me over to the login manager where I can access my usual session.