一个脚本下载bing的img并设置为墙纸
wonderful_bing的Python项目详细描述
__ __ ___ __ ___ __ __ | | / \ |\ | | \ |__ |__) |__ | | | |__) | |\ | / _` |/\| \__/ | \| |__/ |___ | \ | \__/ |___ |__) | | \| \__>
简介
厌倦了墙纸?让我们改变一下。这个计划是为了 下载Bing的图片并设置为带有通知的墙纸 知道照片背后的故事。
要求
- Linux平台(目前支持gnome、xfce(多亏了[@jokeryu][]), 伙伴(感谢[@renzhn][])
- python 2.7和python 3.x
- libnotify bin(用于arch:libnotify)
安装
$ (sudo) pip install wonderful_bing $ sudo apt-get install libnotify-bin
用法
使用bing --help获取详细信息。
- 手动
您需要设置一个目录(默认的/tmp)来保存下载 图片,以“/”结尾,指定桌面环境(支持gnome, 肉桂,xfce4)。
$ bing set -d /path/to/save/pictures/ desktop_environment
- 自动(建议)
将其添加到startup application(在我的linux mint16中)如果您启动了 打开电脑并定期关机,然后每次开机时 在您的电脑上,此脚本将自动为您运行。
或者使用cron。我举个例子:
0 8 * * * env DISPLAY=:0 /usr/local/bin/bing set -d /home/lord63/pictures/bing/ cinnamon
我们需要``env display=:0``,否则通知根本无法显示, 记住结尾的`/`'。
或者使用anacron如果你经常挂断你的电脑而不是电源 别说了。但是原始的anacron将在根目录下运行脚本, 因此,它可能无法将图片设置为墙纸。跟随 this让您运行anacron 作为普通用户。我举个例子,在 $HOME/.anacron/anacrontab:
1 1 bing env DISPLAY=:0 /usr/local/bin/bing set -d /home/lord63/pictures/bing/ cinnamon
如果您找到更好的方法,请告诉我:)
快照
第一次运行时:
$ bing set -d /home/lord63/pictures/bing/ cinnamon Successfully download the picture to --> /home/lord63/pictures/bing/CascadePools.jpg Successfully set the picture as the wallpaper. :)
获取今天的图片故事。
$ bing story 美国蒙大拿州的白鱼市,正在吃花楸浆果的太平鸟 (© Chuck Haney/Alamy)
如果图片是以前下载过的:
$ bing set -d /home/lord63/pictures/bing/ cinnamon You have downloaded the picture before. Have a look at it --> /home/lord63/pictures/bing/CascadePools.jpg
如果您的电脑没有连接到网络,它将在5点后重试 分钟。
$ bing set -d /home/lord63/pictures/bing/ cinnamon ConnectionError,check your network please. Will try again after 5 minutes.
通知应该如下:
许可证
麻省理工学院许可证