简短的设置壁纸程序

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
wiewi
帖子: 628
注册时间: 2008-11-20 22:50
系统: ArchLinux

简短的设置壁纸程序

#1

帖子 wiewi » 2011-07-24 22:18

[bash]

[liwei@myhost ~] $ >>_ cat bin/setwallpaper
#!/bin/bash
# Set background using hsetroot,with a file selection dialog of zenity
# Necessary parts: zenity,hsetroot(or other similar wallpaper programs)
# 11/07/24,[email protected]

Dest=$HOME/media/images/background/1280x800

[ -d "$Dest" ] && cd "$Dest"
[ "$?" -ne 0 ] && zenity --notification --text="No such directory: $Dest" && exit 1

Wallpaper=$(zenity --file-selection --title=请选择壁纸)

[ -n "$Wallpaper" ] &&{
ln -sf "$Wallpaper" ~/.wallpaper
hsetroot -fill ~/.wallpaper && exit 0
}

[/bash]
来个图吧
:em06 :em06
2011-07-24-22-21-30.png
===我的小窝===
无聊吗?点我吧,楼主迫切期待你的光临~~
又一个轮子
------------------------------------
这年头,没有1000贴都不好意思见人了
------------------------------------
献丑不如藏拙
------------
头像
monk
帖子: 19507
注册时间: 2010-01-28 10:45

Re: 简短的设置壁纸程序

#2

帖子 monk » 2011-07-24 22:47

很少看到桌面
不过还是支持一下 :em11

*********宁静致远*********
如果我说的有什么不对,请看签名第一行
头像
wiewi
帖子: 628
注册时间: 2008-11-20 22:50
系统: ArchLinux

Re: 简短的设置壁纸程序

#3

帖子 wiewi » 2011-07-24 22:59

monk 写了:很少看到桌面
不过还是支持一下 :em11
纯CLI & Coder? ym~~
===我的小窝===
无聊吗?点我吧,楼主迫切期待你的光临~~
又一个轮子
------------------------------------
这年头,没有1000贴都不好意思见人了
------------------------------------
献丑不如藏拙
------------
头像
vinoca
帖子: 59
注册时间: 2011-03-21 18:30

Re: 简短的设置壁纸程序

#4

帖子 vinoca » 2011-07-25 12:40

不错。早上也搞了个,每5分钟换壁纸,rox+openbox环境。
crontab -e :
*/5 * * * * /home/user/.config/scripts/chbg.sh `bash -c 'echo /media/Wallpaper/$(ls /media/Wallpaper/ | sed -n "$(($RANDOM%$(ls /media/Wallpaper/ | wc -l)+1))p")'`

/home/user/.config/scripts/chbg.sh :

#!/bin/sh
rox --RPC << EOF
<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope">
<env:Body xmlns="http://rox.sourceforge.net/SOAP/ROX-Filer">
<SetBackdrop>
<Filename>$1</Filename>
<Style>Stretch</Style>
</SetBackdrop>
</env:Body>
</env:Envelope>

EOF

不用rox -pDefault,也可以是这样:hsetroot -fill "$(find /media/Wallpaper/ -type f | shuf -n 1)"
上次由 vinoca 在 2011-08-06 17:31,总共编辑 1 次。
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: 简短的设置壁纸程序

#5

帖子 eexpress » 2011-07-25 16:31

--RPC... 还真不知道这。
● 鸣学
回复