国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > 服务器 > Shiftwallpaper.sh 每隔数秒更换墙纸的脚本

Shiftwallpaper.sh 每隔数秒更换墙纸的脚本

来源:程序员人生   发布时间:2014-04-02 09:25:09 阅读次数:3941次

Linux下的一个脚本:Shiftwallpaper.sh ,功能是:每隔数秒更换墙纸的脚本,时间(默认120秒)你可以自己在下边的代码中设置。

#!/usr/bin/env bash
# shiftwallpaper.sh
# A very simple bash script to shift wallpaper every n seconds.
# Turns your desktop in a kind of digital frame :-)
# Tested in and for Fluxbox [TM].
# Public Domain Code. No Warranty at all.
# ksaver, July 2011.

# Modify this line to you own wallpapers directory.
WALLPAPER_DIR="$HOME/MyPictures/Wallpaper"

# Set interval in seconds to shift wallpaper.
WAIT=120

function load_wallpapers()
{
# Load the wallpaper list into an array
# loads new wallpapers added to directory in runtime.
n=0
for wallpaper in "$1/*"; do
wallpaper_list[n]=$wallpaper
let n=$n+1
done
}

function rotate_wallpapers()
{
# Rotate wallpaper every n seconds.
for wallpaper in ${wallpaper_list[@]}; do
/usr/bin/env fbsetbg -F $wallpaper
sleep $1
done
}

## main()
while [ True ]; do
load_wallpapers $WALLPAPER_DIR
rotate_wallpapers $WAIT
done
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
为码而活
积分:4237
15粉丝
7关注
栏目热点
关闭
程序员人生