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="$@"