


(i just copy, pasted and changed this from someones else’s config, AFAIK this: GitHub jhgg/Hammerspoon-Config The sleep_a (and some other modules) are in a folder called modules in the same directory as a and get initialed by the init script. Table.insert(buf, "Hammerspoon re-loaded: ") Table.insert(buf, "Hammerspoon loaded: ") This is my hammerspoon config ( a): local alert = require 'hs.alert'įor part in string.gmatch(key_path, "+") do

#SLEEPWATCHER MAC MAC#
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.
#SLEEPWATCHER MAC FULL#
Next think of a name in the following reverse domain notation .plist and create the property list file (.plist) with the following content: Mai 2018įirst of all create your bash script and place it somewhere.
