Jump to content

Ulysses workflow


Recommended Posts

I've put an Alfred workflow for Ulysses up at packal.org/workflow/ulysses and github. The page includes a download link, full instructions and an image. Please give it a go. The commands are briefly:

Get help

  • u:help -- Show a brief summary of commands

Open group or sheet

  • uf -- Find a group or sheet based on internal content
  • u -- Open group or sheet (cmd-return to drill down)
  • ug -- Open group (cmd-return to drill down)
  • us -- Open sheet

Pop open Ulysses Open dialogue

  • uo -- Search for within Ulysses’ Open dialogue

Create sheets

  • un --Create new sheet with optional text (shift-enter to create in /Inbox)

Alfred file actions

  • Use the Open in Ulysses file action to open text-like files in Ulysses
  • Use the Import into Ulysses file action to create a new sheet from text-like content

Configure view to open

  • u:setsheetview  -- Set the view for opening sheets with (defaults to 'Editor Only')
  • u:setgroupview -- Set the view for opening groups with (defaults to 'Sheets')

Thanks

 

The source is on github.

 

--- Rob

Edited by robwalton
Link to comment

Oh this is amazing. Thank you for sharing. I am a heavy user of Ulysses and this is really useful indeed. I would also love to have the groups from 'ug' script folder to be opened in 'cmd + 2' view with side bar hidden away. Is there a way to change it so that it opens in 'cmd + 2' view instead of 'cmd + 1'?

 

Thank you for sharing this.

Edited by nikivi
Link to comment
On 10/28/2016 at 2:12 AM, nikivi said:

Oh this is amazing. Thank you for sharing. I am a heavy user of Ulysses and this is really useful indeed. I would also love to have the groups from 'ug' script folder to be opened in 'cmd + 2' view with side bar hidden away. Is there a way to change it so that it opens in 'cmd + 2' view instead of 'cmd + 1'?

 

Thank you for sharing this.

(Duplicating my response to your question on github here)

Hi Nikita, This is a good idea; doing it this way would keep you at the context level you've already entered via Alfred. Ulysses has no apple scripting or callback support for the mac version. If you want to tinker with the workflow's interaction with Ulysses its not too involved.

 

I just tried getting Alfred to send a cmd-2 after opening the sheet or group. At first glance it works great, but actually Ulysses has an odd system in that this command toggles between which-ever view you had selected and 'sheets view' (cmd-2). I can't see a way around this except to read the state of a menu command (i.e. where the check mark is). This seems only to be possible if your global accessibility commands are switched on (http://stackoverflow.com/questions/69030/in-applescript-how-can-i-find-out-if-a-menu-item-is-selected-focused); not sure I'm keen to pursue this route though if it really needs to be on.

 

If you can work out series of manual interactions with Ulysses that always selects what we want, then I'd be pleased to add it to the workflow. I can't see one though.

--Rob

Link to comment

Hi guys,

 

Thanks for the suggestion @dunkaroo I've come up with two options:

 

1. Send cmd-3 and then cmd-2 after a .5s delay. This always ends up in the 'sheet view' as we'd like.

2. Use the applescript (probably superseding suggestion to use hamerspoon). This will cause Alfred to prompt the user to give Alfred Accessibility access to OSX the first time its run:

on run argv
  #activate application "Ulysses"
  delay .4
  tell application "System Events" to tell process "Ulysses"
    tell menu item "Sheets" of menu "View" of menu bar item "View" of menu bar 1
      if value of attribute "AXMenuItemMarkChar" is not "✓" then click
    end tell
  end tell
end run

This again suffers the delay as Ulysses will ignore the 'click' until it has opened the sheet or doc and switched to 3 pane (not sure why it always does this). Given the need to give Alfred (and any workflow installed) Accessibility access turns me off.

 

 I've uploaded to git a version with the first approach wired in. (Would add a u:setview command before releasing on Packal). Let me know if it works!

 

--Rob

 

P.S. Any way just to upload quick workflows on the forum. Github releases seem a bit heave for this type of thing!

 

 

 

 

Link to comment

Hi @katie, glad you like it! I'm finding it pretty handy too.

16 hours ago, katie said:

Would it be possible to include a search of the contents of sheets (like ⌘O in Ulysses)? I don't always remember the title of my sheets :) 

 

Firstly, have you tried the 'uo <search term>' command which takes the search term and opens up ⌘O in Ulysses with it? It would be nice to have this work directly in Alfred though. I left it out because I couldn't find an easy way to access the text surrounding the search term. Have just spotted that Spotlight does not do this, so I guess its not a deal breaker. If I get to it, I think I would remove 'us' (sheet) command which can be found with the 'u' command anyway and turn into a search command. Alternatively could keep it and call the new command 'uf' (find). Any thoughts?

Link to comment

Hi @robwalton!

 

Thanks for getting back to me. I have tried the 'uo <search term>' option and it works - as long as Ulysses is already open. If Ulysses isn't open, then I get two "something went wrong beeps" (as I call them), and Ulysses opens but the open dialogue doesn't. Because of this, I deactivated that keyword because a lot of times I don't want to open Ulysses, especially if it doesn't have what I'm looking for. I guess my computer is slow enough that waiting for a program (even one as light as Ulysses) to open so I can re-do a search, and (potentially) close it, is frustrating. 

 

I only use the 'us' and 'ug' keywords! I have a pretty formalized grouping system that 'ug' works great with and I can drill down to the group I need (amazing job on this). The downside of my system, as I mentioned, is that many sheet names are pretty useless or I don't really remember them (e.g. a sheet named "syllabus" in every course admin group). This is why a content search is so appealing to me - so I can check if something is in Ulysses before opening it up (and head right to the sheet, e.g. psy311) or make sure I've made a note of something without opening up Ulysses. And some sheet names are useful. What I'm trying to say is that I think there's a clear distinction between group and sheet searches (at least for me) so I think a new keyword 'uf' would be the best idea (and not to mix in sheet searches with groups as a 'u' search). If it's possible. And if you think it would be useful, too. 

 

As it is, I'm really happy with the workflow just so I can open the groups I need! It's what was missing for me to make the most of Ulysses (I used to use nvalt and there are some great workflows for it). Thank you for expending time and effort to build it!

 

 

Link to comment
  • 3 months later...
  • 2 weeks later...

Hi @nikivi & @dunkaroo especially, I've uploaded a new version to packal and github. By default groups are now opened in two pane view (Sheets) and sheets in 1 pane view (Editor only). There are two commands to change these 'u:setgroupview' and 'u:setsheetview'. For this to work Alfred needs accessibility access: the workflow pops up a message if it does not.

 

Release notes:

Quote

0.9.1

  • Added feature to select view for opening items with and commands to configure
  • Behind the scenes the workflow now uses (not enough of) deanishe's https://github.com/deanishe/alfred-workflow
  • Help now opens in Safari
  • 'ug' command no longer lets user drill into empty groups

@katie, didn't get to better searching yet, but it shouldn't be a biggy.

Link to comment
21 hours ago, dfay said:

Rob if you're adding to this actively I put up a draft for creating / appending from Alfred here: 

 

haven't had time to fully troubleshoot but maybe you want to run with it? :)

 

Hi dfay,

It looks like your commands to create a new sheet either from text entered in alfred or from a file would be pretty easy to integrate---I guess having captured the content for the new sheet we might pop up my workflow's 'ug' list filter to select the group in which to create the sheet. If you tried to create a new sheet with no content, it might create an empty sheet and then open it.

 

Not sure that the append to file one is really ready yet though (as you say)! This is the one I'd really like (I'd love a quick way e.g. to add an item to the Agenda sheet I keep in some groups). Along this line I could imagine a command to add to a group's 'inbox' sheet. The first time this was run in a group it could create a sheet and capture the x-callback reply with the id of the sheet. Steps and troubles:

1. would need to write and then register an os x url handler to act as the x-callback client that ulysses would call after creating the sheet

  2. would need to re-register the url handler when workflow is updated (and make sure old one isn't hanging around)

3. would need to maintain a mapping of group to id of group's 'inbox'

  4. if the group's path changed its mapping would become stale

5. subsequent requests to append to a group's 'inbox' would use the stored id

 

This solution (or simpler variants of it) seems like it would be hard to get working reliably without turning into actual work! And it still wouldn't be very complete.

Link to comment

Re #1 & 2 -- I've written a URL handler to allow creating a new Ulysses sheet that will subsequently be linked to a record in BibDesk -- the URL handler responds to ulbd:// and adds the newly created sheet to BibDesk -- but I've never changed it since (got it right the first time ;) ) so I'm not sure whether updating would break anything.  But...registering the URL handler is entirely done within the app bundle ( see http://www.macosautomation.com/applescript/linktrigger/index.html ) so I think if that app bundle was contained within the workflow directory and updated / replaced along with new versions of the workflow, the updating shouldn't be an issue. 

 

re: 3-5 -- moving groups and sheets around doesn't seem to change the IDs in Ulysses as far as I've observed, so I think one would just need to capture the group ID once.  Or are you saying you want to have an inbox sheet (with its own ID) for a group (with its own ID)?  In that case the inbox sheet could be separated from the group if the user rearranged stuff....  My use pattern is to just use the one Inbox and file stuff from there, so separate inboxes per group are outside my normal usage.

 

 There's also the possibility of using paths instead of IDs with groups but that seems rather error-prone.

 

 

 

Link to comment

Hi @dfay, Thanks for your the info on URL handlers. I've got one that lets you call arbitrary workflows with external inputs which is pretty cool---but off topic! May not have to use the callback part of x-callback though (also I think I misinterpreted you a while back):

 

On creating a new sheet in a group: I've been working on the workflow some. I brought across your file actions and new sheet command (in master); thanks for those and the good ideas. These prompt the user to select a group to create the new sheet in (shift-enter will add direct to the main Inbox). This works just using the group path rather than the id (seems to be reliable for me).

 

On appending within a sheet: Its easy to look at the note field for a sheet. I reckon if we just get folk to add a note of form id:o64TRsfrF8hWisC8Kmjrkg to a sheet, then the imagined 'append to sheet' command could find any sheets with an id in the note. Even cooler you could then add a smart filter to show all appendable sheets in Ulysses. This is a bit manual. With this we could add a ua command to append input to existing sheet and an 'Append to Sheet' file action.

 

--Rob

Link to comment
8 hours ago, dfay said:

Big update to the URL scheme today:

 

https://www.ulyssesapp.com/kb/x-callback-url/

I spotted that too. Definitely tips the balance into making the callback worthwhile! I have a version to release after I've updated @deanishes awesome workflow lib to new version at weekend; and will then start on the x-callback scheme, initially for appending to sheets.

Edited by robwalton
Link to comment

I've uploaded a new version 1.0 to packal and github. Big improvements are the addition of uf find command to search inside content and the introduction of fuzzy searching (from @deanishe's workflow) to other search commands. Don't know I lived without those two @katie. Also updates Alfred-Workflow to fix hanging in Sierra and add's @dfay's code for opening or importing files--no appending yet.

Quote

version 1.0

  • Fixed 100% cpu hang on Sierra with update of alfred-workflow to 1.25.1
  • Added `uf` command to find groups and sheets based on their internal content
  •  u, ug and uf now use fuzzy search Ulysses' path to groups and sheets
  • Added un command to create new sheet with optional text
  • Added Alfred file actions to open text-like files in Ulysses or to import them
  • Added support for Inbox items
  • Added support for local Ulysses (non-iCloud) items (still no external folders)
  • Added warning when no iCloud files found
  • Fixed race condition with `uo` command when Ulysses is not activated

 

Edited by robwalton
formatting
Link to comment
On 05/04/2017 at 2:53 PM, dfay said:

Big update to the URL scheme today:

 

https://www.ulyssesapp.com/kb/x-callback-url/

I've started work on a ulysses python client on github. Need to work out how to create a call back receiver which is quicker: it currently takes .4s which adds up. Looks like you can leave an NSApplication running in an app bundle running rather than depending on AppleScript firing up each time as it does now (example). 

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