这依赖于使用键盘的物理访问

这依赖于使用键盘的物理访问

我正在使用 Debian Bullseye。我想以 systemd 服务的用户身份运行 Weston。我需要默认的 drm 后端,因此我认为需要使用 weston-launch 作为 root 启动它。但是,我尝试了多种配置,但无法运行。目前我正在尝试使用 weston-launch,但出现以下错误:

Date: 2023-02-16 CET
[14:32:56.381] weston 9.0.0
               https://wayland.freedesktop.org
               Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
               Build: 9.0.0
[14:32:56.381] Command line: /usr/bin/weston --log=/tmp/weston.log
[14:32:56.381] OS: Linux, 5.10.52-gba9ade6851ca-dirty, #1 SMP PREEMPT Thu Feb 16 10:37:31 UTC 2023, aarch64
[14:32:56.381] Using config file '/etc/xdg/weston/weston.ini'
[14:32:56.382] Output repaint window is 16 ms maximum.
[14:32:56.382] Loading module '/usr/lib/aarch64-linux-gnu/libweston-9/drm-backend.so'
[14:32:56.388] initializing drm backend
[14:32:56.393] logind: cannot take control over session 8
[14:32:56.394] logind: cannot setup systemd-logind helper (-5), using legacy fallback
[14:32:56.397] using /dev/dri/card1
[14:32:56.397] DRM: supports atomic modesetting
[14:32:56.397] DRM: does not support GBM modifiers
[14:32:56.397] DRM: supports picture aspect ratio
[14:32:56.398] Loading module '/usr/lib/aarch64-linux-gnu/libweston-9/g2d-renderer.so'

/lib/systemd/system/weston.service:

[Unit]
Description=Weston Wayland Compositor (on tty7)
RequiresMountsFor=/run
[email protected] plymouth-quit.service
After=systemd-user-sessions.service [email protected] plymouth-quit-wait.service

[Service]
User=root
PermissionsStartOnly=true

# Log us in via PAM so we get our XDG & co. environment and
# are treated as logged in so we can use the tty:
PAMName=login

# Grab tty7
UtmpIdentifier=tty7
TTYPath=/dev/tty7
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes

# stderr to journal so our logging doesn't get thrown into /dev/null
StandardOutput=tty
StandardInput=tty
StandardError=journal

EnvironmentFile=-/etc/default/weston

# Weston does not successfully change VT, nor does systemd place us on
# the VT it just activated for us. Switch manually:
ExecStartPre=/bin/chvt 7
ExecStart=/usr/bin/weston-launch --tty /dev/tty7 --user tavla-run -- --log=/var/log/weston.log $OPTARGS

IgnoreSIGPIPE=no

[Install]
WantedBy=multi-user.target

/etc/profile.d/weston.sh:

if test -z "$XDG_RUNTIME_DIR"; then
    export XDG_RUNTIME_DIR=/run/user/`id -u`
    if ! test -d "${XDG_RUNTIME_DIR}"; then
        mkdir --parents "${XDG_RUNTIME_DIR}"
        chmod 0700 "${XDG_RUNTIME_DIR}"
    fi
fi

/etc/xdg/weston/weston.ini:

[core]
#gbm-format=argb8888
idle-time=0
use-g2d=1
xwayland=true
#drm-device=card0
repaint-window=16
#enable-overlay-view=1

#[shell]
#size=1920x1080

[libinput]
touchscreen_calibrator=true

#[output]
#name=HDMI-A-1
#mode=1920x1080@60
#transform=rotate-90

#[output]
#name=HDMI-A-2
#mode=off
#       WIDTHxHEIGHT    Resolution size width and height in pixels
#       off             Disables the output
#       preferred       Uses the preferred mode
#       current         Uses the current crt controller mode
#transform=rotate-90

[screen-share]
command=@bindir@/weston --backend=rdp-backend.so --shell=fullscreen-shell.so --no-clients-resize

[shell]
background-image=/usr/share/images/desktop-base/default
background-type=scale-crop

答案1

以下是一些文档的快速链接,准确描述了您正在寻找的内容:https://wayland.pages.freedesktop.org/weston/toc/running-weston.html#running-weston-from-a-systemd-service

文档中的示例

这依赖于使用键盘的物理访问

Debian 系统使用/etc/systemd/user/dir 作为 systemd 用户单元。

/etc/systemd/user/weston.socket

[Unit]
Description=Weston, a Wayland compositor
Documentation=man:weston(1) man:weston.ini(5)
Documentation=https://wayland.freedesktop.org/

[Socket]
ListenStream=%t/wayland-0

/etc/systemd/user/weston.service

[Unit]
Description=Weston, a Wayland compositor, as a user service
Documentation=man:weston(1) man:weston.ini(5)
Documentation=https://wayland.freedesktop.org/

# Activate using a systemd socket
Requires=weston.socket
After=weston.socket

# Since we are part of the graphical session, make sure we are started before
Before=graphical-session.target

[Service]
Type=notify
TimeoutStartSec=60
WatchdogSec=20
# Defaults to journal
#StandardOutput=journal
StandardError=journal

# add a ~/.config/weston.ini and weston will pick-it up
ExecStart=/usr/bin/weston

[Install]
WantedBy=graphical-session.target

创建文件后,您想让 systemd 通过运行重新加载更改systemctl --user daemon-reload

如果没有在计算机上创建登录会话,您需要物理登录并启动运行的 westonsystemctl --user start weston

允许以普通用户身份通过​​ VT 或 SSH 登录

此方法需要将服务作为常规 systemd 系统单元运行。

/etc/systemd/system/mysession.service

[Unit]
Description=My graphical session

# Make sure we are started after logins are permitted.
After=systemd-user-sessions.service

# if you want you can make it part of the graphical session
#Before=graphical.target

# not necessary but just in case
#ConditionPathExists=/dev/tty7

[Service]
Type=simple
Environment=XDG_SESSION_TYPE=wayland
ExecStart=/usr/bin/systemctl --wait --user start mysession.target

# The user to run the session as. Pick one!
User=user
Group=user

# Set up a full user session for the user, required by Weston.
PAMName=login

# A virtual terminal is needed.
TTYPath=/dev/tty7
TTYReset=yes
TTYVHangup=yes
TTYVTDisallocate=yes

# Fail to start if not controlling the tty.
StandardInput=tty-fail

# Defaults to journal, in case it doesn't adjust it accordingly
#StandardOutput=journal
StandardError=journal

# Log this user with utmp, letting it show up with commands 'w' and 'who'.
UtmpIdentifier=tty7
UtmpMode=user

[Install]
WantedBy=graphical.target

/etc/systemd/user/mysession.target

[Unit]
Description=My session

BindsTo=mysession.target
Before=mysession.target

执行一些重新加载和 loginctl 的操作

# Reloading the configuration so systemd sees it.
systemctl --user daemon-reload
sudo systemctl daemon-reload

# Starting and testing service.
sudo systemctl start mysession # systemd should ask for a password
loginctl # Verify is mysession was able to do session login
systemctl --user start weston 

相关内容