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

New Skill: desktop window tool and dictation #1343

Open
auwsom opened this issue Jun 7, 2020 · 4 comments
Open

New Skill: desktop window tool and dictation #1343

auwsom opened this issue Jun 7, 2020 · 4 comments

Comments

@auwsom
Copy link

auwsom commented Jun 7, 2020

Alright, moving along faster than I can follow the procedure to submit into the marketplace, I now have a skill that can use xdotool on Ubuntus for desktop window manipulation, so far minimze and activate (restore). It also has a rudimentary dictation function through the xdotool Type.

from mycroft import MycroftSkill, intent_file_handler
import subprocess

class xdotoolSkill(MycroftSkill):
    def __init__(self):
        MycroftSkill.__init__(self)

    @intent_file_handler('testa.intent')
    def handle_testa(self, message):
        utterance = message.data.get('utterance')
        print(utterance)
        if not ' '  in utterance: self.speak('too short'); return True
        utteranceList = utterance.split(' ')
        self.log.info("utteranceList: "+str(utteranceList))
        command = ''
        if 'minimize' in utterance:
            command = 'xdotool search --onlyvisible --classname '+utteranceList[utteranceList.index("minimize")+1]+' windowminimize'
        if 'activate' in utterance:
            command = 'xdotool search --onlyvisible --classname '+utteranceList[utteranceList.index("activate")+1]+' windowactivate'
            print(command)
        if 'type' in utterance:
            command = 'xdotool type "'+utterance.split(' ', 1)[1]+'"'
            print(command)

        try:
            process = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
            output, error = process.communicate()
        except Exception as e:
            #self.speak('window not found') # no way to implement because no error from xdotool search when finding nothing
            self.log.exception('error: '+e)

def create_skill():
    return xdotoolSkill()

todo: https://mycroft-ai.gitbook.io/docs/skill-development/marketplace-submission

@auwsom
Copy link
Author

auwsom commented Jun 7, 2020

This skill has similar functions to https://github.com/MycroftAI/skill-desktop-launcher, except will run using xdotool (a necessary requirement) instead of using PyGObject for application launch() for example as this seems to be GTK specific. Correct me if Im wrong..

@ChanceNCounter
Copy link
Contributor

Personally, I'd rather not see a bunch of small skills for individual desktop features. That'll end in a very cluttered marketplace.

I think it's fine if there are multiple "desktop suites," like maybe extensions to the desktop launcher for specific distros or WMs/DEs. I'd even be okay if there were several basic desktop skills (I've got one I haven't published, and probably won't =P) But I think things like this would be better as part of a suite.

@auwsom
Copy link
Author

auwsom commented Jun 7, 2020

@ChanceNCounter , sure, makes sense. I was about to post an issue in mycoft-core about resolving overlapping intent words by context..

Id like to see the mycroft-skills page on GitHub divided into categories like the marketplace is. I agree, clutter is counterproductive. Speaking of, which other desktop skills are there? No need for me to reinvent the wheel. Also, please just create a post (maybe here) for your code, as I said no reason to reinvent the wheel =P.

Im fine with merging this with skill-desktop-launcher, but I think in the interim, it can be delineated maybe if I put 'xdotool' in the skill name. Then users will have a general sense of its capability and distro compatibility.

@auwsom
Copy link
Author

auwsom commented Jun 7, 2020

Also, being able to sort by the number of downloads (maybe using this https://github.blog/2014-08-12-clone-graphs/ but it looks like info only the repo owner can see) or maybe on number of stars the repo has. That would cut down on the clutter tremendously. @ChanceNCounter

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