答案1
使用 Nautilus 导航并查看适合用作登录屏幕和锁定屏幕壁纸的 .png 或 .jpg 文件后,Nautilus 可以使用脚本为您设置此项:
笔记:在 Ubuntu 18.04 中,仅更改了锁屏壁纸。更改登录壁纸需要不同的技术。
要创建脚本,请使用:
cd ~/.local/share/nautilus/scripts/
gedit set-login-wallpaper
粘贴以下行:
#!/bin/bash
## Set login wallpaper
# strip new line char passed by Nautilus
FILENAME=$(echo $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS | sed -e 's/\r//g')
# Multiple files can't be selected.
LINE_COUNT=$(wc -l <<< "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS")
LINE_COUNT=$((LINE_COUNT-1))
if [[ $LINE_COUNT > 1 ]] ; then
zenity --error --text "Ony one file can be selected at a time! "
exit 1
fi
# Object type must be "file..." (ie no directories, etc.)
if [ -d "${FILENAME}" ] ; then
zenity --error --text "$FILENAME is a directory!";
exit 1
else
if [ -f "${FILENAME}" ]; then
: # Bash noop
else
zenity --error --text "${FILENAME} is not a file!";
exit 2
fi
fi
# Build working file in /tmp
echo "[com.canonical.unity-greeter]" > /tmp/set-login-wallpaper.tmp
echo "draw-user-backgrounds=false" >> /tmp/set-login-wallpaper.tmp
echo "background='$FILENAME'" >> /tmp/set-login-wallpaper.tmp
# Must run as sudo
if [ "$EUID" -ne 0 ] ; then
# Get sudo password
PASSWORD=$(zenity --password --title="Set Login Wallpaper" --timeout=20)
# copy working file to real file using sudo
echo $PASSWORD | sudo -S cp /tmp/set-login-wallpaper.tmp \
/usr/share/glib-2.0/schemas/10_unity_greeter_background.gschema.override
# compile using sudo
echo $PASSWORD | sudo -S glib-compile-schemas /usr/share/glib-2.0/schemas
else
# Already sudo so simply copy and compile
# copy working file to real file
cp /tmp/set-login-wallpaper.tmp \
/usr/share/glib-2.0/schemas/10_unity_greeter_background.gschema.override
# compile
glib-compile-schemas /usr/share/glib-2.0/schemas
fi
exit 0
保存文件并退出gedit
编辑器。
现在使用以下命令将脚本标记为可执行:
chmod +x set-login-wallpaper
打开 Nautilus 并导航到包含壁纸图片的目录。找到合适的图片并右键单击它。出现此下拉菜单:
单击第三个选项Scripts
。将出现另一个下拉菜单,其中包含所有脚本:
选择set-login-wallpaper
。
当脚本运行时,您必须输入密码sudo
。
重新启动并享受您的新登录壁纸。