This is my hammerspoon config ( a): local alert = require 'hs.alert'įor part in string.gmatch(key_path, " ") do ![]() something like this should also work for setting mqtt topics for your screen status or any other mac status or telemetry. Hammerspoon has a steep learning curve, but is a very usefull tool, that i don’t want to miss any more. it retries serveral times to connect to the net, to give the mac time after wakeup to connect to the network. If your mqtt broker is accessible from outside your network, this works anywhere, if the mac has an internet connection. ![]() Hs.execute('/Users/ix/Library/Application\\ Support/LaunchBar/Actions/wake.lbaction/Contents/Scripts/wake.sh', true) Hs.notify.show("Wake sequence initiated!", "", "") Hs.execute('/Users/ix/Library/Application\\ Support/LaunchBar/Actions/sleep.lbaction/Contents/Scripts/sleep.sh', true)Įlseif (eventType = hs.) then Sleep_a local sleepWatcher = require 'hs.caffeinate.watcher' sh file to call other services, too) with the hammerspoon caffeinate.watcher function: This is the module that i use to call the scripts (embedded in a. Publish_message("ixbook/sleep/status", "start") Publish.single(topic, message, hostname="mqtt-hostname", port=, auth=auth, tls=tls, retain=True) Publish_message("ixbook/sleep/status", "stop") ![]() Publish.single(topic, message, hostname="", port=, auth=auth, tls=tls, retain=True) 'ca_certs':"/usr/local/etc/openssl/cert.pem", Print("Publishing to MQTT topic: " topic) I’m getting pretty reliable results with hammerspoon now, calling the scripts when the mac awakes or goes to sleep.ĭef wait_for_internet_connection(url=' timeout=5): i also tried sleepwatcher, but moved away from that because of lacking support for newer operating systems. i used to call the scripts with scenario, which didn’t work as reliably as i wished. I’m using two python scripts on my macbook that set an mqtt topic for a sleep sensor.
0 Comments
Leave a Reply. |