dock
The community/apps/dock
directory contains files that allow the user to control the macOS Dock via Talon.
The dock.py
file defines the core functionality, using the Talon API and macOS's Accessibility API to interact with the Dock. It defines two custom actions:
dock_send_notification(notification: str)
: Sends a notification to the macOS Dock using SPI (System Programming Interface). The implementation of this action is in theUserActions
class which callstalon.mac.dock.dock_notify
. This action can be used to trigger certain Dock behaviors, such as showing the desktop or toggling Launchpad.dock_app_expose(app: Optional[ui.App] = None)
: Activates macOS app Exposé for a given app's Dock item. If no app is specified, it defaults to the frontmost app. The implementation of this action is in theUserActions
class. It first locates the Dock icon for the application by searching the accessibility tree. Then it performs theAXShowExpose
action on the Dock item. If no Dock icon or multiple Dock icons are found, a notification is sent to the user.
The dock.talon
file contains Talon commands that use the actions defined in dock.py
:
^desktop$
: Triggersuser.dock_send_notification("com.apple.showdesktop.awake")
to show the desktop.^window$
: Triggersuser.dock_app_expose()
to activate App Exposé for the frontmost app.^launch pad$
: Triggersuser.dock_send_notification("com.apple.launchpad.toggle")
to toggle Launchpad.
In summary, the files in community/apps/dock
work together to provide a way to control the macOS Dock with Talon. dock.py
implements the core functionality of sending notifications to the Dock and activating App Exposé. dock.talon
provides the commands that trigger these actions.