blob: 0dbeb28e1bbccce778f6e62c3c7578125fd07759 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
From ad6b44cda0c8cc509abaff2634196b6edea66e13 Mon Sep 17 00:00:00 2001
From: ArenM <aren@peacevolution.org>
Date: Wed, 5 Apr 2023 18:55:53 -0400
Subject: [PATCH sxmo-utils 9/9] Simplify handling of XDG_RUNTIME_DIR
Previously if this detected that sxmo was not running, it would unset
XDG_RUNTIME_DIR. This would prevent anyone from having sxmo installed
but not using it.
---
configs/profile.d/sxmo_init.sh | 36 +++++++++++++---------------------
1 file changed, 14 insertions(+), 22 deletions(-)
diff --git a/configs/profile.d/sxmo_init.sh b/configs/profile.d/sxmo_init.sh
index fdf5dd9..a8bb2e2 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,7 +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 +107,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
|