Skip to content

Commit

Permalink
Add optional app specification to user.dock_app_expose.
Browse files Browse the repository at this point in the history
  • Loading branch information
nriley committed Nov 24, 2024
1 parent 06f6a44 commit b8887b3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apps/dock/dock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from talon import Context, Module, actions, clip, ui
from pathlib import Path
from typing import Optional

ctx = Context()
mod = Module()
Expand All @@ -14,17 +15,17 @@ class Actions:
def dock_send_notification(notification: str):
"""Send a CoreDock notification to the macOS Dock using SPI"""

def dock_app_expose():
"""Activate app Exposé using the macOS Dock item for the frontmost app"""
def dock_app_expose(app: Optional[ui.App] = None):
"""Activate macOS app Exposé via its Dock item (for the frontmost app if not specified)"""


@ctx.action_class("user")
class UserActions:
def dock_app_expose(app: Optional[App]):
def dock_app_expose(app=None):
if app is None:
app = ui.active_app()

app_name = Path(ui.active_app().path).stem
app_name = Path(app.path).stem
dock_items = ui.apps(bundle="com.apple.dock")[0].children.find(
AXSubrole="AXApplicationDockItem", AXTitle=app_name, max_depth=1
)
Expand Down

0 comments on commit b8887b3

Please sign in to comment.