]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
weston-init: Allow weston user to be specified
authorJoshua Watt <JPEWhacker@gmail.com>
Wed, 15 Oct 2025 16:04:38 +0000 (10:04 -0600)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 16 Oct 2025 09:53:06 +0000 (10:53 +0100)
Adds variables to set the name of the weston user (defaulting to
"weston") and the home directory (defaulting to "/home/weston"). This
allows users to easily change which user the compositor runs as.

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-graphics/wayland/weston-init.bb
meta/recipes-graphics/wayland/weston-init/weston-socket.sh
meta/recipes-graphics/wayland/weston-init/weston.service
meta/recipes-graphics/wayland/weston-init/weston.socket

index fc817d113fede90fc322ac0cd7dd465af62f0722..e236bdb253e64e2d46670531523461288e5c9b14 100644 (file)
@@ -25,6 +25,8 @@ PACKAGECONFIG[use-pixman] = ",,"
 
 DEFAULTBACKEND ??= ""
 DEFAULTBACKEND:qemuall ?= "drm"
+WESTON_USER ??= "weston"
+WESTON_USER_HOME ??= "/home/${WESTON_USER}"
 
 do_install() {
        # Install weston-start script
@@ -41,10 +43,15 @@ do_install() {
                install -D -p -m0644 ${S}/weston.service ${D}${systemd_system_unitdir}/weston.service
                install -D -p -m0644 ${S}/weston.socket ${D}${systemd_system_unitdir}/weston.socket
                install -D -p -m0644 ${S}/weston-socket.sh ${D}${sysconfdir}/profile.d/weston-socket.sh
-               sed -i -e s:/etc:${sysconfdir}:g \
-                       -e s:/usr/bin:${bindir}:g \
-                       -e s:/var:${localstatedir}:g \
-                       ${D}${systemd_system_unitdir}/weston.service
+               sed -i -e s:@sysconfdir@:${sysconfdir}:g \
+                       -e s:@bindir@:${bindir}:g \
+                       -e s:@localstatedir@:${localstatedir}:g \
+                       -e s:@runtimedir@:${runtimedir}:g \
+                       -e s:@WESTON_USER@:${WESTON_USER}:g \
+                       -e s:@WESTON_USER_HOME@:${WESTON_USER_HOME}:g \
+                       ${D}${systemd_system_unitdir}/weston.service \
+                       ${D}${systemd_system_unitdir}/weston.socket \
+                       ${D}${sysconfdir}/profile.d/weston-socket.sh
        fi
 
        if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then
@@ -70,7 +77,7 @@ do_install() {
                sed -i -e "/^\[core\]/a use-pixman=true" ${D}${sysconfdir}/xdg/weston/weston.ini
        fi
 
-       install -dm 755 -o weston -g weston ${D}/home/weston
+       install -dm 755 -o ${WESTON_USER} -g ${WESTON_USER} ${D}/${WESTON_USER_HOME}
 }
 
 INHIBIT_UPDATERCD_BBCLASS = "${@oe.utils.conditional('VIRTUAL-RUNTIME_init_manager', 'systemd', '1', '', d)}"
@@ -95,11 +102,11 @@ FILES:${PN} += "\
     ${systemd_system_unitdir}/weston.socket \
     ${sysconfdir}/default/weston \
     ${sysconfdir}/pam.d/ \
-    /home/weston \
+    ${WESTON_USER_HOME} \
     "
 
 CONFFILES:${PN} += "${sysconfdir}/xdg/weston/weston.ini ${sysconfdir}/default/weston"
 
 SYSTEMD_SERVICE:${PN} = "weston.service weston.socket"
-USERADD_PARAM:${PN} = "--home /home/weston --shell /bin/sh --user-group -G video,input,render,seat,wayland weston"
+USERADD_PARAM:${PN} = "--home ${WESTON_USER_HOME} --shell /bin/sh --user-group -G video,input,render,seat,wayland ${WESTON_USER}"
 GROUPADD_PARAM:${PN} = "-r wayland; -r render; -r seat"
index 86389d63a3b1c3b159f7a9a789665a8757678365..8f652862daa5cf867884cb9add9789b3575dc5bb 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 # set weston variables for use with global weston socket
-global_socket="/run/wayland-0"
+global_socket="@runtimedir@/wayland-0"
 if [ -e "$global_socket" ]; then
        weston_group=$(stat -c "%G" "$global_socket")
        if [ "$(id -u)" = "0" ]; then
index 80745998ed20c6776a1149e59f934a307e802124..b7e845e88de2b1df40480096827adf7b47e6e336 100644 (file)
@@ -33,19 +33,19 @@ ConditionPathExists=/dev/tty0
 [Service]
 # Requires systemd-notify.so Weston plugin.
 Type=notify
-EnvironmentFile=/etc/default/weston
-ExecStart=/usr/bin/weston --modules=systemd-notify.so
+EnvironmentFile=@sysconfdir@/default/weston
+ExecStart=@bindir@/weston --modules=systemd-notify.so
 
 # Optional watchdog setup
 #TimeoutStartSec=60
 #WatchdogSec=20
 
 # The user to run Weston as.
-User=weston
-Group=weston
+User=@WESTON_USER@
+Group=@WESTON_USER@
 
 # Make sure the working directory is the users home directory
-WorkingDirectory=/home/weston
+WorkingDirectory=@WESTON_USER_HOME@
 
 # Set up a full user session for the user, required by Weston.
 PAMName=weston-autologin
index c1bdc83c05dfabedd78d83144f97c965c745738c..a7d461ee3040316fb2c3b2899dad60124cc4eefa 100644 (file)
@@ -1,11 +1,11 @@
 [Unit]
 Description=Weston socket
-RequiresMountsFor=/run
+RequiresMountsFor=@runtimedir@
 
 [Socket]
-ListenStream=/run/wayland-0
+ListenStream=@runtimedir@/wayland-0
 SocketMode=0775
-SocketUser=weston
+SocketUser=@WESTON_USER@
 SocketGroup=wayland
 RemoveOnStop=yes