diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/.bashrc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/misc/.bashrc b/misc/.bashrc index 115dab5..95079eb 100644 --- a/misc/.bashrc +++ b/misc/.bashrc @@ -208,6 +208,26 @@ export QT_IM_MODULE=ibus #fix small vlc interface export QT_AUTO_SCREEN_SCALE_FACTOR=0 +# ensure $XDG_RUNTIME_DIR is set +if [ -z "$XDG_RUNTIME_DIR" ]; then # It's not already set + XDG_RUNTIME_DIR=/run/user/$UID # Try systemd created path + if [ ! -d "$XDG_RUNTIME_DIR" ]; then + # systemd-created directory doesn't exist + XDG_RUNTIME_DIR=/tmp/$USER-runtime + if [ ! -d "$XDG_RUNTIME_DIR" ]; then # Doesn't already exist + mkdir -m 0700 "$XDG_RUNTIME_DIR" + fi + fi +fi +# Check dir has got the correct type, ownership, and permissions +if ! [[ -d "$XDG_RUNTIME_DIR" && -O "$XDG_RUNTIME_DIR" && + "$(stat -c '%a' "$XDG_RUNTIME_DIR")" = 700 ]]; then + echo "\$XDG_RUNTIME_DIR: permissions problem with $XDG_RUNTIME_DIR:" >&2 + ls -ld "$XDG_RUNTIME_DIR" >&2 + XDG_RUNTIME_DIR=$(mktemp -d /tmp/"$USER"-runtime-XXXXXX) + echo "Set \$XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR" >&2 +fi + # start the agent automatically and make sure that only one # ssh-agent process runs at a time if ! pgrep -u "$USER" ssh-agent > /dev/null; then |