From 9c69b290f13f05742a9e72071a21148f55e4a8c1 Mon Sep 17 00:00:00 2001 From: lemniskett Date: Wed, 13 Jan 2021 12:47:53 +0700 Subject: [PATCH] Allow different user in Archbox to access host user's X server and allow apps to run as Wayland-native. --- archbox.bash | 15 ++++++++++++--- archboxcommand.bash | 6 +++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/archbox.bash b/archbox.bash index c7a1725..57ec629 100644 --- a/archbox.bash +++ b/archbox.bash @@ -14,9 +14,18 @@ asroot(){ [[ $EUID -ne 0 ]] && err "Run this as root!" } -storeenv(){ - echo $DBUS_SESSION_BUS_ADDRESS > /tmp/archbox_dbus_session_address - echo $XDG_RUNTIME_DIR > /tmp/archbox_xdg_runtime_dir +#storeenv(){ +# echo $DBUS_SESSION_BUS_ADDRESS > /tmp/archbox_dbus_session_address +# echo $XDG_RUNTIME_DIR > /tmp/archbox_xdg_runtime_dir +#} + +storeenv() { + echo "# This will be sourced when entering Archbox" > /tmp/archbox_env + [[ ! -z $WAYLAND_DISPLAY ]] && echo "WAYLAND_DISPLAY=$WAYLAND_DISPLAY" >> /tmp/archbox_env + [[ ! -z $DISPLAY ]] && checkdep xhost && xhost +local: > /dev/null \ + && echo "DISPLAY=$DISPLAY" >> /tmp/archbox_env + echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" >> /tmp/archbox_env + echo "XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR" >> /tmp/archbox_env } help_text(){ diff --git a/archboxcommand.bash b/archboxcommand.bash index aea345f..b7828ad 100644 --- a/archboxcommand.bash +++ b/archboxcommand.bash @@ -1,8 +1,12 @@ #!/usr/bin/env bash source /etc/archbox.conf +source /tmp/archbox_env -REQ_ENV="DBUS_SESSION_BUS_ADDRESS=$(cat /tmp/archbox_dbus_session_address) XDG_RUNTIME_DIR=$(cat /tmp/archbox_xdg_runtime_dir)" +REQ_ENV="DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS " +REQ_ENV+="XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR " +[[ ! -z $DISPLAY ]] && REQ_ENV+="DISPLAY=$DISPLAY " +[[ ! -z $WAYLAND_DISPLAY ]] && REQ_ENV+="WAYLAND_DISPLAY=$WAYLAND_DISPLAY " ENV="$REQ_ENV $ENV_VAR" COMMAND="$@"