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