Jump to content

Recreate calculator workflow


Recommended Posts

Posted

I'd like help figuring out how to recreate the calculator. Namely:

 

- Have a input trigger

- Have the input automatically run a script to do a computation (in my workflow I'll customize this calculation)

- Have the subtext automatically update as I type

- Ability to copy the result to the clipboard

 

I've tried using a workflow variable and setting a Keyword's subtext to `{var:result}` but keyword doesn't run until you hit enter.

 

I tried using a Script Filter, but that doesn't work either.

 

Is this currently possible?

Posted (edited)

Looks like I just needed to work at it a little longer and read the manual.

 

This Script Filter (w/ python code) + a Copy to Clipboard achieved what I was looking for. Maybe someday I'll get around to a custom icon.
 

import sys
import json

query = int(sys.argv[1]) * 2

sys.stdout.write(
    json.dumps({ 
        'items': [{
            'title': str(query),
            'subtitle': 'Copy to clipboard',
            'arg': str(query)
        }]
    })
)

 

Edited by RyanJM

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...