KMSCON

Related articles
KMS
systemd
From the project's
git repository
:
Kmscon is a simple terminal emulator based on linux
kernel mode setting
. It is an attempt to replace the in-kernel VT implementation with a userspace console.
Kmscon can function as a drop-in replacement for the in-kernel linux-console. Features include:
Full vt220 to vt510 implementation.
Full internationalization support:
Kmscon supports printing full Unicode glyphs, including the CJK ones.
Kmscon provides internationalized keyboard handling through libxkbcommon, thus allowing it to use the full range of keyboard layouts supported in X keyboard.
Hardware accelerated rendering.
Scroll support.
Mouse/Touchscreen support.
On screen font resize support, including TTF fonts.
Multi-seat
capability.
Installation
Install
the
kmscon
package.
Configuration
Despite its name,
KMS
is not a hard requirement for kmscon. It supports the following video backends:
drm3d
(Linux DRM hardware-rendering backend).
drm2d
(Linux DRM software-rendering backend).
fbdev
(
Linux framebuffer
).
Make sure one of them is available on your system.
Normally, there is a special systemd configuration for
tty1
. To be conservative, you can continue to run the traditional agetty on
tty1
and only run kmscon on some, or all, the other virtual terminals. In case you want to be less conservative, you can run kmscon on
tty1
as well.
To enable kmscon on
ttyX
,
enable
kmsconvt@ttyX.service
. As stated in the previous paragraph,
tty1
is unusual in that
getty@tty1.service
is enabled by default. Therefore, it should be
disabled
before using
kmsconvt@tty1.service
. Also note
logind.conf(5) § OPTIONS
sets
NAutoVTs
to 6, by default.
Note
If you are using a
display manager
such as
SDDM
or
GDM
,
add
kmsconvt@tty1.service
to the
Conflicts
and
After
fields of the display manager service file.
To enable kmscon on all virtual terminals,
disable
getty@.service
and
enable
kmsconvt@.service
.
This will make
systemd
to start kmscon instead of agetty on each VT. More precisely, this will make
systemd-logind
use
kmsconvt@.service
instead of
getty@.service
for new VTs. Additionally, all other systemd units that use
getty@.service
will not be affected by this change.
If kmscon cannot start for whatever reason, this unit will cause
getty@.service
to be started instead. Furthermore, if no VTs are available, this unit will not start anything.
Warning
If you have replaced agetty on all terminals, take care to ensure
kmscon
presents you with a prompt before rebooting your machine, otherwise you may have to recover through a live CD.
Tip
You can
enable
getty@tty1.service
and
disable
kmsconvt@tty1.service
after enabling kmscon on all virtual terminals: this will allow the user to start a graphical session from the command line on tty1 while enjoying the benefits of kmscon on the remaining terminals.
Tips and tricks
Switching VT
The familiar
Alt+Fn
key combination will not change into another VT when the current VT is
kmscon
. Only
Ctrl+Alt+Fn
is working in this circumstances.
CJK support
Kmscon supports rendering CJK characters through the default font engine
pango
. However,
fontconfig
has to be
globally
configured to map the monospace font alias to proper CJK fonts. For Chinese users, the following template is provided and proved to result in satisfactory Chinese characters rendering:
/etc/fonts/conf.d/99-kmscon.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match>
        <test name="family"><string>monospace</string></test>
        <edit name="family" mode="prepend" binding="strong">
                <string>DejaVu Sans Mono</string>
                <string>WenQuanYi Micro Hei Mono</string>
        </edit>
</match>
</fontconfig>
Alternatively, we can add the following line to
/etc/kmscon/kmscon.conf
for globally configuring kmscon using the fonts:
/etc/kmscon/kmscon.conf
font-name=DejaVu Sans Mono, WenQuanYi Micro Hei Mono
font-size=14
See
kmscon(1)
.
You need to have
ttf-dejavu
and
wqy-microhei
, both available from the official repositories, installed.
Automatic login
It is possible to login as user
username
automatically without asking for password by adding this to
/etc/kmscon/kmscon.conf
/etc/kmscon/kmscon.conf
# Example: Login as user "
username
" without asking for password
login=/bin/login -p -f
username
Or as user
root
:
/etc/kmscon/kmscon.conf
# Example: Login as root in a bash shell without asking for password
login=/bin/bash --login
HiDPI support
You can change font size on the fly with
Ctrl++
,
Ctrl+Shift+=
,
Ctrl+-
shortcuts. Also you can set
font-dpi
and
font-size
in
/etc/kmscon/kmscon.conf
, e.g.
font-dpi=288
. 96 is the default value, so 96 * 3 is 300% scaling.
Troubleshooting
Root cannot login
If you cannot login as root check
/etc/pam.d/
files, if you have enabled
pam_securetty
. You need to disable the
pam_securetty
module by removing or commenting out the corresponding line eg. in
/etc/pam.d/login
.
Window managers cannot be started from KMS console
Use the
kmscon-launch-gui
wrapper to launch your favourite desktop environment.
Gnome Session does not start
You need to set the wayland type flag for your terminal. Add type=wayland to the pam_systemd.so line in
/etc/pam.d/system-login
Problems with switching between Xorg and kmscon
You may want to add
hwaccel
to
/etc/kmscon/kmscon.conf
if you have problems with switching between
Xorg
and kmscon. Another possibility would be
editing the systemd service file
.
No audio control
As version 7, if you cannot control the audio, add your user to the
audio
user group
. Be aware of the
shortcomings
of this choice.
Vim does not clear terminal output
Vim might open without clearing the terminal output, it is still possible to edit the file but the text will not be visible until it is changed. As a workaround, try setting the
environment variable
TERM=vt220
. Alternatively, another vim-like editor like
Neovim
might work.
Note
Color support is not available if
TERM
is set to
vt220
.