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
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
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)
Gave this a go as per Aren's suggestion, still fails to resolve issue #567
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
>
Marked as needing revision so
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.