我将所有文档保存在与 Ubuntu 安装不同的驱动器上,并且该驱动器上有一个装满精美壁纸的文件夹。如何让 Ubuntu 自动搜索此目录,以便壁纸显示在壁纸更换器对话框中,右键单击桌面并选择更改桌面壁纸?
编辑:我尝试在/usr/share/背景文件夹复制到另一个驱动器,但没有效果。
答案1
* 编辑 - 第二次尝试 - 并立即为所有终端工作道歉 - 希望这只是复制和粘贴突出显示的条目*
保存 gnome 壁纸详细信息的文件夹名为 /usr/share/gnome-background-properties/ubuntu-wallpapers.xml
您可以编辑该文件以使壁纸.../壁纸子部分指向您的新文件夹和壁纸文件
以下是从该论坛修改的脚本入口它将为包含 .png 和 .jpg 文件的文件夹自动重新生成 ubuntu-wallpapers.xml 文件。
将内容复制并粘贴到名为“ubuntu-wallpaper-generator”的新文本文件中
然后使用语法执行该文件
sh ubuntu-wallpaper-generator <path to new wallpaper folder>
这将在运行此脚本的同一文件夹中生成一个名为 ubuntu-wallpapers.xml 的文件。
安全备份您当前的 xml 文件,即
sudo cp /usr/share/gnome-background-properties/ubuntu-wallpapers.xml /usr/share/gnome-background-properties/ubuntu-wallpapers.xml.backup
新生成的文件中的副本
sudo cp ubuntu-wallpapers.xml /usr/share/gnome-background-properties/ubuntu-wallpapers.xml
这是我引用的脚本文件:
#!/bin/bash
#
# This script will take all wallpapers in a given folder and
# make them available as "default" background in the "Change Background" gui
# frontend in Ubuntu.
#
################################################################################
#CONFIG_DIR="/usr/share/gnome-background-properties"
CONFIG_DIR="./"
XML_FILE="$CONFIG_DIR/ubuntu-wallpapers.xml"
if [ $# -ne 1 ]; then
echo "*** syntax ubuntu-wallpaper-generator <path to wallpaper folder> ***"
echo "*** for example ***"
echo "*** ubuntu-wallpaper-generator /usr/share/backgrounds ***"
exit 1
else
WALLPAPER_DIR=$1
echo "*** parameters passed: $1 ***"
fi
#### First check if we have write permissions to the share dirctory. ####
touch $CONFIG_DIR/testfile >/dev/null 2>/dev/null
if [ $? -ne 0 ]; then
echo "**** No permissions to the desktop share directory. ****"
echo "**** $CONFIG_DIR ****"
echo "**** Procedure Terminated. ****"
exit 1
else
rm $CONFIG_DIR/testfile 2>/dev/null
fi
#### Show the script description message. ###
cat <<EOF
################################################################################
This script makes all pictures in the $WALLPAPER_DIR
directory available to all users defined on this system as their
system-wide GNOME wallpapers.
################################################################################
EOF
#### Fail if the wallpaper directory does not exist. ####
if [ ! -d $WALLPAPER_DIR ]; then
echo "**** The wallpaper directory \"$WALLPAPER_DIR\" does not exist. ****"
echo "**** Precedure Terminated. ****"
exit 1
fi
#### Count the number of jpg/jpeg/png images. ####
numfiles=`ls -1 $WALLPAPER_DIR/*.jpg WALLPAPER_DIR/*.jpeg WALLPAPER_DIR/*.png 2>/dev/null | wc -l`
#### If there are no image files there then exit. ####
if [ $numfiles -eq 0 ]; then
echo "**** The wallpaper directory \"$WALLPAPER_DIR\" has no images. ****"
echo "**** Precedure Terminated. ****"
exit 1
fi
#### Now we create the XML file containing the images for backgrounds. ####
#### Start by creating the header in the XML file. ####
cat <<EOF > $XML_FILE
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
EOF
#### Add each file to the XML file. ####
#### Doing it this way makes sure files with spaces in their names are ####
#### handled properly. (ls .... | while read fname; do) ####
ls -1 $WALLPAPER_DIR/*.jpg $WALLPAPER_DIR/*.png $WALLPAPER_DIR/*.jpeg 2> /dev/null |
while read image_name; do
echo " Adding: `basename "$image_name"`."
fname=`basename "$image_name"`
fname="${fname%%\.*}"
echo " <wallpaper>" >> $XML_FILE
echo " <name>$fname</name>" >> $XML_FILE
echo " <filename>$image_name</filename>" >> $XML_FILE
echo " <options>stretched</options>" >> $XML_FILE
echo " <pcolor>#c58357</pcolor>" >> $XML_FILE
echo " <scolor>#c58357</scolor>" >> $XML_FILE
echo " <shade_type>solid</shade_type>" >> $XML_FILE
echo " </wallpaper>" >> $XML_FILE
done
#### Create the footer for the XML file. ####
echo "</wallpapers>" >> $XML_FILE
cat <<EOF
################################################################################
You're almost done. copy the generated file ubuntu-wallpapers.xml to the
folder /usr/shared/gnome-background-properties
REMEMBER to backup the current ubuntu-wallpaper.xml in that folder first!
################################################################################
EOF
答案2
使用 CreBS(创建背景幻灯片),您可以创建用于壁纸幻灯片的 XML 文件——图像的完整路径存储在 XML 中,因此无需移动文件。
答案3
以下是更新内容:
#!/bin/bash
################################################################################
# This script will take all wallpapers in a given folder and
# make them available as options in the "change desktop background" OR "system->pref->apperances"
# dialog boxes.
# for ubuntu or debian
# wallpapers are in /usr/share/pixmaps/backgrounds/gnome OR /usr/share/backgrounds
# config file(s) for the dialog are in /usr/share/gnome-background-properties
# --that will make them system wide.
#
#ToDo:
# paths with spaces.
################################################################################
# put the output in the same directory as this script
OutDirectory="$( cd "$( dirname "$0" )" && pwd )"
OutFile="$OutDirectory/gnome-added.xml"
# options
options="zoom" #zoom is best but stretch,center,scale,tile,span
shade_type="solid" #horizontal-gradient, vertical-gradient
pcolor="#000000"
scolor="#000000"
if [ $# -ne 1 ]; then
echo "*** need path to directory containing files to include."
echo "*** for example: /usr/share/backgrounds"
exit 1
else
ScanDirectory=$1
fi
#------need to strip and trailing "/" or this writes incorrect file names.
# not if [ "$lastchr" -eq "/" ]
# lastchr=`expr substr $ScanDirectory ${#ScanDirectory} 1` #--OR:
lastchr=${ScanDirectory#${ScanDirectory%?}}
if [ "${lastchr}" = "/" ]; then
ScanDirectory=${ScanDirectory%?}
fi
#--operating in same directory as the script? set full path for the xml file
if [ ${#ScanDirectory} -le 1 ]; then
ScanDirectory=$OutDirectory
fi
# ---does directory exist
if [ ! -d $ScanDirectory ]; then
echo "**** The wallpaper directory \"$ScanDirectory\" does not exist. ****"
echo "**** Precedure Terminated. ****"
exit 1
fi
# ----can we write to it?
# touch $OutDirectory/testfile >/dev/null 2>/dev/null
# if [ $? -ne 0 ]; then
if [ ! -w $OutDirectory ]; then
echo "**** No permissions to the desktop share directory. ****"
echo "**** $OutDirectory ****"
echo "**** Procedure Terminated. ****"
exit 1
fi
#### Count the number of jpg/jpeg/png/svg [tif(f)] images. ####
numfiles=`ls -1 $ScanDirectory/*.jpg ScanDirectory/*.jpeg ScanDirectory/*.png ScanDirectory/*.svg 2>/dev/null | wc -l`
#### If there are no image files there then exit. ####
if [ $numfiles -eq 0 ]; then
echo "**** The wallpaper directory \"$ScanDirectory\" has no images. ****"
echo "**** Precedure Terminated. ****"
exit 1
fi
#### Now we create the XML file containing the images for backgrounds. ####
#### Start by creating the header in the XML file. ####
cat <<EOF > $OutFile
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
EOF
#### Add each file to the XML file. ####
#### Doing it this way makes sure files with spaces in their names are ####
#### handled properly. (ls .... | while read fname; do) ####
ls -1 $ScanDirectory/*.jpg $ScanDirectory/*.png $ScanDirectory/*.jpeg $ScanDirectory/*.svg 2> /dev/null |
while read image_name; do
fname=`basename "$image_name"`
echo " Adding: $fname."
echo " <wallpaper deleted=\"false\">" >> $OutFile
echo " <name>$fname</name>" >> $OutFile
echo " <filename>$image_name</filename>" >> $OutFile
echo " <options>$options</options>" >> $OutFile
echo " <pcolor>$pcolor</pcolor>" >> $OutFile
echo " <scolor>$scolor</scolor>" >> $OutFile
echo " <shade_type>$shade_type</shade_type>" >> $OutFile
echo " </wallpaper>" >> $OutFile
done
#### Create the footer for the XML file. ####
echo "</wallpapers>" >> $OutFile
答案4
这是我的做法。
右键单击桌面>更改背景。
单击“背景”选项卡上的“添加”。
去进入文件夹,然后选择所有壁纸,方法是单击其中一个,然后按Ctrl+ A。
它们现在应该显示在选择器中。我还在尝试寻找一个我曾经使用过的小应用程序,用于自动更改壁纸。找到后我会发布。
我找到了一个叫 Wally 的,强烈推荐,但我记得我没有用过它。无论如何,您可以通过输入以下内容来安装它:
sudo apt-get install wally
在终端中。
为了在选择器中显示壁纸,而无需手动更新文件夹,您必须将它们添加到/usr/share/backgrounds
。
我还能够通过在文件夹中创建符号链接在选择器中列出壁纸。
$ cd /usr/share/backgrounds
$ ln -s /path/to/wallpapers
这可能会有所帮助,因为每次将壁纸添加到 root 拥有的文件夹中可能并不总是很方便。