我一直疯狂地使用 Google 来寻找答案,所以我现在决定在这里提问。
我该如何更改登录屏幕的背景?(lightdm-gtk-greeter)。
它目前使用我设置为桌面背景的任何背景,并且不监听 中的任何配置/etc/lightdm/lightdm-gtk-greeter.conf
,这是它当前设置的内容:
[greeter]
background=/home/illidan/Pictures/bg.png
答案1
方法 1:假设你正在运行<=14.0.4,
sudo su
xhost +SI:localuser:lightdm
su lightdm -s /bin/bash
gsettings set com.canonical.unity-greeter draw-user-backgrounds 'true'
gsettings set com.canonical.unity-greeter background 'path-to-image'
对我有用。另外,你可能需要将背景修改为 chmod 644。
方法 2
将图片文件复制到此位置
/usr/share/backgrounds/
将文件名更改为warty-final-ubuntu.png
(显然图像必须是 PNG 格式)
答案2
我使用 Nautilus 导航到壁纸文件,然后调用自定义脚本来同时设置登录屏幕和锁定屏幕背景:
#!/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
完整答案包括如何向 Nautilus 添加脚本:如何更改 Unity 锁屏壁纸?