summaryrefslogtreecommitdiff
path: root/.config/login.d
diff options
context:
space:
mode:
Diffstat (limited to '.config/login.d')
-rw-r--r--.config/login.d/01_locale.sh3
-rw-r--r--.config/login.d/01_xdg.sh7
-rw-r--r--.config/login.d/02_tmpdir.sh24
-rw-r--r--.config/login.d/10_goroot.sh3
-rw-r--r--.config/login.d/10_selected-editor.sh4
-rw-r--r--.config/login.d/90_dot-runtime.sh3
6 files changed, 36 insertions, 8 deletions
diff --git a/.config/login.d/01_locale.sh b/.config/login.d/01_locale.sh
new file mode 100644
index 0000000..2e4f3c4
--- /dev/null
+++ b/.config/login.d/01_locale.sh
@@ -0,0 +1,3 @@
+if { [[ $LANG = C ]] || [[ -z $LANG ]]; } && grep '^en_US.UTF-8\s' /etc/locale.gen &>/dev/null; then
+ export LANG=en_US.UTF-8
+fi
diff --git a/.config/login.d/01_xdg.sh b/.config/login.d/01_xdg.sh
index 2e0b42c..07cea90 100644
--- a/.config/login.d/01_xdg.sh
+++ b/.config/login.d/01_xdg.sh
@@ -20,16 +20,15 @@ fi
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"
- readonly XDG_RUNTIME_DIR
# 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_CACHE_HOME" ]]; then
- local tmp="$(mktemp --tmpdir -- "${USER}@${HOSTNAME}-runtime.XXXXXXXXXX")"
+ 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"
+ exec 7>"$XDG_CACHE_HOME/xdg-runtime-dir/.lock"
fi
if flock -sn 7; then
trap _diy_xdg_runtime_logout EXIT
diff --git a/.config/login.d/02_tmpdir.sh b/.config/login.d/02_tmpdir.sh
index d0079aa..293064e 100644
--- a/.config/login.d/02_tmpdir.sh
+++ b/.config/login.d/02_tmpdir.sh
@@ -1,3 +1,21 @@
-mkdir -p -- "$XDG_RUNTIME_DIR/tmpdir"
-export TMPDIR="$XDG_RUNTIME_DIR/tmpdir"
-ln -sfT -- "$TMPDIR" "$HOME/tmp"
+if [[ ! -d "$HOME/tmp/$HOSTNAME" ]]; then
+ tmp="$(mktemp --tmpdir -d "$USER@$HOSTNAME-tmpdir.XXXXXXXXXXXXXXXXXXX")"
+ mkdir -p -- "$HOME/tmp"
+ ln -sf "$tmp" "$HOME/tmp/$HOSTNAME"
+ unset tmp
+fi
+export TMPDIR="$HOME/tmp/$HOSTNAME"
+if type flock &>/dev/null; then
+ if [[ "$(readlink -f /dev/fd/7)" != "$(readlink -f "$TMPDIR/.uselock")" ]]; then
+ exec 7>"$TMPDIR/.uselock"
+ fi
+ if flock -sn 7; then
+ _logout_tmpdir_cleanup() {
+ if flock -xn 7; then
+ rm -rf -- "$(readlink -f "$TMPDIR")"
+ rm -- "$TMPDIR"
+ fi
+ }
+ trap _logout_tmpdir_cleanup EXIT
+ fi
+fi
diff --git a/.config/login.d/10_goroot.sh b/.config/login.d/10_goroot.sh
new file mode 100644
index 0000000..89d1037
--- /dev/null
+++ b/.config/login.d/10_goroot.sh
@@ -0,0 +1,3 @@
+if [[ -z $GOROOT ]]; then
+ export GOROOT=/homes/shumakl/.prefix.$(uname -m)/go
+fi
diff --git a/.config/login.d/10_selected-editor.sh b/.config/login.d/10_selected-editor.sh
index f176b8a..c1c18fb 100644
--- a/.config/login.d/10_selected-editor.sh
+++ b/.config/login.d/10_selected-editor.sh
@@ -1,3 +1,7 @@
+# PAM seems to be setting EDITOR...
+if [[ $EDITOR = /usr/bin/vi ]]; then
+ unset EDITOR
+fi
if [[ -f "$HOME/.selected_editor" ]]; then
. "$HOME/.selected_editor"
export SELECTED_EDITOR
diff --git a/.config/login.d/90_dot-runtime.sh b/.config/login.d/90_dot-runtime.sh
index d597cc7..fb7ecd6 100644
--- a/.config/login.d/90_dot-runtime.sh
+++ b/.config/login.d/90_dot-runtime.sh
@@ -1 +1,2 @@
-ln -sfT -- "$XDG_RUNTIME_DIR" ~/.runtime
+mkdir -p -- ~/.runtime
+ln -sfT -- "$XDG_RUNTIME_DIR" ~/.runtime/"$HOSTNAME"