From 7e01b3eb44f1d756a156ddc382d684fd4a45ee48 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Tue, 5 May 2026 09:41:45 +0200 Subject: [PATCH] Fix to set XDG runtime and D-Bus env in xterm shells https://github.com/webmin/webmin/issues/2679 --- xterm/rc/.bashrc | 14 ++++++++++++++ xterm/rc/.zshrc | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/xterm/rc/.bashrc b/xterm/rc/.bashrc index 3cbb131ac..4b63e43fd 100644 --- a/xterm/rc/.bashrc +++ b/xterm/rc/.bashrc @@ -53,3 +53,17 @@ if [ -d ~/.bashrc.d ]; then done fi unset rc + +# set XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS if not set +if [ -z "$XDG_RUNTIME_DIR" ]; then + uid=$(id -u) + xdg_runtime_dir="/run/user/$uid" + + if [ -d "$xdg_runtime_dir" ] && [ -O "$xdg_runtime_dir" ] && \ + [ -S "$xdg_runtime_dir/bus" ]; then + export XDG_RUNTIME_DIR="$xdg_runtime_dir" + export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus" + fi + + unset uid xdg_runtime_dir +fi diff --git a/xterm/rc/.zshrc b/xterm/rc/.zshrc index 50f8b01d7..2d95deae4 100644 --- a/xterm/rc/.zshrc +++ b/xterm/rc/.zshrc @@ -22,3 +22,17 @@ fi if [ -f ~/.zshrc ]; then . ~/.zshrc fi + +# set XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS if not set +if [ -z "$XDG_RUNTIME_DIR" ]; then + uid=$(id -u) + xdg_runtime_dir="/run/user/$uid" + + if [ -d "$xdg_runtime_dir" ] && [ -O "$xdg_runtime_dir" ] && \ + [ -S "$xdg_runtime_dir/bus" ]; then + export XDG_RUNTIME_DIR="$xdg_runtime_dir" + export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus" + fi + + unset uid xdg_runtime_dir +fi