Jump to content

Omnifocus Create (Yet another)


Recommended Posts

The OF workflow that just sends the query straight to OmniFocus was a bit too simplistic for my taste. I created a workflow that lists matching projects and contexts and autocompletes them when you select it.

 

OvuWjnll.png

 

CD5uyicl.png

 

Hope it actually works for you guys, I've used the ruby template but not sure how to distribute it properly.

 

http://s.crowdway.com/of-create.alfredworkflow

Edited by davidv
Link to comment
  • 1 month later...

I've tried it.

Four packages is needed before the workflow can work:

bundler, plist, alfred-workflow, rb-appscript

 

Also I've made an small modification on your script to make it work with the time tracking app Tyme:

on alfred_script(q)

	tell application "System Events"
    	if not (exists process "OmniFocus") then
        	tell application "OmniFocus" to activate
     	end if
    end tell

	tell application "OmniFocus"
		set my_selection to first item of (parse tasks into default document with transport text q)
		set tsk to name of my_selection
		set due to due date of my_selection
		set esti to (estimated minutes of my_selection) * 60 as real
		set proj to name of containing project of my_selection
		tell application "Tyme" to make new task of (project proj) of application "Tyme" with properties {name:tsk, plannedDurationHours:esti, dueDate:due}
		tell application "Tyme" to make new taskTag of task tsk of (project proj) of application "Tyme" with properties {name:"Incomplete"}
	end tell

end alfred_script

If you are interested in use omnifocus with fantastical and tyme, here you go: https://github.com/fuxialexander/Applescript

Link to comment
  • 1 month later...

I would *love* to use this workflow, but I can not satisfy the gem dependencies. After `sudo gem install rb-appscript` I still get the following and Alfred offers to search google.

 

How should I install dependencies for this workflow?

Starting debug for 'Omnifocus Create'


[ERROR: alfred.workflow.input.scriptfilter] Code 1: /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require': cannot load such file -- appscript (LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require'
from /Users/dlbewley/Dropbox/conf/Alfred/Alfred.alfredpreferences/workflows/user.workflow.7A5B36A9-7F3C-4FD0-8200-0DC536CE50EA/app/omnifocus.rb:1:in `<top (required)>'
from /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require'
from ./main.rb:10:in `<main>'
[ERROR: alfred.workflow.input.scriptfilter] Code 1: /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require': cannot load such file -- appscript (LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require'
from /Users/dlbewley/Dropbox/conf/Alfred/Alfred.alfredpreferences/workflows/user.workflow.7A5B36A9-7F3C-4FD0-8200-0DC536CE50EA/app/omnifocus.rb:1:in `<top (required)>'
from /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require'
from ./main.rb:10:in `<main>'
[ERROR: alfred.workflow.input.scriptfilter] Code 1: /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require': cannot load such file -- appscript (LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require'
from /Users/dlbewley/Dropbox/conf/Alfred/Alfred.alfredpreferences/workflows/user.workflow.7A5B36A9-7F3C-4FD0-8200-0DC536CE50EA/app/omnifocus.rb:1:in `<top (required)>'
from /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/custom_require.rb:36:in `require'
from ./main.rb:10:in `<main>'
Link to comment
  • 2 weeks later...

For people who can't get it working.

 

I install ruby with rbenv so when I do gem install my gems don't use system ruby.

 

To keep it simpe:

2.1.2 in toadi/› which ruby
/Users/toadi/.rbenv/shims/ruby

You can go in the alfred workflow and update the path to the ruby:

 

 

 

Now don't forget to gem install the dependencies :)

 

Link to comment

The package is a bit messed up.

Somehow, there are >30 copies of workflow in there:

zipinfo of-create.alfredworkflow
…
…
workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/spec/app/omnifocus_spec.rb
-rw-r--r--  3.0 unx      973 tx defN 24-Apr-15 19:14 workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/spec/app/task_generator_spec.rb
-rw-r--r--  3.0 unx     3001 tx defN 24-Apr-15 19:21 workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/spec/app/task_spec.rb
-rw-r--r--  3.0 unx     4376 tx defN 24-Apr-15 16:31 workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/workflow/spec/spec_helper.rb
Edited by deanishe
Link to comment

For people who can't get it working.

 

I install ruby with rbenv so when I do gem install my gems don't use system ruby.

 

To keep it simpe:

2.1.2 in toadi/› which ruby
/Users/toadi/.rbenv/shims/ruby

You can go in the alfred workflow and update the path to the ruby:

 

 

 

Now don't forget to gem install the dependencies :)

 

Is it possible to install the gems within the workflow itself before distributing it?

 

It seems excessively complex to require users to install rvm or the like, so as not to mess up the system Ruby.

Link to comment
  • 3 months later...

Hi, I have problem. where i pu the text on cyrilic

[ERROR: alfred.workflow.input.scriptfilter] Code 1: /Users/konstantinpopov/Dropbox/Приложения/Alfred.alfredpreferences/workflows/user.workflow.AB5E6765-3EEA-4E3E-A50B-2A387CA04EC2/bundle/ruby/2.0.0/gems/alfred-workflow-1.8.0/lib/alfred.rb:52:in `join': incompatible character encodings: US-ASCII and ASCII-8BIT (Encoding::CompatibilityError)
	from /Users/konstantinpopov/Dropbox/Приложения/Alfred.alfredpreferences/workflows/user.workflow.AB5E6765-3EEA-4E3E-A50B-2A387CA04EC2/bundle/ruby/2.0.0/gems/alfred-workflow-1.8.0/lib/alfred.rb:52:in `rescue in with_friendly_error'
	from /Users/konstantinpopov/Dropbox/Приложения/Alfred.alfredpreferences/workflows/user.workflow.AB5E6765-3EEA-4E3E-A50B-2A387CA04EC2/bundle/ruby/2.0.0/gems/alfred-workflow-1.8.0/lib/alfred.rb:29:in `with_friendly_error'
	from ./main.rb:14:in `<main>'
[ERROR: alfred.workflow.input.scriptfilter] Code 1: /Users/konstantinpopov/Dropbox/Приложения/Alfred.alfredpreferences/workflows/user.workflow.AB5E6765-3EEA-4E3E-A50B-2A387CA04EC2/bundle/ruby/2.0.0/gems/alfred-workflow-1.8.0/lib/alfred.rb:52:in `join': incompatible character encodings: US-ASCII and ASCII-8BIT (Encoding::CompatibilityError)
	from /Users/konstantinpopov/Dropbox/Приложения/Alfred.alfredpreferences/workflows/user.workflow.AB5E6765-3EEA-4E3E-A50B-2A387CA04EC2/bundle/ruby/2.0.0/gems/alfred-workflow-1.8.0/lib/alfred.rb:52:in `rescue in with_friendly_error'
	from /Users/konstantinpopov/Dropbox/Приложения/Alfred.alfredpreferences/workflows/user.workflow.AB5E6765-3EEA-4E3E-A50B-2A387CA04EC2/bundle/ruby/2.0.0/gems/alfred-workflow-1.8.0/lib/alfred.rb:29:in `with_friendly_error'
	from ./main.rb:14:in `<main>'
[ERROR: alfred.workflow.input.scriptfilter] Code 1: /Users/konstantinpopov/Dropbox/Приложения/Alfred.alfredpreferences/workflows/user.workflow.AB5E6765-3EEA-4E3E-A50B-2A387CA04EC2/bundle/ruby/2.0.0/gems/alfred-workflow-1.8.0/lib/alfred.rb:52:in `join': incompatible character encodings: US-ASCII and ASCII-8BIT (Encoding::CompatibilityError)
	from /Users/konstantinpopov/Dropbox/Приложения/Alfred.alfredpreferences/workflows/user.workflow.AB5E6765-3EEA-4E3E-A50B-2A387CA04EC2/bundle/ruby/2.0.0/gems/alfred-workflow-1.8.0/lib/alfred.rb:52:in `rescue in with_friendly_error'
	from /Users/konstantinpopov/Dropbox/Приложения/Alfred.alfredpreferences/workflows/user.workflow.AB5E6765-3EEA-4E3E-A50B-2A387CA04EC2/bundle/ruby/2.0.0/gems/alfred-workflow-1.8.0/lib/alfred.rb:29:in `with_friendly_error'
	from ./main.rb:14:in `<main>'
Link to comment

It looks like an encoding issue. Alfred uses UTF-8, but tells workflows (by omission) that it's using ASCII.
 
Here's something you can try.

Open the workflow in Alfred Preferences, double-click the "todo" Script Filter and change the Script from this:

/usr/bin/ruby ./main.rb {query}

to this:

/usr/bin/ruby -U ./main.rb {query}

That should force Ruby to use UTF-8 instead of ASCII, and Cyrillic characters should work.

Handling non-ASCII characters is often more complicated than just using the right encoding, so you still might have some problems.
 
In particular, having non-ASCII characters in your sync directory path (/Users/konstantinpopov/Dropbox/Приложения/Alfred.alfredpreferences/workflows/) is quite likely to cause issues with UTF-8/Unicode-unaware workflows.

If my first suggestion doesn't help and/or you have issues with other workflows, try renaming Приложения to Applications or some other ASCII name.

 

A stupid amount of software can't handle non-ASCII paths.

Link to comment

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...