ulauncher-clipboard icon indicating copy to clipboard operation
ulauncher-clipboard copied to clipboard

manager for Clips app

Open anibalestrella opened this issue 1 year ago • 2 comments

**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()

anibalestrella avatar Apr 14 '23 10:04 anibalestrella

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

friday avatar Apr 14 '23 16:04 friday

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

friday avatar Apr 01 '24 20:04 friday