ubuntu 中设置动态壁纸

为了开发android 功能,ubuntu系统也使用了好久时间,作为一个经常使用的系统,不捣鼓捣鼓就太平淡,根据网上的一些介绍,搞了一个动态壁纸出来,用来定时更换壁纸。

首先创建一个文件夹,里面三个文件,其余根据自己喜好放入壁纸文件。


第一个文件addbackground.sh,需要可执行权限

sudo rm -rf /usr/share/backgrounds/test
sudo mkdir /usr/share/backgrounds/test
sudo cp  *.jpg /usr/share/backgrounds/test/
. makelist.sh > background.xml
sudo cp background.xml /usr/share/backgrounds/test/
sudo cp cust-wallpapers.xml /usr/share/gnome-background-properties/

gsettings set org.gnome.desktop.background picture-uri 'file:///usr/share/backgrounds/test/background.xml'

第二个文件,用于拷贝到gnome-background-properties,这样设置里面就可以选择作为动态壁纸

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE wallpapers SYSTEM "gnome-wp-list.dtd">
<wallpapers>
 <wallpaper deleted="false">
   <name>wentao wallpaper</name>
   <filename>/usr/share/backgrounds/test/background.xml</filename>
   <options>zoom</options>
 </wallpaper>
</wallpapers>

第三个文件makelist.sh 也需要可执行权限

#!/bin/bash
# wentao add 2017.6.27

#get current path
basepath=$(cd `dirname $0`; pwd)

#get all jpg wallpapers
files=`ls  $basepath |grep jpg`

lastfile='empty'

echo '<background>'
echo '    <starttime>'
echo '        <year>2017</year>'
echo '        <month>3</month>'
echo '        <day>15</day>'
echo '        <hour>00</hour>'
echo '        <minute>00</minute>'
echo '        <second>00</second>'
echo '    </starttime>'

for current_file in $files
do
        if [[ $lastfile == 'empty' ]]
        then
                lastfile=$current_file
                echo '    <static>'
                echo '        <duration>300.0</duration>'
                echo "       <file>/usr/share/backgrounds/test/$lastfile</file>"
                echo '    </static>'
        else
                echo '    <transition>'
                echo '         <duration>5.0</duration>'
                echo "         <from>/usr/share/backgrounds/test/$lastfile</from>"
                echo "         <to>/usr/share/backgrounds/test/$current_file</to>"
                echo '    </transition>'
                echo '    <static>'
                echo '         <duration>300.0</duration>'
                echo "        <file>/usr/share/backgrounds/test/$current_file</file>"
                echo '    </static>'
                lastfile=$current_file
        fi
done

echo '</background>'

设置完成以后,运行 ./addbackgroundd.sh,就可以设置动态壁纸了,如果想更换动态壁纸里的图片,只要更新当前文件夹里面的图片就可以了。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 进入带空格的文件或者文件夹 Linux文件权限详解 文件和目录权限概述 在linux中的每一个文件或目录都包含有访...
    annkee阅读 2,731评论 0 4
  • 一、文件/文件夹管理 ls 列出当前目录文件(不包括隐含文件)ls -a 列出当前目录文件(包括隐含文件)l...
    路痴千行阅读 2,531评论 0 5
  • Ubuntu 常用命令大全 查看软件 xxx 安装内容 #dpkg -L xxx 查找软件 #apt-cache ...
    guiwuzhe阅读 2,645评论 0 14
  • 作者: Seven-Steven原文链接: https://blog.diqigan.cn/posts/ubunt...
    L_第七感阅读 37,586评论 45 720
  • 租了一个小房间。 这边的建筑,都是很老很旧的规模,随处可见年久的痕迹。藤蔓植物阴嗖嗖的爬向水泥墙壁,繁盛,肆意横行...
    gnani阅读 361评论 0 4