- # make runtime dir in our session-specific tmpdir
- export XDG_RUNTIME_DIR=$TMPDIR/.xdg.runtime
- # same as in tmpdir creation, ensure dir doesn't exist
- if [[ -h $XDG_RUNTIME_DIR ]] {
- unlink $XDG_RUNTIME_DIR 2>/dev/null
- } elif [[ -e $XDG_RUNTIME_DIR ]] {
- rm -rf $XDG_RUNTIME_DIR 2>/dev/null
+ if [[ -v XDG_RUNTIME_DIR ]] {
+ export XDG_RUNTIME_DIR
+ } else {
+ # make runtime dir in our session-specific tmpdir
+ export XDG_RUNTIME_DIR=$TMPDIR/.xdg.runtime
+ # same as in tmpdir creation, ensure dir doesn't exist
+ if [[ -h $XDG_RUNTIME_DIR ]] {
+ unlink $XDG_RUNTIME_DIR 2>/dev/null
+ } elif [[ -e $XDG_RUNTIME_DIR ]] {
+ rm -rf $XDG_RUNTIME_DIR 2>/dev/null
+ }
+ mkdir -m700 $XDG_RUNTIME_DIR 2>/dev/null