分页: 1 / 1

shell切换壁纸脚本分享

发表于 : 2012-10-31 19:37
langyxxl
shell脚本版块是不是可以开一个分享shell脚本的地方出来,大家把自己觉得有用的脚本分享出来,方便更多的人来学习
新手学shell脚本往往觉得枯燥,提供一些实际的例子有助于激发兴趣

我先分享一个ubuntu12.04 桌面壁纸1分钟自动随机切换的脚本出来

代码: 全选

#!/bin/bash

dir=/mnt/壁纸      #壁纸目录
cd $dir
i=0
for file in *.{jpg,png,bmp}   # 找到所有图片放入数组
do
	photos[i]=$file
	((i++))
done

while true                          #无限循环,切换壁纸
do
	((num=RANDOM%i))    #双小括号为运算
	gsettings set org.gnome.desktop.background picture-uri "file://$dir/${photos[$num]}"
	sleep 60
done

其他地方看一下应该就知道意思,我也就不废话了

Re: shell脚本分享

发表于 : 2012-11-01 4:24
funicorn
[bash]
#!/bin/bash
loop_wall(){
find $HOME/Pictures/Wall/ \( -type f -a -name \*.jpg -o -name \*.png \) | while read wall
do
ln -sf "$wall" "$HOME/.wallpaper"
sleep 300
done
}
touch $HOME/.wallpaper
gsettings set org.gnome.desktop.background picture-uri "file://$HOME/.wallpaper"

while true
do
loop_wall
done
[/bash]

Re: shell脚本分享

发表于 : 2012-11-01 7:54
langyxxl
这个bash脚本是怎么放在网页上的?

Re: shell脚本分享

发表于 : 2012-11-01 8:18
YeLee
[bash]
#!/bin/bash
intertime=1800
wallpaper=/tmp/wallpaper
if [ -e $wallpaper ];then
exit 0
else
touch $wallpaper
fi

signal_handle()
{
rm $wallpaper
exit 1
}
trap signal_handle SIGHUP SIGINT SIGQUIT SIGABRT SIGKILL SIGALRM SIGTERM

while true
do
for i in $(find $1 -type f -name "*.png")
do
fvwm-root --retain-pixmap $i
sleep $intertime
if [ -z $(pgrep fvwm) ];then
rm $wallpaper
exit 0
fi
done
done

[/bash]
换壁纸啊。 :em01 :em01 :em01

Re: shell脚本分享

发表于 : 2012-11-01 9:06
jarryson
不是自带壁纸程序就支持动态壁纸的嘛。。。