Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open App #2015

Open
donzee529 opened this issue Jan 9, 2024 · 3 comments
Open

Open App #2015

donzee529 opened this issue Jan 9, 2024 · 3 comments

Comments

@donzee529
Copy link

How do I make an icon show in the menu bar and when clicked it toggles open/close a certain app?

@sprak3000
Copy link
Sponsor Collaborator

@donzee529

Have you read through the Writing plugins guide? Start there to get a general overview of how plugin development works.

@donzee529
Copy link
Author

I tried but it wasnt working

#!/bin/bash

# Specify the path to the Pictures folder
pictures_folder="~/Pictures"

# Specify the name of the app to toggle
app_name="MyApp"

# Check if the app is running
if pgrep -xq "$app_name"; then
    # App is running, so we'll stop it
    killall "$app_name"
    echo "Start $app_name | shell=/usr/bin/open | param1=-a | param2=$app_name | emojize=false"
    echo "----"
    echo "Pictures Folder | href=file://$pictures_folder | image=base64_icon_data_here"
else
    # App is not running, so we'll start it
    open -a "$app_name"
    echo "Stop $app_name | shell=pkill | param1=-x | param2=$app_name | emojize=false"
    echo "----"
    echo "Pictures Folder | href=file://$pictures_folder | image=base64_icon_data_here"
fi

@sprak3000
Copy link
Sponsor Collaborator

@donzee529

One thing that jumps out is having too many hyphens for the menu separator.

This

    echo "----"

should be

    echo "---"

Three hyphens... That will at least get the plugin to have your Pictures Folder menu item show up. If I run your plugin and substitute for MyApp, the plugin loads up the application at startup and then shows the Stop <app name> in the menu bar. However, I don't think the menu bar item does anything beyond opening up the menu when you click on it. If you want an action to stop the application, that would need to go in the menu after the echo "---" line, as you have the Pictures Folder link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants