撸了一段自动更换壁纸的脚本
Tofloor
poster avatar
justforlxz
deepin
2016-04-20 06:27
Author
python3写的,路径自己改图片的文件夹,时间默认是60秒。

Reply Favorite View the author
All Replies
avatar
justforlxz
deepin
2016-04-20 06:28
#1
本帖最后由 kirigaya 于 2016-4-19 22:41 编辑
  1. import os
  2. import os.path
  3. import time
  4. rootdir="/home/kirigayaloveyousei/Wallpaper/"
  5. while True:        
  6.         for parent,dirnames,filenames in os.walk(rootdir):
  7.                 for filename in filenames:        
  8.                         #print("filename with full path:"+ os.path.join(parent,filename))
  9.                         os.system("gsettings set org.gnome.desktop.background picture-uri file://"+os.path.join(parent,filename))
  10.                         print("正在设置壁纸,壁纸来自:"+os.path.join(parent,filename))
  11.                         time.sleep(60)
Copy the Code


Reply View the author
avatar
yjqcx89
deepin
2016-04-20 07:11
#2
厉害,学习了
Reply View the author
avatar
临之
deepin
2016-04-20 17:19
#3
挺好。windows下就没想过这个问题。。。
Reply View the author
avatar
redstoneleo
deepin
2016-04-21 05:07
#4
我已经写了个成品
http://mathjoy.lofter.com/post/42208d_7cabcf7
必应好壁纸 换一张壁纸,换一种心情!每天都为你更新来自微软必应搜索的高品质壁纸!
Reply View the author
avatar
海天鹰
deepin
2016-04-21 08:14
#5
本帖最后由 sonichy 于 2016-4-21 09:21 编辑
https://bbs.deepin.org/post/38940
我已经写了个成品
http://mathjoy.lofter.com/post/42208d_7cabcf7
必应好壁纸 换一张壁纸,换一种心情! ...
os.system("gsettings set org.gnome.desktop.background picture-uri file://"+os.path.join(parent,filename))
把他的代码加入你的代码,linux就能设置壁纸了。
Reply View the author
avatar
海天鹰
deepin
2016-04-21 08:15
#6
本帖最后由 sonichy 于 2016-4-21 09:16 编辑
line 10 SyntaxError: Non-ASCII character '\xe6' in file wallpaper.py on line 10, but no encoding declared;
最前面要加一行解决中文问题:# encoding: utf-8

Reply View the author
avatar
纯洁的老污师
deepin
2016-08-22 19:12
#7
http://git.oschina.net/aliendata/My_Other_Program/tree/master/gnome_background_switcher
之前撸过一段半成品,每执行一次脚本随机更换一次壁纸。自动更换功能可配合crontab或者systemd-timer来实现。(用systemd-timer要更完美一些)
Reply View the author