summaryrefslogtreecommitdiff
path: root/.config/login.d
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-04-13 17:10:00 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-04-13 17:10:00 -0400
commit39db29c39dcca6d47fbc56dffd8c0c7bf63beb51 (patch)
treec769eba9bb2da4cf6eca0421992736841bf8f8d6 /.config/login.d
parentf181c08119e7bf00ce6520331afb737321f350ad (diff)
parent39c0d7a5c7538350e96fc135147f56cdb7d45093 (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to '.config/login.d')
-rw-r--r--.config/login.d/01_xdg.sh31
-rw-r--r--.config/login.d/02_tmpdir.sh2
-rw-r--r--.config/login.d/02_xdg_runtime_dir.sh28
-rw-r--r--.config/login.d/03_tmpdir.sh4
-rw-r--r--.config/login.d/90_dot-runtime.sh4
-rw-r--r--.config/login.d/90_symlink_xdg_runtime_dir.sh6
6 files changed, 42 insertions, 33 deletions
diff --git a/.config/login.d/01_xdg.sh b/.config/login.d/01_xdg.sh
index 4464764..22bbc01 100644
--- a/.config/login.d/01_xdg.sh
+++ b/.config/login.d/01_xdg.sh
@@ -9,35 +9,12 @@
[ -n "$XDG_DATA_DIRS" ] || export XDG_DATA_DIRS="/usr/local/share/:/usr/share/"
[ -n "$XDG_CONFIG_DIRS" ] || export XDG_CONFIG_DIRS="/etc/xdg"
[ -n "$XDG_CACHE_HOME" ] || export XDG_CACHE_HOME="$HOME/.cache"
+[ -n "$XDG_VTNR" ] || export XDG_VTNR="$(tty 2>/dev/null | sed -n 's,^/dev/tty,,p')"
+
+# Check if XDG_VTNR got set to empty
+[ -n "$XDG_VTNR" ] || unset XDG_VTNR
# Check if XDG_RUNTIME_DIR is set, but has a bogus setting
if [ -n "$XDG_RUNTIME_DIR" ] && [ ! -d "$XDG_RUNTIME_DIR" ]; then
unset XDG_RUNTIME_DIR
fi
-
-# Set XDG_RUNTIME_DIR if we can
-if [ -z "$XDG_RUNTIME_DIR" ] && type flock &>/dev/null; then
- _diy_xdg_runtime_login() {
- export XDG_RUNTIME_DIR="$XDG_CACHE_HOME/xdg-runtime-dir/$HOSTNAME"
- # There's a race condition here, between the `ln -s` and `flock`.
- # But it's not like I'll be hammering a box with logins.
- if [ ! -d "$XDG_RUNTIME_DIR" ]; then
- local tmp="$(mktemp -d --tmpdir -- "${USER}@${HOSTNAME}-runtime.XXXXXXXXXX")"
- mkdir -p -- "$XDG_CACHE_HOME/xdg-runtime-dir"
- ln -sfT -- "$tmp" "$XDG_RUNTIME_DIR"
- fi
- if ! [ /dev/fd/7 -ef "$XDG_CACHE_HOME/xdg-runtime-dir/.lock" ]; then
- exec 7>"$XDG_CACHE_HOME/xdg-runtime-dir/.lock"
- if flock -sn 7; then
- # Unfortunately this doesn't survive across exec(1).
- trap _diy_xdg_runtime_logout EXIT
- fi
- fi
- }
- _diy_xdg_runtime_logout() {
- if flock -xn 7; then
- rm -rf -- "$(readlink "$XDG_RUNTIME_DIR")"
- fi
- }
- _diy_xdg_runtime_login
-fi
diff --git a/.config/login.d/02_tmpdir.sh b/.config/login.d/02_tmpdir.sh
deleted file mode 100644
index c0d5f18..0000000
--- a/.config/login.d/02_tmpdir.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-mkdir -p -- "$XDG_RUNTIME_DIR/tmpdir"
-export TMPDIR="$XDG_RUNTIME_DIR/tmpdir"
diff --git a/.config/login.d/02_xdg_runtime_dir.sh b/.config/login.d/02_xdg_runtime_dir.sh
new file mode 100644
index 0000000..6d93359
--- /dev/null
+++ b/.config/login.d/02_xdg_runtime_dir.sh
@@ -0,0 +1,28 @@
+# This should be readable by /bin/sh
+
+# Set XDG_RUNTIME_DIR if we can
+if [ -z "$XDG_RUNTIME_DIR" ] && shopt -q login_shell && type flock &>/dev/null; then
+ _diy_xdg_runtime_login() {
+ export XDG_RUNTIME_DIR="$XDG_CACHE_HOME/xdg-runtime-dir/$HOSTNAME"
+ # There's a race condition here, between the `ln -s` and `flock`.
+ # But it's not like I'll be hammering a box with logins.
+ if [ ! -d "$XDG_RUNTIME_DIR" ]; then
+ local tmp="$(mktemp -d --tmpdir -- "${USER}@${HOSTNAME}-runtime.XXXXXXXXXX")"
+ mkdir -p -- "$XDG_CACHE_HOME/xdg-runtime-dir"
+ ln -sfT -- "$tmp" "$XDG_RUNTIME_DIR"
+ fi
+ if ! [ /dev/fd/7 -ef "$XDG_CACHE_HOME/xdg-runtime-dir/.lock" ]; then
+ exec 7>"$XDG_CACHE_HOME/xdg-runtime-dir/.lock"
+ if flock -sn 7; then
+ # Unfortunately this doesn't survive across exec(1).
+ trap _diy_xdg_runtime_logout EXIT
+ fi
+ fi
+ }
+ _diy_xdg_runtime_logout() {
+ if flock -xn 7; then
+ rm -rf -- "$(readlink "$XDG_RUNTIME_DIR")"
+ fi
+ }
+ _diy_xdg_runtime_login
+fi
diff --git a/.config/login.d/03_tmpdir.sh b/.config/login.d/03_tmpdir.sh
new file mode 100644
index 0000000..b94ef1a
--- /dev/null
+++ b/.config/login.d/03_tmpdir.sh
@@ -0,0 +1,4 @@
+if [ -n "$XDG_RUNTIME_DIR" ]; then
+ mkdir -p -- "$XDG_RUNTIME_DIR/tmpdir"
+ export TMPDIR="$XDG_RUNTIME_DIR/tmpdir"
+fi
diff --git a/.config/login.d/90_dot-runtime.sh b/.config/login.d/90_dot-runtime.sh
deleted file mode 100644
index 87d30ec..0000000
--- a/.config/login.d/90_dot-runtime.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-# This is really only needed for ssh ControlPath; as I don't have a
-# way to communicate XD
-mkdir -p -- ~/.runtime
-ln -sfT -- "$XDG_RUNTIME_DIR" ~/.runtime/"$HOSTNAME"
diff --git a/.config/login.d/90_symlink_xdg_runtime_dir.sh b/.config/login.d/90_symlink_xdg_runtime_dir.sh
new file mode 100644
index 0000000..bc6109d
--- /dev/null
+++ b/.config/login.d/90_symlink_xdg_runtime_dir.sh
@@ -0,0 +1,6 @@
+# This is really only needed for ssh ControlPath; as I don't have a
+# way to communicate XDG_RUNTIME_DIR
+if [ -n "$XDG_RUNTIME_DIR" ]; then
+ mkdir -p -- "$XDG_CACHE_HOME/xdg-runtime-dir"
+ ln -sfT -- "$XDG_RUNTIME_DIR" "$XDG_CACHE_HOME/xdg-runtime-dir/$HOSTNAME"
+fi