Coder Social home page Coder Social logo

2018_code_calendar_wallpaper_macos's Introduction

2018编程日历壁纸Mac OS

今天看见了ttttmr2018编程日历壁纸,无奈人家是Windows的,于是自己写了一个Mac OS一键换编程日历壁纸的python脚本。

效果图:

一键换壁纸动图展示

依赖

  • Python3
  • ImgaeMagick

有一些同学说会出现no module named wand的情况,我特意去wand官网查看了一下,Wand is a Python binding of ImageMagick, so you have to install it as well所以必须安装ImgaeMagick,但由于现在pip上面的Wand仅支持imagemagick6,而homebrew等版本默认为7。

$ brew install imagemagick@6
$ echo 'export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"' >> ~/.bash_profile
$ brew link imagemagick@6 --force
  • Wand
pip install -r requirements.txt
  • Ghostscript brew install ghostscript即可

使用:

下载项目,进入项目地址,然后python wallpaper.py即可实现一键换壁纸,如果你想使用自己的壁纸,可以将项目目录下的paper.jpg换成你的壁纸。

参考资源:

  1. ttttmr2018编程日历壁纸
  2. 极客编程日历2018桌面壁纸

采坑经历:

$ brew uninstall --force imagemagick

$ brew install imagemagick@6

$ echo 'export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"' >> ~/.bash_profile

$ brew link imagemagick@6 --force
  • 在"一键换壁纸",一直不知道Mac OS除了在系统设置中换壁纸外其他的方法,后来找到了一篇文章Shell系列 - Mac OS X自动下载切换桌面壁纸,于是照猫画虎,在python中使用了os.system("osascript -e \"tell application \\\"Finder\\\" to set desktop picture to POSIX file \\\"/Users/apple/Desktop/Wallpaper/" + OUTPUT + "\\\"\"")以实现“一键换壁纸”的效果。但"一键换壁纸"的命令中壁纸的地址必须使用绝对路径,所以还得通过os.getced()获取当前路径,所以最后的代码为:
address = os.getcwd() + "/" + OUTPUT 
os.system("osascript -e \"tell application \\\"Finder\\\" to set desktop picture to POSIX file \\\"" + address + "\\\"\"")
  • 由于壁纸的大小不同,可能会导致脚本运行后得到的日历壁纸在屏幕显示中不太正常,如有需要可以自己更改脚本中的参数: MARGIN_LEFT,MARGIN_TOP以及resolution

  • 当同一图片文件发生改变,再使用上述“一键换壁纸”命令时发现,壁纸并不会发生改变,为了使得每周使用者在使用该脚本时正常使用,特意改变输出文件的文件名为turing+本周周数。

2018_code_calendar_wallpaper_macos's People

Contributors

rayzhao1998 avatar vonfry avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.