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

manager for Clips app #36

Open
anibalestrella opened this issue Apr 14, 2023 · 2 comments
Open

manager for Clips app #36

anibalestrella opened this issue Apr 14, 2023 · 2 comments

Comments

@anibalestrella
Copy link

anibalestrella commented Apr 14, 2023

**manager for Clips app **
I am trying to add a manager for https://github.com/hezral/clips, it works fine in elementaryOs but I see it's missing on your extension so i am trying to make a manager for it, but i can't make it work, here's the code i am doing:

from shutil import which

class MyClipsManager:
    def __init__(self):
        self.name = 'clips'
        self.binary = '/usr/bin/clips'
        if not self.can_start():
            raise Exception('Clips app is not installed or not in PATH')
        if not self.is_running():
            self.start()

    def can_start(self):
        return bool(which(self.binary))

    def is_running(self):
        return bool(self.pid_of('clips'))

    def pid_of(self, process_name):
        return subprocess.check_output(['pgrep', process_name]).strip()

    def start(self):
        subprocess.call([self.binary])

    def stop(self):
        subprocess.call(['killall', 'clips'])

    def add(self, text):
        subprocess.call([self.binary, '-a', text])

    def get_history(self):
        return subprocess.check_output([self.binary, '-l']).decode('utf-8').splitlines()
@friday
Copy link
Owner

friday commented Apr 14, 2023

Did you also import it and add it to the list? https://github.com/friday/ulauncher-clipboard/blob/main/main.py#L3-L7

@friday
Copy link
Owner

friday commented Apr 1, 2024

I have pushed some refactoring to the main branch (used for Ulauncher v6) to add stricter types, so they're actually classes now, more similar to your example. I would recommend to copy one of the existing integrations (ex GPaste), replacing the name and the implementation of the methods rather than writing your own separate implementation from scratch. Then you also have to import it to main.py

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