[solve] Weston in kiosk mode with full screen browser

This forum is for discussion about general software issues.

[solve] Weston in kiosk mode with full screen browser

Postby keithspg » Sun Mar 07, 2021 9:35 pm

I want to lanuch weston as a kiosk. It is built in the latest arch package. Since the latest version supports this functionality, I have created a script to launch it and can verify that it does work:
$this->bbcode_second_pass_code('', '# Make sure that $DISPLAY is unset.
unset DISPLAY

# And that $XDG_RUNTIME_DIR has been set and created.
if test -z "${XDG_RUNTIME_DIR}"; then
export XDG_RUNTIME_DIR=/run/weston
if ! test -d "${XDG_RUNTIME_DIR}"; then
mkdir "${XDG_RUNTIME_DIR}"
chmod 0700 "${XDG_RUNTIME_DIR}"1
fi
fi

weston &
sleep 1s # could be less
export WAYLAND_DISPLAY=wayland-0
export DISPLAY=:1
exec /usr/bin/surfer http://localhost')

this works and does exactly what I want. Now I want to launch it as a service file.
I created a service file and am trying to get it to launch but there is a problem with logind and something else, I imagine.
$this->bbcode_second_pass_code('', '[Unit]
Description=Weston Local Browser Kiosk mode
After=network.target

[Service]
Type=simple
User=http
Group=http
RuntimeDirectory=weston
RuntimeDirectoryMode=0700
WorkingDirectory=/srv/http
Environment="HOME=/srv/http"
Environment="XDG_RUNTIME_DIR=/run/weston"
Environment="WAYLAND_DISPLAY=wayland-0"
Environment="DISPLAY=:1"
ExecStart=/usr/bin/weston
ExecStartPost=/usr/bin/sleep 2s ; /usr/bin/surfer http://localhost
ExecStop=/usr/bin/pkill -15 weston
IgnoreSIGPIPE=no
Restart=always
RestartSec=1

[Install]
WantedBy=multi-user.target
')

The journal shows this when it launches:
$this->bbcode_second_pass_code('', 'Mar 07 15:21:17 rune64 weston[2834]: Date: 2021-03-07 CST
Mar 07 15:21:17 rune64 weston[2834]: [15:21:17.601] weston 9.0.0
Mar 07 15:21:17 rune64 weston[2834]: https://wayland.freedesktop.org
Mar 07 15:21:17 rune64 weston[2834]: Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
Mar 07 15:21:17 rune64 weston[2834]: Build: 9.0.0
Mar 07 15:21:17 rune64 weston[2834]: [15:21:17.601] Command line: /usr/bin/weston
Mar 07 15:21:17 rune64 weston[2834]: [15:21:17.601] OS: Linux, 5.10.17-3-ARCH, #1 SMP PREEMPT Wed Mar 3 16:26:04 MST 2021, aarch64
Mar 07 15:21:17 rune64 weston[2834]: [15:21:17.601] Using config file '/srv/http/.config/weston.ini'
Mar 07 15:21:17 rune64 weston[2834]: [15:21:17.602] Output repaint window is 7 ms maximum.
Mar 07 15:21:17 rune64 weston[2834]: [15:21:17.602] Loading module '/usr/lib/libweston-9/fbdev-backend.so'
Mar 07 15:21:17 rune64 weston[2834]: [15:21:17.607] initializing fbdev backend
Mar 07 15:21:17 rune64 weston[2834]: [15:21:17.611] logind: not running in a systemd session
Mar 07 15:21:17 rune64 weston[2834]: [15:21:17.611] logind: cannot setup systemd-logind helper (-61), using legacy fallback
Mar 07 15:21:17 rune64 weston[2834]: [15:21:17.611] fatal: fbdev backend should be run using weston-launch binary, or your system should provide the logind D-Bus API.
Mar 07 15:21:17 rune64 weston[2834]: [15:21:17.611] fatal: failed to create compositor backend
Mar 07 15:21:17 rune64 systemd[1]: local-browser_w.service: Main process exited, code=exited, status=1/FAILURE
Mar 07 15:21:18 rune64 systemd[1]: local-browser_w.service: Control process exited, code=killed, status=15/TERM
Mar 07 15:21:18 rune64 systemd[1]: local-browser_w.service: Failed with result 'exit-code'.
')

I've tried the fbdev and drm backend and get the same error. I do not get the difference between weston-launch and weston. I have a single program I want to run in weston and the script does it, I just need a service file to start and stop it. When I run the script from a vt it works.
Last edited by keithspg on Sun Mar 14, 2021 12:53 am, edited 1 time in total.
keithspg
 
Posts: 221
Joined: Mon Feb 23, 2015 4:14 pm

Re: Request help with wayland/weston systemd service file

Postby keithspg » Sat Mar 13, 2021 4:48 am

I almost got it working. Now I cannot get the service file to return a prompt. it is as if it is waiting to return and I have to ctrl-c to get the prompt back after I send 'systemctl start weston-kiosk.service. It is the ExecStartPost line that is causing the problem. How do I launch the browser after weston is started?

this almost works:
weston-kiosk.service file
$this->bbcode_second_pass_code('', '[Unit]
Description=Weston Local Browser Kiosk mode
After=network.target

[Service]
Type=notify
RuntimeDirectory=weston
RuntimeDirectoryMode=0700
WorkingDirectory=/srv/http
Environment="HOME=/srv/http"
Environment="XDG_RUNTIME_DIR=/run/weston"
Environment="WAYLAND_DISPLAY=wayland-0"
Environment="DISPLAY=:1"
ExecStart=/usr/bin/weston --tty=1 --modules=systemd-notify.so
ExecStartPost=/usr/bin/sleep 2s ; /usr/bin/luakit
ExecStop=/usr/bin/pkill -15 weston
IgnoreSIGPIPE=no
StandardOutput=journal
StandardError=journal
TimeoutSec=infinity

[Install]
WantedBy=multi-user.target')

~.config/weston.ini
$this->bbcode_second_pass_code('', '#kiosk weston ini
[core]
shell=kiosk-shell.so
backend=/usr/lib/libweston-9/fbdev-backend.so
#backend=/usr/lib/libweston-9/drm-backend.so
idle-time=0
[output]
name=WL1
mode=current
transform=normal
scale=1
[input-method]
path=/usr/lib/weston/weston-keyboard
[keyboard]
keymap_model=pc105
keymap_layout=us
vt-switching=true
')

this script will launch it from a vt, but I need it to be able to be launched as a service.
$this->bbcode_second_pass_code('', '# Make sure that $DISPLAY is unset.
unset DISPLAY

# And that $XDG_RUNTIME_DIR has been set and created.
if test -z "${XDG_RUNTIME_DIR}"; then
export XDG_RUNTIME_DIR=/run/weston
if ! test -d "${XDG_RUNTIME_DIR}"; then
mkdir "${XDG_RUNTIME_DIR}"
chmod 0700 "${XDG_RUNTIME_DIR}"1
fi
fi

# Run weston:
weston --tty=1 &
sleep 2s # could be less
export WAYLAND_DISPLAY=wayland-0
export DISPLAY=:1
exec /usr/bin/luakit')
keithspg
 
Posts: 221
Joined: Mon Feb 23, 2015 4:14 pm

Re: Request help with wayland/weston systemd service file

Postby keithspg » Sun Mar 14, 2021 12:52 am

I have a solution:
https://gitlab.freedesktop.org/wayland/ ... ote_830410

this is very specifically for a SBC running a single application(Browser) in weston. Basically, I need 2 service files. When I call the local-browser, it launches weston first then when weston is up, it launches the browser to display our localhost as a sort of 'dashboard'. We are not using logind. There is no user other than root which has a password and can log in. Everything should be running as http:http, but weston wants to be launched as a user with logind managing some of it and we do not have that. Regardless, leveraging some of the systemd capabilities of creating a run directory and using that as our XDG_RUNTIME_DIR, it works.

A couple notes: I am using the fbdev-backend.so and have it running on tty=1 to get it to display on my small 3.5" spitft screen. To use it on the hdmi, you will probably want to use the drm-backend in the weston.ini file and probably have to either remove or edit the tty references in the service files.

local-browser.service
$this->bbcode_second_pass_code('', '[Unit]
Description=launch Local Browser Kiosk mode
After=network.target weston.service
Wants=weston.service

[Service]
Type=simple
#User=http
Group=http
WorkingDirectory=/srv/http
Environment="HOME=/srv/http"
Environment="XDG_RUNTIME_DIR=/run/weston"
Environment="WAYLAND_DISPLAY=wayland-0"
Environment="XDG_SESSION_TYPE=wayland"
Environment="GDK_BACKEND=wayland"
#ExecStart=/usr/bin/luakit --config=/srv/http/.config/luakit/userconf.lua
ExecStart=/usr/bin/luakit
ExecStop=/usr/bin/pkill -15 luakit
ExecStopPost=/usr/bin/pkill -15 weston
TimeoutSec=infinity

[Install]
WantedBy=multi-user.target')
weston.service
$this->bbcode_second_pass_code('', '[Unit]
Description=Weston Kiosk mode
After=network.target

[Service]
Type=notify
#User=http
Group=http
RuntimeDirectory=weston
RuntimeDirectoryMode=0755
Environment="XDG_RUNTIME_DIR=/run/weston"
ExecStart=/usr/bin/weston --tty=1 --log=/var/log/runeaudio/weston.log \
--config=/srv/http/.config/weston.ini --modules=systemd-notify.so
ExecStop=/usr/bin/pkill -15 weston
IgnoreSIGPIPE=no
#Restart=always
#RestartSec=1
StandardOutput=journal
StandardError=journal
TimeoutSec=infinity

[Install]
WantedBy=multi-user.target')
weston.ini
$this->bbcode_second_pass_code('', '# Kiosk mode weston ini
[core]
shell=kiosk-shell.so
backend=/usr/lib/libweston-9/fbdev-backend.so
#backend=/usr/lib/libweston-9/drm-backend.so
idle-time=0
[output]
name=WL1
mode=current
transform=normal
scale=1
#app-ids=1
[input-method]
path=/usr/lib/weston/weston-keyboard
[keyboard]
keymap_model=pc105
keymap_layout=us
vt-switching=true')
keithspg
 
Posts: 221
Joined: Mon Feb 23, 2015 4:14 pm


Return to General

Who is online

Users browsing this forum: No registered users and 6 guests