Giter Club home page Giter Club logo

wallpaper-mac's Introduction

wallpaper-mac

背景

使用go语言的跨平台开发框架wails开发桌面应用的时候, 需要修改桌面壁纸,但是wails并没有提供修改桌面壁纸的接口, 只能通过AppleScript脚本来修改桌面壁纸,正常情况下是没问题的。 但是如果想要上架苹果应用商店,由于系统权限问题,如若需要在沙盒环境下运行, AppleScript脚本将无法正常运行,需要在沙盒模式下运行脚本,步骤相对比较复杂, 所以需要寻找其他方法来修改桌面壁纸。

思路

通过调用Macos原生Api来修改桌面壁纸,具体实现方法可以参考macdriver, 基于该库我将壁纸修改的功能简单的封装成了一个库,方便其他开发者调用。

安装

go get -u github.com/boyyang-love/wallpaper-mac

使用

package main

import (
  "fmt"
  "github.com/boyyang-love/wallpaper-mac/wallpaper"
)

func main() {
  w := wallpaper.NewWallpaper()

  // 设置壁纸
  err := w.SetWallpaper("/Users/boyyang/Downloads/test.jpg")
  if err != nil {
    return
  }
  // 获取当前桌面壁纸路径
  path := w.GetWallpaper()
  fmt.Println(path)
}

wallpaper-mac's People

Contributors

boyyang-love avatar

Stargazers

 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.