广州活力数据恢复中心

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1693|回复: 0

Macos自动化神器hammerspoon

[复制链接]

92

主题

104

帖子

688

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
688
发表于 2020-4-2 07:35:38 | 显示全部楼层 |阅读模式
Macos自动化神器hammerspoon
安装hammerspoon
下载安装
  1. https://github.com/Hammerspoon/hammerspoon/releases
复制代码


在安装过程中遇到的问题,报错如下:
  1. Updating Homebrew...
  2. fatal: Could not resolve HEAD to a revision
  3. Error: Cask 'hammerspoon' is unavailable: No Cask with this name exists.
复制代码

brew 安装hammerspoon
  1. brew install --cask hammerspoon
复制代码

下面分享一些lua
init.lua

  1. function open(name)
  2.     return function()
  3.         hs.application.launchOrFocus(name)
  4.         if name == 'Finder' then
  5.             hs.appfinder.appFromName(name):activate()
  6.         end
  7.     end
  8. end

  9. --- 快速程序如打开微信,Chrome,finder,QQ,把open("改成你需要的程序")
复制代码




gmail.lua
  1. local gmail = {}

  2. function gmail.mailCount(username, password, cb)
  3.    local url = "https://mail.google.com/mail/feed/atom"

  4.    hs.http.asyncGet(url, {Authorization = "Basic " .. hs.base64.encode(username .. ":" .. password)}, function(status, body, headers)
  5.                        if status == 200 then
  6.                           local mailCount = string.match(body, "<fullcount>([0-9]*)")
  7.                           cb(tonumber(mailCount))
  8.                        else
  9.                           print("gmail call failed with status code: " .. status)
  10.                           print("Please log an issue with the below information to https://github.com/andrewhampton/dotfiles")
  11.                           print(hs.inspect.inspect(headers))
  12.                           print(body)
  13.                           cb(0)
  14.                        end
  15.    end)
  16. end

  17. return gmail
复制代码

wifi连接到指定的wifi后静音
  1. local workWifi = 'wifi name'
  2. local outputDeviceName = 'Built-in Output'
  3. hs.wifi.watcher.new(function()
  4.     local currentWifi = hs.wifi.currentNetwork()
  5.     local currentOutput = hs.audiodevice.current(false)
  6.     if not currentWifi then return end
  7.     if (currentWifi == workWifi and currentOutput.name == outputDeviceName) then
  8.         hs.audiodevice.findDeviceByName(outputDeviceName):setOutputMuted(true)
  9.     end
  10. end):start()
复制代码









一体优盘数据恢复 www.rflashdata.com
硬盘ROM损坏焊爆丢失配ROM服务
buffalo 隨身碟數據救援 bitlocker WDV2 lacie EFS等加密硬盘数据恢复,指纹爱国者加密优盘数据恢复 +86 18620923827
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|硬盘FLASH数据恢复论坛

GMT+8, 2024-5-14 11:30 , Processed in 0.038937 second(s), 29 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表