hs.permissions
ModuleModule for checking and requesting system permissions
Properties
This module has no properties.
Methods
hs.permissions.checkAccessibility() -> boolean
Check if the app has Accessibility permission
hs.permissions.checkAccessibility() -> boolean
console.log(hs.permissions.checkAccessibility())
hs.permissions.requestAccessibility() -> None
Request Accessibility permission (shows system dialog if not granted)
hs.permissions.requestAccessibility() -> None
hs.permissions.requestAccessibility()
hs.permissions.checkEventPosting() -> boolean
Check if the app may post synthetic keyboard and mouse events, which hs.eventtap needs to send keystrokes and clicks.
macOS keeps this separate from Accessibility, so checkAccessibility() can return true while posted events are
silently dropped. System Settings lists it with Accessibility (System & App Protection Override on macOS 27.3
and later). macOS may not update the result until Hammerspoon 2 is restarted.
hs.permissions.checkEventPosting() -> boolean
if (!hs.permissions.checkEventPosting()) {
console.log("hs.eventtap can't send keystrokes yet")
}
hs.permissions.requestEventPosting() -> None
Request permission to post synthetic keyboard and mouse events (shows the system dialog if not granted).
Once the permission is granted, restart Hammerspoon 2 so macOS applies it.
hs.permissions.requestEventPosting() -> None
hs.permissions.requestEventPosting()
hs.permissions.checkScreenRecording() -> boolean
Check if the app has Screen Recording permission
hs.permissions.checkScreenRecording() -> boolean
console.log(hs.permissions.checkScreenRecording())
hs.permissions.requestScreenRecording() -> None
Request Screen Recording permission
hs.permissions.requestScreenRecording() -> None
hs.permissions.requestScreenRecording()
hs.permissions.checkCamera() -> boolean
Check if the app has Camera permission
hs.permissions.checkCamera() -> boolean
console.log(hs.permissions.checkCamera())
hs.permissions.requestCamera() -> Promise<boolean>
Request Camera permission (shows system dialog if not granted)
hs.permissions.requestCamera() -> Promise<boolean>
hs.permissions.requestCamera().then(granted => console.log(granted))
hs.permissions.checkMicrophone() -> boolean
Check if the app has Microphone permission
hs.permissions.checkMicrophone() -> boolean
console.log(hs.permissions.checkMicrophone())
hs.permissions.requestMicrophone() -> Promise<boolean>
Request Microphone permission (shows system dialog if not granted)
hs.permissions.requestMicrophone() -> Promise<boolean>
hs.permissions.requestMicrophone().then(granted => console.log(granted))
hs.permissions.checkNotifications() -> boolean
Check if the app has permission to display notifications.
The result is cached from the last request or check; the cache is refreshed asynchronously,
so the very first call in a session may return false before the cached value is populated.
Use requestNotifications() on first launch to ensure the result is accurate.
hs.permissions.checkNotifications() -> boolean
console.log(hs.permissions.checkNotifications())
hs.permissions.requestNotifications() -> Promise<boolean>
Request notification permission (shows the system dialog if the user has not yet decided).
It is safe to call this on every launch — the dialog only appears once; subsequent calls resolve immediately with the previously granted or denied state.
hs.permissions.requestNotifications() -> Promise<boolean>
hs.permissions.requestNotifications().then(granted => console.log(granted))
hs.permissions.checkLocation() -> boolean
Check if the app has Location permission.
hs.permissions.checkLocation() -> boolean
console.log(hs.permissions.checkLocation())
hs.permissions.requestLocation() -> Promise<boolean>
Request Location permission (shows the system dialog if the user has not yet decided).
hs.permissions.requestLocation() -> Promise<boolean>
hs.permissions.requestLocation().then(granted => {
if (granted) console.log(hs.location.get())
})
hs.permissions.checkInputMonitoring() -> boolean
Check if the app has Input Monitoring permission.
Input Monitoring is required for hs.keyboard to query and control CapsLock state and LEDs on a
per-keyboard basis.
hs.permissions.checkInputMonitoring() -> boolean
console.log(hs.permissions.checkInputMonitoring())
hs.permissions.requestInputMonitoring() -> None
Request Input Monitoring permission (shows the system dialog if the user has not yet decided).
hs.permissions.requestInputMonitoring() -> None
hs.permissions.requestInputMonitoring()
hs.permissions.checkBluetooth() -> boolean
Check if the app has Bluetooth permission, which hs.bluetooth needs.
hs.permissions.checkBluetooth() -> boolean
console.log(hs.permissions.checkBluetooth())
hs.permissions.requestBluetooth() -> Promise<boolean>
Request Bluetooth permission (shows the system dialog if the user has not yet decided)
hs.permissions.requestBluetooth() -> Promise<boolean>
hs.permissions.requestBluetooth().then(granted => console.log(granted))
hs.permissions.checkCalendars() -> boolean
Check if the app has full access to calendar events, which hs.eventkit needs.
hs.permissions.checkCalendars() -> boolean
console.log(hs.permissions.checkCalendars())
hs.permissions.requestCalendars() -> Promise<boolean>
Request full access to calendar events (shows the system dialog if the user has not yet decided)
hs.permissions.requestCalendars() -> Promise<boolean>
hs.permissions.requestCalendars().then(granted => {
if (granted) console.log(hs.eventkit.calendars().length + " calendars")
})
hs.permissions.checkReminders() -> boolean
Check if the app has full access to reminders, which hs.eventkit's reminder methods need.
hs.permissions.checkReminders() -> boolean
console.log(hs.permissions.checkReminders())
hs.permissions.requestReminders() -> Promise<boolean>
Request full access to reminders (shows the system dialog if the user has not yet decided)
hs.permissions.requestReminders() -> Promise<boolean>
hs.permissions.requestReminders().then(granted => {
if (granted) console.log(hs.eventkit.reminderLists().length + " reminder lists")
})
hs.permissions.checkPersonalVoice() -> boolean
Check if the app may speak with the Personal Voices the user has created, which hs.speech can then use.
Personal Voice is an accessibility feature that creates a synthesized voice that sounds like the user. Voices are created in System Settings → Accessibility → Personal Voice.
hs.permissions.checkPersonalVoice() -> boolean
console.log(hs.permissions.checkPersonalVoice())
hs.permissions.requestPersonalVoice() -> Promise<boolean>
Request permission to speak with the user's Personal Voices (shows the system dialog if the user has not yet decided).
The dialog only appears if "Allow applications to use your Personal Voice" is turned on in
System Settings → Accessibility → Personal Voice; otherwise the Promise resolves to false.
Once granted, the user's Personal Voices are listed by hs.speech.voices(), with isPersonalVoice set.
hs.permissions.requestPersonalVoice() -> Promise<boolean>
hs.permissions.requestPersonalVoice().then(granted => {
const mine = hs.speech.voices().find(v => v.isPersonalVoice)
if (granted && mine) hs.speech.speak("This is my voice", { voice: mine.identifier })
})