Utilities for running Avalonia apps on Linux DRM/Framebuffer: evdev keyboard (EN/RU, Alt+Shift, CapsLock), on-screen keyboard, soft cursor with auto-hide and pointerover fix, evdev mouse fallback.
$ dotnet add package DrmKit.AvaloniaHelpers for running Avalonia apps directly on Linux DRM/Framebuffer (kiosk / embedded, no X11 / Wayland).
KeyboardOverlay) for touch UI;SmartPlatform — runtime switch: DRM ↔ desktop with CLI options.Main namespace:
Avalonia.DrmKit
Recommended: Avalonia 11, .NET 8, Linux with/dev/dri/card*and/dev/input/event*.
dotnet add package DrmKit.Avalonia
Program.cs:
using Avalonia;
using Avalonia.DrmKit;
internal static class Program
{
public static int Main(string[] args)
=> SmartPlatform.Start(BuildAvaloniaApp(), args);
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.UseReactiveUI()
.UseDrmSoftCursor() // soft cursor overlay for DRM
.UseLinuxKeyboardListener() // evdev keyboard (EN/RU, Alt+Shift, CapsLock)
.UseEvdevMouseFallback(); // evdev mouse + pointerover fix for DRM
}
Run in DRM mode:
# user should be in 'video' and 'input' groups
./YourApp --system=drm --drm=card1 --resolution=1280x720
# debug evdev input
DRMKIT_DEBUG=1 ./YourApp --system=drm --drm=card1
If DRM cannot be initialized, SmartPlatform falls back to the standard Avalonia desktop backend.
Attach overlay keyboard to any TextBox:
<TextBox
xmlns:osk="clr-namespace:Avalonia.DrmKit.OnScreenKeyboard;assembly=Avalonia.DrmKit"
osk:KeyboardOverlay.IsEnabled="True"
Watermark="Tap to enter text" />
Behaviour:
TextBox with KeyboardOverlay.IsEnabled="True" receives focus,
a shared on‑screen keyboard panel appears at the bottom of the main window;TextBox controls, the keyboard hides;Layouts:
UseDrmSoftCursor() adds an overlay layer that renders a software cursor on top of the window.
Features:
PointerEntered / PointerExited / PointerMoved for Avalonia controls;Example style in App.axaml:
<Application.Styles>
<Style Selector="t|SoftCursorLayer">
<Setter Property="AutoHideDelay" Value="0:0:3" /> <!-- idle timeout -->
<Setter Property="StrokeBrush" Value="White" />
<Setter Property="FillBrush" Value="#80FFFFFF" />
<Setter Property="PressedFillBrush" Value="#C0FFFFFF" />
</Style>
</Application.Styles>To fully replace visuals (text, image, custom shape), set
DisableDefaultRendering="True" and provide your own Template or Content.
SmartPlatform understands several useful command‑line options:
--system=auto|drm|desktop
--drm=card0|card1|/dev/dri/card1|1
--resolution=1280x720Typical DRM run:
./YourApp --system=drm --drm=card0 --resolution=1920x1080If no DRM card is found (no /dev/dri/card*), the library automatically starts
the regular Avalonia desktop backend instead.
SmartPlatform.Start(...) + три extension‑метода
для AppBuilder.On-screen keyboard (KeyboardOverlay):
Tab focus by default;Esc hides overlay without rollback;Cancel on overlay keyboard.Useful attached properties:
osk:KeyboardOverlay.OpenOnProgrammaticFocus (default: False)osk:KeyboardOverlay.OpenOnKeyboardFocus (default: False)osk:KeyboardOverlay.InputGateTimeoutMs (default: 300)DRM keyboard backend (DrmKeyboardOptions) defaults:
UseRoutedControlKeys = trueEnableRawControlKeysFallback = falseTabAsNavigation = trueEnterAsTextFallback = false