Module for storing small amounts of data that persists across Hammerspoon restarts.
Values are stored in a dedicated UserDefaults suite named "hs.userdefaults", kept
separate from the app's own preferences so it doesn't get confused with Hammerspoon's
own configuration when inspected with tools like the defaults command line utility.
JavaScript ↔ storage type mapping:
JavaScript strings, numbers, booleans, arrays and objects round-trip directly
JavaScript Date objects round-trip directly (no special API required)
JavaScript null/undefined are not storable values; use clear() to remove a key
Because the suite is just a standard macOS preferences domain, it can also be inspected
and manipulated from the command line with the defaults tool:
# Read every value stored by hs.userdefaults defaultsreadhs.userdefaults
# Read a single key defaultsreadhs.userdefaultssomeKey
# Write a value from the command line defaultswritehs.userdefaultssomeKey"some value"
# Delete a key defaultsdeletehs.userdefaultssomeKey
Module for storing small amounts of data that persists across Hammerspoon restarts.
Values are stored in a dedicated
UserDefaultssuite named "hs.userdefaults", kept separate from the app's own preferences so it doesn't get confused with Hammerspoon's own configuration when inspected with tools like thedefaultscommand line utility.JavaScript ↔ storage type mapping:
Dateobjects round-trip directly (no special API required)null/undefinedare not storable values; useclear()to remove a keyBecause the suite is just a standard macOS preferences domain, it can also be inspected and manipulated from the command line with the
defaultstool: