diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2023-01-27 17:16:42 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2023-01-27 17:33:44 -0700 |
commit | 29cff70c83e7b614055cbb01965a5177e99272a5 (patch) | |
tree | c7e5ff10fc6902dc4dcf0c22b8550c8fae650029 | |
parent | c53e87f671cffded00719a747ba339fc8708dc8f (diff) | |
download | dotfiles-29cff70c83e7b614055cbb01965a5177e99272a5.tar.gz |
emacsclient wrapper: check whether /run/user/$(id -u) exists
-rwxr-xr-x | bin/emacsclient | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/bin/emacsclient b/bin/emacsclient index cb371608..928badb2 100755 --- a/bin/emacsclient +++ b/bin/emacsclient @@ -27,6 +27,7 @@ want_installed=false want_eval=false want_version=false timeout= +euid= devel_running=false installed_running=false make= @@ -182,16 +183,23 @@ done # -sgdbmacs implies --spw/installed, as a special case. [ "$daemon_name" = gdbmacs ] && want_installed=true -# We set and export XDG_RUNTIME_DIR such that Emacs doesn't choose -# "/tmp/emacs$(id -u)" as the socket dir. +# We set and export XDG_RUNTIME_DIR such that Emacs doesn't choose a directory +# under /tmp as the socket directory. However, if /run/user/$(id -u) does not +# already exist, then we probably don't have permission to create it. if [ -n "$XDG_RUNTIME_DIR" ]; then was_set=true + socket_dir="$XDG_RUNTIME_DIR/emacs/" + locks_dir="$XDG_RUNTIME_DIR/spw_emacsclient/" +elif [ -d "/run/user/${euid:=$(id -u)}" ]; then + was_set=false + export XDG_RUNTIME_DIR="/run/user/$euid" + socket_dir="$XDG_RUNTIME_DIR/emacs/" + locks_dir="$XDG_RUNTIME_DIR/spw_emacsclient/" else was_set=false - export XDG_RUNTIME_DIR=/run/user/$(id -u) + socket_dir="${TMPDIR:-/tmp}/emacs$euid/" + locks_dir="${socket_dir}spw_emacsclient/" fi -socket_dir="$XDG_RUNTIME_DIR/emacs/" -locks_dir="$XDG_RUNTIME_DIR/spw_emacsclient/" $want_version || spw_flock 3 "${daemon_name:-server}" |