I would like an app in the dock to open and close when I double-click it. Is that possible?
Hi @erwin, I'll try to help you out.
Assuming I understand your goal correctly, closing Chrome tabs via clicking on an item in the Dock is achievable. We'll do this by leveraging the macOS Shortcuts app and AppleScript.
Note
I didn't implement any "opening" Chrome tabs functionality because I don't fully understand how exactly you would like that to work. If you provide more details, I could provide further guidance.
Steps:
-
Create a new Apple Shortcut in the macOS Shortcuts app.
-
Add a Run AppleScript Action.
-
Enter this AppleScript in the Run AppleScript Action:
tell application "Google Chrome" -- Loop through each window repeat with w in every window -- Get just the tabs for this one window set tabList to every tab of w -- Close them one by one repeat with t in tabList close t end repeat end repeat end tell
At this stage, you should see this on your screen:
-
Click on File → Add to Dock
-
You should now see a new item in your Dock called "Close Chrome Tabs" and when clicked, all of the tabs in every window of Chrome will be closed.
I hope this helps.