如何为壁纸设置另一个搜索目录?

Sli*_*eam 12 wallpaper 10.10

我将所有文档保存在与 ubuntu 安装不同的驱动器上,并且该驱动器上有一个装满精美壁纸的文件夹。如何让 ubuntu 自动搜索此目录,以便墙纸显示在墙纸更换器对话框中,通过右键单击桌面并选择“更改桌面墙纸”到达?

编辑:我尝试将/usr/share/backgrounds文件夹中的符号链接放入另一个驱动器,但没有用。

fos*_*dom 9

* 编辑 - 第二次尝试 - 并立即为所有终端工作道歉 - 希望这应该只是复制和粘贴突出显示的条目*

保存 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>
Run Code Online (Sandbox Code Playgroud)

这将在您运行此脚本的同一文件夹中生成一个名为 ubuntu-wallpapers.xml 的文件。

安全备份您当前的 xml 文件,即

sudo cp /usr/share/gnome-background-properties/ubuntu-wallpapers.xml /usr/share/gnome-background-properties/ubuntu-wallpapers.xml.backup
Run Code Online (Sandbox Code Playgroud)

新生成的文件中的副本

sudo cp ubuntu-wallpapers.xml /usr/share/gnome-background-properties/ubuntu-wallpapers.xml
Run Code Online (Sandbox Code Playgroud)

这是我提到的脚本文件:

#!/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
Run Code Online (Sandbox Code Playgroud)