Skip to content

Instantly share code, notes, and snippets.

@moyashi
Created November 15, 2019 05:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moyashi/ad9342024b3da3fb789826bc4c73ae24 to your computer and use it in GitHub Desktop.
Save moyashi/ad9342024b3da3fb789826bc4c73ae24 to your computer and use it in GitHub Desktop.
toggleInstantHotspot = [[
tell application "System Events"
tell process "SystemUIServer"
tell menu bar 1
set menuBarItems to (every menu bar item whose description begins with "Wi-Fi")
if (count of menuBarItems) is greater than 0 then
set wifiMenuBarItem to item 1 of menuBarItems
click wifiMenuBarItem
--接続中か判定
set menuItemDisconnects to (every menu item of menu 1 of wifiMenuBarItem whose name ends with "との接続を解除")
if (count of menuItemDisconnects) is greater than 0 then
click item 1 of menuItemDisconnects
return
end if
repeat with i in every menu item of menu 1 of wifiMenuBarItem
try
if (value of attribute "AXValueDescription" of i ends with " インターネット共有.") then
click i
exit repeat
end if
end try
end repeat
end if
end tell
end tell
end tell
]]
hs.hotkey.bind({"cmd"}, "F1", function()
hs.osascript.applescript(toggleInstantHotspot)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment