Reputation: 3898
For installation purposes I need to locate desktop folders of all Linux with Qvwm users on current machine.
I have the following script:
HOMES=`getent passwd | cut -d: -f6`
SHORTCUT=/path/to/shortcut.desktop
find $HOMES -maxdepth 3 -name "Desktop" -exec cp $SHORTCUT {} \;
But I understood that user desktop folder may differ from "Desktop".
The question is: how I can determine the correct path to desktop folder of all/specified user in system.
Thanks for you suggestions..
Upvotes: 0
Views: 651
Reputation: 295472
For any desktop environment following the XDG Base Directory Specification and compatible with the xdg-user-dirs
reference implementation, this might look as follows:
sudo -u "$user" -i bash -l <<'EOF'
user_dirs_file=${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs
[[ -s $user_dirs_file ]] && . "$user_dirs_file"
printf '%s\n' "${XDG_DESKTOP_DIR:-$HOME/Desktop}"
EOF
XDG_CONFIG_HOME
is set by the user's dotfiles, the configuration file specifying the location of their home directory will be set in the directory thus named; otherwise, the file exists in ~user/.config
.$XDG_CONFIG_HOME/user-dirs.dirs
exists and contains an assignment to XDG_DESKTOP_DIR
, the result of that assignment shall be used as the user's desktop directory.$HOME/Desktop
.Upvotes: 2