qubes.GetAppmenus: handle home directory properly in case of sudo

This commit is contained in:
Pawel Marczewski 2020-01-08 17:05:32 +01:00
parent 2df17a4790
commit 418a5ec6e3
No known key found for this signature in database
GPG Key ID: DE42EE9B14F96465

View File

@ -17,7 +17,13 @@ for i in /etc/profile.d/*.sh ; do
done
if [ -z "$XDG_DATA_HOME" ]; then
XDG_DATA_HOME="$HOME/.local/share"
user="$(whoami)"
# In case we are running under sudo, use default-user.
if [ "$user" = "root" ]; then
user="$(qubesdb-read /default-user || echo user)"
fi
home="$(eval echo "~$user")"
XDG_DATA_HOME="$home/.local/share"
fi
if [ -z "$XDG_DATA_DIRS" ]; then
XDG_DATA_DIRS="/usr/local/share/:/usr/share/"