Robert Cranston authored on 06/06/2026 11:06:46
Showing 1 changed files
... ...
@@ -1,11 +1,47 @@
1 1
 i3 &
2
-I3_PID="$!"
2
+i3_pid="$!"
3 3
 
4
-while ! [ -e "/run/user/1000/i3/ipc-socket.$I3_PID" ]
4
+# TODO: We still get the error:
5
+#   i3: Could not mkdir(/run/user/1000/i3): File exists
6
+#   i3: Check permissions of $XDG_RUNTIME_DIR = '/run/user/1000'
7
+# sometimes. Look into it. Might be fixed in new version? We often shut down
8
+# with a manual `systemctl poweroff` from within i3 (i.e. while it's still
9
+# running), might that be the problem?
10
+
11
+# Spinlock until `i3` has initialized the IPC socket and set the
12
+# `I3_SOCKET_PATH` property of the X11 root window that other xsession programs
13
+# might require. If `i3` fails for some reason, retrieve its exit code and exit
14
+# ourselves with it.
15
+# <https://i3wm.org/docs/ipc.html>
16
+while ! i3 --get-socketpath > '/dev/null'
5 17
 do
6
-  if ! [ "$(ps -p "$I3_PID" -o pid=)" ]
18
+  # TODO: If the last started background job (`%%`, i.e. `i3 &`) exited (`!
19
+  # jobs %%`) we want to get its exit status (`wait %%`). This seems to not be
20
+  # the way to do it though, since in the case where the job did exit, the
21
+  # `wait %%` gives "wait: No current job". Do some research, it must be
22
+  # possible to get the exit status of the last started job. Would it work to
23
+  # just use `$i3_pid` instead of `%%`?
24
+  if ! jobs %% > '/dev/null' 2>&1
7 25
   then
8
-    wait "$I3_PID"
26
+    wait %%
9 27
     exit $?
10 28
   fi
11 29
 done
30
+
31
+# while ! i3 --get-socketpath > '/dev/null'
32
+# do
33
+#   if ! kill -0 "$i3_pid" > '/dev/null' 2>&1
34
+#   then
35
+#     wait "$i3_pid"
36
+#     exit $?
37
+#   fi
38
+# done
39
+
40
+# while ! [ -e "${XDG_RUNTIME_DIR:-"/run/user/$(id -u)"}/i3/ipc-socket.$i3_pid" ]
41
+# do
42
+#   if ! [ "$(ps -p "$i3_pid" -o pid=)" ]
43
+#   then
44
+#     wait "$i3_pid"
45
+#     exit $?
46
+#   fi
47
+# done
Robert Cranston authored on 06/06/2026 11:06:38
Showing 1 changed files
... ...
@@ -1,10 +1,7 @@
1 1
 i3 &
2 2
 I3_PID="$!"
3 3
 
4
-# Running `i3 --get-socketpath` seems to interfere with the startup of the `i3`
5
-# running in the background.
6
-# while ! i3 --get-socketpath > '/dev/null'
7
-while ! [ -e '/run/user/1000/i3/ipc-socket.'* ]
4
+while ! [ -e "/run/user/1000/i3/ipc-socket.$I3_PID" ]
8 5
 do
9 6
   if ! [ "$(ps -p "$I3_PID" -o pid=)" ]
10 7
   then
Browse code

Add dotfiles

Robert Cranston authored on 13/02/2022 02:03:57
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,14 @@
1
+i3 &
2
+I3_PID="$!"
3
+
4
+# Running `i3 --get-socketpath` seems to interfere with the startup of the `i3`
5
+# running in the background.
6
+# while ! i3 --get-socketpath > '/dev/null'
7
+while ! [ -e '/run/user/1000/i3/ipc-socket.'* ]
8
+do
9
+  if ! [ "$(ps -p "$I3_PID" -o pid=)" ]
10
+  then
11
+    wait "$I3_PID"
12
+    exit $?
13
+  fi
14
+done