~mil/sxmo-devel

sxmo-utils: Clean up handling of XDG_RUNTIME_DIR v1 NEEDS REVISION

ArenM: 1
 Clean up handling of XDG_RUNTIME_DIR

 1 files changed, 14 insertions(+), 23 deletions(-)
#968911 test.yml success
Gave this a go as per Aren's suggestion, still fails to resolve issue #567
Hi Aren and Willow,

Gave this patch another go on an install not long ago I have freshly installed
and it fixes https://todo.sr.ht/~mil/sxmo-tickets/567

I must have had an old package blocking this before and trying again now fixed
it.
Marked as needing revision so
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~mil/sxmo-devel/patches/40196/mbox | git am -3
Learn more about email & git

[PATCH sxmo-utils] Clean up handling of XDG_RUNTIME_DIR Export this patch

Previously if we detected that sxmo was not running, we would unset
XDG_RUNTIME_DIR. This prevents anyone from having sxmo installed but not
using it.
---
 configs/profile.d/sxmo_init.sh | 37 +++++++++++++---------------------
 1 file changed, 14 insertions(+), 23 deletions(-)

diff --git a/configs/profile.d/sxmo_init.sh b/configs/profile.d/sxmo_init.sh
index fdf5dd9..dcd6760 100644
--- a/configs/profile.d/sxmo_init.sh
+++ b/configs/profile.d/sxmo_init.sh
@@ -9,9 +9,9 @@
_sxmo_is_running() {
	unset SXMO_WM

	if [ -f "${XDG_RUNTIME_DIR}"/sxmo.swaysock ]; then
	if [ -f "${_RUNTIME_DIR}"/sxmo.swaysock ]; then
		unset SWAYSOCK
		if SWAYSOCK="$(cat "${XDG_RUNTIME_DIR}"/sxmo.swaysock)" \
		if SWAYSOCK="$(cat "${_RUNTIME_DIR}"/sxmo.swaysock)" \
			swaymsg 2>/dev/null; then
			printf "Detected the Sway environment\n" >&2
			export SXMO_WM=sway
@@ -29,22 +29,6 @@ _sxmo_is_running() {
	return 1
}

_sxmo_find_runtime_dir() {
	# Take what we gave to you
	if [ -n "$XDG_RUNTIME_DIR" ]; then
		printf %s "$XDG_RUNTIME_DIR"
		return
	fi

	if [ -d "/var/run/user/$(id -u)" ]; then
		printf "/var/run/user/%s" "$(id -u)"
		return
	fi

	# Fallback to a shared memory location
	printf "/dev/shm/user/%s" "$(id -u)"
}

_sxmo_load_environments() {
	# Determine current operating system see os-release(5)
	# https://www.linux.org/docs/man5/os-release.html
@@ -60,8 +44,6 @@ _sxmo_load_environments() {
	export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
	export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
	export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
	XDG_RUNTIME_DIR="$(_sxmo_find_runtime_dir)"
	export XDG_RUNTIME_DIR
	export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
	export XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"

@@ -124,13 +106,22 @@ $PATH"
}

_sxmo_grab_session() {
	XDG_RUNTIME_DIR="$(_sxmo_find_runtime_dir)"
	export XDG_RUNTIME_DIR
	if [ -n "$XDG_RUNTIME_DIR" ]; then
		_RUNTIME_DIR="$XDG_RUNTIME_DIR"
	elif [ -d "/var/run/user/$(id -u)" ]; then
		_RUNTIME_DIR="/var/run/user/%s" "$(id -u)"
	else
		_RUNTIME_DIR="/dev/shm/user/%s" "$(id -u)"
	fi

	if ! _sxmo_is_running; then
		unset XDG_RUNTIME_DIR
		unset _RUNTIME_DIR
		return
	fi

	export XDG_RUNTIME_DIR="$_RUNTIME_DIR"
	unset _RUNTIME_DIR

	_sxmo_load_environments

	if [ -f "$XDG_RUNTIME_DIR"/dbus.bus ]; then
-- 
2.39.2




sxmo-utils/patches/test.yml: SUCCESS in 55s

[Clean up handling of XDG_RUNTIME_DIR][0] from [ArenM][1]

[0]: https://lists.sr.ht/~mil/sxmo-devel/patches/40196
[1]: mailto:aren@peacevolution.org

✓ #968911 SUCCESS sxmo-utils/patches/test.yml https://builds.sr.ht/~mil/job/968911
Thanks!

I'm actually in the middle of rewriting this (as part of a more general 
rewrite of our init scripts). If I bail on this rewrite project, I'll 
look into merging this.
This needs a revision, details below.