-
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
Showing
7 changed files
with
56 additions
and
37 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
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
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
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,13 @@ | ||
function reloadConfig(files) | ||
doReload = false | ||
for _,file in pairs(files) do | ||
if file:sub(-4) == ".lua" then | ||
doReload = true | ||
end | ||
end | ||
if doReload then | ||
hs.reload() | ||
end | ||
end | ||
myWatcher = hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", reloadConfig):start() | ||
hs.alert.show("Config loaded") |
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 |
---|---|---|
@@ -1,28 +1,32 @@ | ||
-- ~/.hammerspoon/usb.lua | ||
local module = {} | ||
|
||
local evtAdd = "added" | ||
local evtRemove = "removed" | ||
local fiion = "FiiO USB DAC-E17" | ||
local bluen = "Blue Snowball " | ||
local smodi = "Schiit Modi 3" | ||
module.watcher = nil | ||
|
||
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"] | ||
if pn == blue then | ||
if evt == evtAdd then | ||
hs.findDeviceByName(blue):setDefaultInputDevice() | ||
end | ||
elseif pn == fiio then | ||
if evt == evtAdd then | ||
hs.findDeviceByName(fiio):setDefaultOutputDevice() | ||
end | ||
if (pn == smodi) then | ||
if evt == evtAdd then | ||
dac = hs.audiodevice.findOutputByName(pn) | ||
if dac ~= nil then | ||
dac:setDefaultOutputDevice() | ||
end | ||
end | ||
elseif (pn == bluen) then | ||
if evt == evtAdd then | ||
mic = hs.audiodevice.findAudioDeviceByName(pn) | ||
if mic ~= nil then | ||
mic:setDefaultInputDevice() | ||
end | ||
end | ||
end | ||
|
||
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 |
---|---|---|
|
@@ -19,5 +19,4 @@ end | |
|
||
module.watcher = hs.wifi.watcher.new(ssidChangedCallback) | ||
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