W3cubDocs

/Hammerspoon

hs.camera

Inspect the system's camera devices

API Overview

API Documentation

Functions

allCameras
Signature hs.camera.allCameras() -> table
Type Function
Description

Get all the cameras known to the system

Parameters
  • None
Returns
  • A table containing all of the known cameras
Source extensions/camera/libcamera.m line 329
isWatcherRunning
Signature hs.camera.isWatcherRunning() -> Boolean
Type Function
Description

Checks if the camera devices watcher is running

Parameters
  • None
Returns
  • A boolean, True if the watcher is running, otherwise False
Source extensions/camera/libcamera.m line 468
setWatcherCallback
Signature hs.camera.setWatcherCallback(fn)
Type Function
Description

Sets/clears the callback function for the camera devices watcher

Parameters
  • fn - A callback function, or nil to remove a previously set callback. The callback should accept a two arguments (see Notes below)
Returns
  • None
Notes
  • The callback will be called when a camera is added or removed from the system
  • To watch for changes within a single camera device, see hs.camera:newWatcher()
  • The callback function arguments are:
  • An hs.camera device object for the affected device
  • A string, either "Added" or "Removed" depending on whether the device was added or removed from the system
  • For "Removed" events, most methods on the hs.camera device object will not function correctly anymore and the device object passed to the callback is likely to be useless. It is recommended you re-check hs.camera.allCameras() and keep records of the cameras you care about
  • Passing nil will cause the watcher to stop if it is running
Source extensions/camera/libcamera.m line 486
startWatcher
Signature hs.camera.startWatcher()
Type Function
Description

Starts the camera devices watcher

Parameters
  • None
Returns
  • None
Source extensions/camera/libcamera.m line 378
stopWatcher
Signature hs.camera.stopWatcher()
Type Function
Description

Stops the camera devices watcher

Parameters
  • None
Returns
  • None
Source extensions/camera/libcamera.m line 435

Methods

connectionID
Signature hs.camera:connectionID() -> String
Type Method
Description

Get the raw connection ID of the camera

Parameters
  • None
Returns
  • A number containing the connection ID of the camera
Source extensions/camera/libcamera.m line 554
isInUse
Signature hs.camera:isInUse() -> Boolean
Type Method
Description

Get the usage status of the camera

Parameters
  • None
Returns
  • A boolean, True if the camera is in use, otherwise False
Source extensions/camera/libcamera.m line 590
isPropertyWatcherRunning
Signature hs.camera:isPropertyWatcherRunning() -> bool
Type Method
Description

Checks if the property watcher on a camera object is running

Parameters
  • None
Returns
  • A boolean, True if the property watcher is running, otherwise False
Source extensions/camera/libcamera.m line 691
name
Signature hs.camera:name() -> String
Type Method
Description

Get the name of the camera

Parameters
  • None
Returns
  • A string containing the name of the camera
Source extensions/camera/libcamera.m line 572
setPropertyWatcherCallback
Signature hs.camera:setPropertyWatcherCallback(fn) -> hs.camera object
Type Method
Description

Sets or clears a callback for when the properties of an hs.camera object change

Parameters
  • fn - A function to be called when properties of the camera change, or nil to clear a previously set callback. The function should accept the following parameters:
    • The hs.camera object that changed
    • A string describing the property that changed. Possible values are:
    • gone - The device's "in use" status changed (ie another app started using the camera, or stopped using it)
    • A string containing the scope of the event, this will likely always be "glob"
    • A number containing the element of the event, this will likely always be "0"
Returns
  • The hs.camera object
Source extensions/camera/libcamera.m line 608
startPropertyWatcher
Signature hs.camera:startPropertyWatcher()
Type Method
Description

Starts the property watcher on a camera

Parameters
  • None
Returns
  • The hs.camera object
Source extensions/camera/libcamera.m line 644
stopPropertyWatcher
Signature hs.camera:stopPropertyWatcher()
Type Method
Description

Stops the property watcher on a camera

Parameters
  • None
Returns
  • The hs.camera object
Source extensions/camera/libcamera.m line 671
uid
Signature hs.camera:uid() -> String
Type Method
Description

Get the UID of the camera

Parameters
  • None
Returns
  • A string containing the UID of the camera
Notes
  • The UID is not guaranteed to be stable across reboots
Source extensions/camera/libcamera.m line 533

© 2014–2017 Hammerspoon contributors
Licensed under the MIT License.
https://www.hammerspoon.org/docs/hs.camera.html