API Docs

Module 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
boolean
true if permission is granted, false otherwise
console.log(hs.permissions.checkAccessibility())

hs.permissions.requestAccessibility() -> None

Request Accessibility permission (shows system dialog if not granted)

hs.permissions.requestAccessibility() -> None
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
boolean
true if permission is granted, false otherwise
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
None
hs.permissions.requestEventPosting()

hs.permissions.checkScreenRecording() -> boolean

Check if the app has Screen Recording permission

hs.permissions.checkScreenRecording() -> boolean
boolean
true if permission is granted, false otherwise
console.log(hs.permissions.checkScreenRecording())

hs.permissions.requestScreenRecording() -> None

Request Screen Recording permission

hs.permissions.requestScreenRecording() -> None
None
This will trigger a screen capture which prompts the system dialog
hs.permissions.requestScreenRecording()

hs.permissions.checkCamera() -> boolean

Check if the app has Camera permission

hs.permissions.checkCamera() -> boolean
boolean
true if permission is granted, false otherwise
console.log(hs.permissions.checkCamera())

hs.permissions.requestCamera() -> Promise<boolean>

Request Camera permission (shows system dialog if not granted)

hs.permissions.requestCamera() -> Promise<boolean>
Promise<boolean>
A Promise that resolves to true if granted, false if denied
hs.permissions.requestCamera().then(granted => console.log(granted))

hs.permissions.checkMicrophone() -> boolean

Check if the app has Microphone permission

hs.permissions.checkMicrophone() -> boolean
boolean
true if permission is granted, false otherwise
console.log(hs.permissions.checkMicrophone())

hs.permissions.requestMicrophone() -> Promise<boolean>

Request Microphone permission (shows system dialog if not granted)

hs.permissions.requestMicrophone() -> Promise<boolean>
Promise<boolean>
A Promise that resolves to true if granted, false if denied
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
boolean
true if notification permission is granted
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>
Promise<boolean>
A Promise that resolves to true if granted, false if denied
hs.permissions.requestNotifications().then(granted => console.log(granted))

hs.permissions.checkLocation() -> boolean

Check if the app has Location permission.

hs.permissions.checkLocation() -> boolean
boolean
true if permission is granted, false otherwise
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>
Promise<boolean>
A Promise that resolves to true if granted, false if denied
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
boolean
true if permission is granted, false otherwise
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
None
hs.permissions.requestInputMonitoring()

hs.permissions.checkBluetooth() -> boolean

Check if the app has Bluetooth permission, which hs.bluetooth needs.

hs.permissions.checkBluetooth() -> boolean
boolean
true if permission is granted, false otherwise
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>
Promise<boolean>
A Promise that resolves to true if granted, false if denied
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
boolean
true if permission is granted, false otherwise
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>
Promise<boolean>
A Promise that resolves to true if granted, false if denied
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
boolean
true if permission is granted, false otherwise
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>
Promise<boolean>
A Promise that resolves to true if granted, false if denied
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
boolean
true if permission is granted, false otherwise (including on a Mac that doesn't support Personal Voice)
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>
Promise<boolean>
A Promise that resolves to true if granted, false if denied or unsupported
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 })
})