-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee9fbc9
commit 42f2c50
Showing
5 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require "string" | ||
|
||
local module = {} | ||
|
||
function checkBluetoothResult(rc, stderr, stderr) | ||
if rc ~= 0 then | ||
print(string.format("Unexpected result executing `blueutil`: rc=%d stderr=%s stdout=%s", rc, stderr, stdout)) | ||
end | ||
end | ||
|
||
function bluetooth(power) | ||
print("Setting bluetooth to " .. power) | ||
local t = hs.task.new("/usr/local/bin/blueutil", checkBluetoothResult, {"--power", power}) | ||
t:start() | ||
end | ||
|
||
function f(event) | ||
if event == hs.caffeinate.watcher.systemWillSleep then | ||
bluetooth("off") | ||
elseif event == hs.caffeinate.watcher.screensDidWake then | ||
bluetooth("on") | ||
end | ||
end | ||
|
||
module.watcher = hs.caffeinate.watcher.new(f) | ||
module.watcher:start() | ||
return module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
local module = {} | ||
|
||
local evtAdd = "added" | ||
local evtRemove = "removed" | ||
|
||
function usbDeviceCallback(data) | ||
-- TODO set audio output to the FiiO DAC | ||
-- TODO set audio input to the blue snowball | ||
pn = data["productName"] | ||
evt = data["eventType"] | ||
end | ||
|
||
module.watcher = hs.usb.watcher.new(usbDeviceCallback) | ||
module.watcher:start() | ||
|
||
return module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
local module = {} | ||
module.watcher = nil | ||
local homeSSID = "chrowireless" | ||
local lastSSID = hs.wifi.currentNetwork() | ||
|
||
function ssidChangedCallback() | ||
newSSID = hs.wifi.currentNetwork() | ||
|
||
if newSSID == homeSSID and lastSSID ~= homeSSID then | ||
-- We just joined our home WiFi network | ||
hs.audiodevice.defaultOutputDevice():setVolume(25) | ||
elseif newSSID ~= homeSSID and lastSSID == homeSSID then | ||
-- We just departed our home WiFi network | ||
hs.audiodevice.defaultOutputDevice():setVolume(0) | ||
end | ||
|
||
lastSSID = newSSID | ||
end | ||
|
||
module.watcher = hs.wifi.watcher.new(ssidChangedCallback) | ||
module.watcher:start() | ||
|
||
return module |