~mil/sxmo-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
6 6

[PATCH sxmo-utils] Clean up handling of XDG_RUNTIME_DIR

Details
Message ID
<20230405230851.2254962-1-aren@peacevolution.org>
DKIM signature
pass
Download raw message
Patch: +14 -23
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] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CRP798EGUJU3.1B3CTTMQU447B@cirno2>
In-Reply-To
<20230405230851.2254962-1-aren@peacevolution.org> (view parent)
DKIM signature
missing
Download raw message
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]: aren@peacevolution.org

✓ #968911 SUCCESS sxmo-utils/patches/test.yml https://builds.sr.ht/~mil/job/968911
Details
Message ID
<ZC4asl3sa9bHSHmq@durand.trilidun.org>
In-Reply-To
<20230405230851.2254962-1-aren@peacevolution.org> (view parent)
DKIM signature
pass
Download raw message
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.

On Wed, Apr 05, 2023 at 07:08:51PM -0400, ArenM wrote:
>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
>

--
sic dicit magister P
https://phartman.sites.luc.edu/
GPG keyID 0xE0DBD3D6 (CAE6 3A6F 755F 7BC3 36CA  330D B3E6 39C6 E0DB D3D6)
Details
Message ID
<SYBP282MB238238CD069C8609AEF08271F79C9@SYBP282MB2382.AUSP282.PROD.OUTLOOK.COM>
In-Reply-To
<ZC4asl3sa9bHSHmq@durand.trilidun.org> (view parent)
DKIM signature
missing
Download raw message
Gave this a go as per Aren's suggestion, still fails to resolve issue #567
Details
Message ID
<ddrbq5alu6zwa543rawbq5syi6d73kyycltgwxtjuxhde27rpp@q5smd3lpe7mx>
In-Reply-To
<20230405230851.2254962-1-aren@peacevolution.org> (view parent)
DKIM signature
pass
Download raw message
This needs a revision, details below.

On Wed, Apr 05, 2023 at 07:08:51PM -0400, ArenM wrote:
> 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)"

This uses printf formatting but doesn't call printf. I need to fix it to
include the output of $(id -u) directly in the string.

> +	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
> 
Details
Message ID
<CT4UBDPSFHRG.1DI4CQ37F2F3S@yellow-orcess>
In-Reply-To
<ddrbq5alu6zwa543rawbq5syi6d73kyycltgwxtjuxhde27rpp@q5smd3lpe7mx> (view parent)
DKIM signature
pass
Download raw message
Marked as needing revision so
Details
Message ID
<SYBP282MB238260BC9082C89F56B8DD94F755A@SYBP282MB2382.AUSP282.PROD.OUTLOOK.COM>
In-Reply-To
<ZC4asl3sa9bHSHmq@durand.trilidun.org> (view parent)
DKIM signature
missing
Download raw message
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.
Reply to thread Export thread (mbox)