Answers:
*编辑-第二次尝试-并对所有终端工作立即道歉-希望这应该只是复制并粘贴突出显示的条目*
包含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
使用CreBS(创建背景幻灯片),您可以为墙纸幻灯片创建XML文件-图像的完整路径存储在XML中,因此无需移动文件。
继承人更新:
#!/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
我遇到了同样的问题,我编写了一个python脚本来编辑可放在中的自定义xml文件/usr/share/gnome-background-properties/my-backgrounds.xml
。在GitHub上。
用法示例:
要添加space_galaxy.jpeg
和fuzz_dog.png
XML文件:
python my-backgrounds.py -a space_galaxy.jpeg fuzzy_dog.png -n "Cool Galaxy" "Cute Dog"
请注意,默认的xml文件位于/usr/share/gnome-background-properties/my-backgrounds.xml
(GNOME监视xml的位置)。要指定备用xml文件,请使用以下-x
选项:
python my-backgrounds.py -a space_galaxy.jpeg -x ~/my-backgrounds.xml
要从xml文件中删除条目,请使用以下-r
选项:
python my-backgrounds.py -r "Cool Galaxy" fuzzy_dog.png
这适用于GNOME 3.6和Python 3.3
这就是我的方法。
右键单击桌面>更改背景。
在“背景”选项卡上,单击“添加”。
去到该文件夹,并选择所有壁纸,通过点击一个,然后按Ctrl+ A。
现在,它们应该显示在选择器中。我还试图找到一个我曾经使用过的小应用程序,以自动更改墙纸。当我找到它的时候会发帖。
我找到了一个叫Wally的手机,强烈推荐它,但是我记得我没有用过那个。无论如何,您可以通过键入以下内容进行安装
sudo apt-get install wally
在一个终端。
要在选择器中显示墙纸,而不必手动更新文件夹,则必须将它们添加到中/usr/share/backgrounds
。
通过在文件夹中创建符号链接,我还能够在选择器中列出墙纸。
$ cd /usr/share/backgrounds
$ ln -s /path/to/wallpapers
这可能会有所帮助,因为每次将墙纸添加到root拥有的文件夹可能并不总是很方便。
$HOME/.local/share/gnome-background-properties/my-wallpapers.xml
和使用它,而不用编辑系统后台文件。