[英]How to get desktop folder of specified user in red hat Linux shell script
For installation purposes I need to locate desktop folders of all Linux with Qvwm users on current machine. 出于安装目的,我需要在当前计算机上找到Qvwm用户所在的所有Linux的桌面文件夹。
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.. 感谢您的建议。
For any desktop environment following the XDG Base Directory Specification and compatible with the xdg-user-dirs
reference implementation , this might look as follows: 对于遵循XDG基本目录规范并与
xdg-user-dirs
参考实现兼容的任何桌面环境,它可能如下所示:
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; XDG_CONFIG_HOME
,则指定其主目录位置的配置文件将设置在这样命名的目录中; otherwise, the file exists in ~user/.config
. ~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. $XDG_CONFIG_HOME/user-dirs.dirs
存在并且包含对XDG_DESKTOP_DIR
的分配,则该分配的结果将用作用户的桌面目录。 $HOME/Desktop
. $HOME/Desktop
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.