Last active
April 4, 2024 15:37
-
-
Save RafhaanShah/9de073bd2780c2967d02131eebfef06c to your computer and use it in GitHub Desktop.
Hammpersoon Configs
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
function audioWatcher(eventType) | |
-- print ("Audio Event: " .. eventType) | |
target = "HD Pro Webcam C920" | |
if(eventType == "dIn ") then | |
cur = hs.audiodevice.defaultInputDevice():name() | |
if (cur ~= target) then | |
dev = hs.audiodevice.findInputByName(target) | |
if (dev ~= nil) then | |
print("Setting default input device to: " .. target) | |
dev:setDefaultInputDevice() | |
end | |
end | |
end | |
end | |
hs.audiodevice.watcher.setCallback(audioWatcher) | |
hs.audiodevice.watcher.start() |
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
function caffeinateWatcher(eventType) | |
if (eventType == hs.caffeinate.watcher.systemWillSleep or | |
eventType == hs.caffeinate.watcher.systemWillPowerOff) then | |
-- Device sleeping | |
print ("Going to Sleep") | |
elseif (eventType == hs.caffeinate.watcher.systemDidWake) then | |
-- Device woke up | |
print ("Waking from Sleep") | |
end | |
end | |
sleepWatcher = hs.caffeinate.watcher.new(caffeinateWatcher) | |
sleepWatcher:start() |
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
workSSID = "Work" | |
prevSSID = "" | |
function ssidChangedCallback() | |
newSSID = hs.wifi.currentNetwork() | |
if newSSID == nil then | |
print ("WiFi Disconnected") | |
else | |
print ("WiFi Changed " .. newSSID) | |
end | |
if newSSID == workSSID then | |
-- We just joined our work WiFi network | |
print ("Work WiFi") | |
else | |
if prevSSID == workSSID then | |
-- We just departed our work WiFi network | |
print ("Left Work WiFi") | |
end | |
end | |
if newSSID == nil then | |
prevSSID = "" | |
else | |
prevSSID = newSSID | |
end | |
end | |
-- Run this to get location permission for WiFi print(hs.location.get()) | |
hs.location.get() | |
wifiWatcher = hs.wifi.watcher.new(ssidChangedCallback) | |
wifiWatcher:start() |
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
function usbDeviceCallback(data) | |
if (data["productName"] == "Razer Huntsman V2") then | |
if (data["eventType"] == "added") then | |
hs.keycodes.setLayout("British - PC") | |
elseif (data["eventType"] == "removed") then | |
hs.keycodes.setLayout("U.S.") | |
end | |
end | |
end | |
usbWatcher = hs.usb.watcher.new(usbDeviceCallback) | |
usbWatcher:start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment