Thursday, November 30, 2023

Re: wayland/sway: build fix and link to the tree

Matthieu Herrb <matthieu@herrb.eu> writes:
>
> Here's a diff that allows sway to be linked, and patches the default
> config to use xterm (and also installs swaybg to have the default
> wallpaper)
>
> It also adds a startsway.sh script to start sway and updates DESCR
> accordingly

just some nits in startsway.sh

> Note that the build fix was already committed independently.
>
> ok?

else I am fine. ok semarie@

> Index: files/startsway.sh
> ===================================================================
> RCS file: files/startsway.sh
> diff -N files/startsway.sh
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ files/startsway.sh 30 Nov 2023 21:10:29 -0000
> @@ -0,0 +1,13 @@
> +#! /bin/ksh
> +export XDG_RUNTIME_DIR=${HOME}/.local/run
> +if [ ! -d $XDG_RUNTIME_DIR ]; then
> + mkdir -m 700 -p $XDG_RUNTIME_DIR
> +fi

I would be a bit more defensive with env variables, and use
"${XDG_RUNTIME_DIR}" instead of $XDG_RUNTIME.

> +export WLR_DRM_DEVICES=/dev/dri/card0
> +export LIBSEAT_BACKEND=noop
> +
> +# Tell applications to use Wayland
> +# export MOZ_ENABLE_WAYLAND=1 # doesn't work yet
> +export XDG_CURRENT_DESKTOP=sway
> +
> +exec /usr/local/bin/sway $*

and variables should be overridable by the user.



An alternative script could be something like:

#!/bin/ksh
set -eu

: ${XDG_RUNTIME_DIR:=/tmp/run/$(/usr/bin/id -u)}
: ${WLR_DRM_DEVICES:=/dev/dri/card0}
: ${LIBSEAT_BACKEND:=noop}
#: ${MOZ_ENABLE_WAYLAND:=1} # doesn't work yet
: ${XDG_CURRENT_DESKTOP:=sway}

export XDG_RUNTIME_DIR WLR_DRM_DEVICES LIBSEAT_BACKEND CURRENT_DESKTOP

if [ ! -d "${XDG_RUNTIME_DIR}" ]; then
mkdir -m 700 -p "${XDG_RUNTIME_DIR}"
fi

exec /usr/local/bin/sway "$@"


- base id(1) is used (and not random one from PATH)
- the variables are defined to default values if not already present
- [ and mkdir are resistants to spaces inside XDG_RUNTIME
- sway is invoked without losing NULL arguments or splitting arguments
with spaces

Thanks.
--
Sebastien Marie

No comments:

Post a Comment