Welcome Guest.   Make a donation to an author on the site October 31, 2014, 10:49:21 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Read the Practical Guide to DonationCoder.com Forum Search Features
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1] 2 3 Next   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: FARR plugin: Akete  (Read 26294 times)
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« on: December 15, 2008, 03:04:29 AM »

Akete - FARR-specific file associations

Purpose

  FARR enables customization of the browser and/or file explorer used to "launch" URLs and files/folders respectively.  This plugin generalizes this idea for files based on filename extensions.  

  The original motivation for this plugin was to enable one to make use of and transport file associations without getting involved with the registry -- e.g. for portable application types of settings -- well, at least for files launched via FARR smiley

Usage

  To customize the handling for a specific file extension, first ensure that FARR's "Program Options -> Lists -> User Variables" setting has an [Akete] section.  

  Then create a line in that section of the form:

    <extension>=<executable-path>

where <extension> stands for the (typically 3-letter) file extension in question and <executable-path> is an appropriate path to an appropriate executable.

  For example, to handle PDF files using SumatraPDF, one might use the following sort of text (assuming here that SumatraPDF.exe is the name of the executable and that it lives in D:\Apps\):

    [Akete]
    pdf=D:\Apps\SumatraPDF.exe

  If all goes well, FARR should now launch all files that end in '.pdf' using SumatraPDF.

Credits

  Thanks go out to:

    mouser
    ecaradec
    phitsc
    Plugin authors that provided source and/or comments on the forums
    DC Forums participants
    DC Supporters

Download

  Stable MD5: 1c2fb4e40841437c48cf3f5070d9fa66
  Experimenting MD5: 58ebf5cc5a6b2ffa1a3c76a3348fccc1

If trying the Experimental version, please make sure to install the plugin in FARR's Plugins folder and name the folder for the plugin "Akete".

  



git repository containing code with various changes and restructuring

« Last Edit: January 19, 2013, 08:00:48 PM by ewemoa » Logged
phitsc
Honorary Member
**
Posts: 1,010



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #1 on: December 15, 2008, 04:42:06 PM »

Hi ewemoa. Good start Thmbsup. The plugin doesn't work as expected on my system though unless I assign something (anything, that is) to aliasstr. This reminded my of the problem I had when I was working on my (never released) OpenWith plugin. The onSearchBegins function was never called because I had left the default alias empty (because the plugin didn't need an alias). Maybe it's the same with onProcessTrigger?

Anyway, speaking of my never released OpenWith plugin. I think we've already concluded that the OpenWith plugin and your Akete plugin are similar. Maybe it would be a good idea to extend your Akete plugin to allow definition of "open with" keywords (using FARR's +keyword syntax) to launch files having the same file extension with different applications (what the OpenWith plugin does). I imagine something like this:

  [Akete]
    pdf=D:\Apps\SumatraPDF.exe
    OpenWithNpp=C:\Program Files\Notepad++\Notepad++.exe

and Akete not only launching .pdf files but also something like this: c:\My cool project\Config.xml +OpenWithNpp

I explained why I would like to have this functionality here by the way. The reason I never released the OpenWith plugin is that FARR keyword modifiers can't have spaces, i.e. something like +openwith=c:\program files\blah\blah.exe doesn't work. But by using defined keywords this would obviously not be a problem. With Akete doing this I could ditch the OpenWith plugin and would have something less to take care of Wink

Philipp
Logged

ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #2 on: December 15, 2008, 08:15:10 PM »

Thanks for the feedback and sharing of ideas smiley

The plugin doesn't work as expected on my system though unless I assign something (anything, that is) to aliasstr.

Strange.  What version of FARR are you using?  I just tested it locally with 2.34.01 and it looks like it works for me without modification.  Hmmm...

Quote
This reminded my of the problem I had when I was working on my (never released) OpenWith plugin. The onSearchBegins function was never called because I had left the default alias empty (because the plugin didn't need an alias). Maybe it's the same with onProcessTrigger?

Good question.

Quote
Anyway, speaking of my never released OpenWith plugin. I think we've already concluded that the OpenWith plugin and your Akete plugin are similar.

It is thanks to your generous sharing earlier that contributed to the birth of Akete Wink

Quote
Maybe it would be a good idea to extend your Akete plugin to allow definition of "open with" keywords (using FARR's +keyword syntax) to launch files having the same file extension with different applications (what the OpenWith plugin does). I imagine something like this:

  [Akete]
    pdf=D:\Apps\SumatraPDF.exe
    OpenWithNpp=C:\Program Files\Notepad++\Notepad++.exe

and Akete not only launching .pdf files but also something like this: c:\My cool project\Config.xml +OpenWithNpp

I think I follow this suggestion.  I intend to consider and experiment with trying to implement this.  I have been wary of using keywords in FARR because I have experienced difficulties working with them.  May be I can use this as an opportunity to improve my understanding.

Thanks for posting!
Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #3 on: December 15, 2008, 10:58:37 PM »

I've thought about this a bit more and I think there may be at least one difficulty w.r.t. implementing the proposal.  IIUC there isn't an easy way to programmatically enumerate the names of variables in User Variables (yet). 

I suppose I could try to parse FARR's ini file, but I don't think I want to go that route.

Another possibility is to use a different form of configuration in User Variables.  If all of the pairings of "OpenWith<X>", "<Path>" were stored in a different format -- e.g. as a kind of associative array under a single name -- then there would be no necessity of determining variable names because there would only be one hard-wired one.  I believe czb has applied this method in at least one (may be two or more) of his plugins -- through the use of JSON.  One potential drawback to this approach is that editing of User Variables becomes much more complex.
« Last Edit: December 15, 2008, 11:00:41 PM by ewemoa » Logged
mouser
First Author
Administrator
*****
Posts: 33,612



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: December 15, 2008, 11:12:47 PM »

Quote
IIUC there isn't an easy way to programmatically enumerate the names of variables in User Variables (yet).

i can add this easily in the new version to be released this week.
Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #5 on: December 15, 2008, 11:41:55 PM »

i can add this easily in the new version to be released this week.

That'd be great!

Upon further reflection on the matter though, I think it is the case that enumeration may not be necessary.  If the plugin can access the current set of keywords (which I believe it can via Search.keywords), it can attempt to access User Variables of specific names based on the set.

I intend to try this idea out.
Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #6 on: December 16, 2008, 12:49:10 AM »

Below is an initial implementation -- all that is needed to try it is to replace the content of the existing fscript.js.  Ah, and depending on one's environment, perhaps it is necessary to fill in aliasstr (still don't know what the issue is with that).

I was surprised to see that retrieving keywords via Search.keywords seems to give lowercased keywords.  Consequently, it looks like it's currently easier to use "openwith<string>" (all in lowercase) inside User Variables -- in fact, the current Akete code assumes this.

Formatted for Javascript with the GeSHI Syntax Highlighter [copy or print]
  1. /*global FARR, dan */
  2. var displayname = "Akete",
  3.    versionstring = "1.0.0.4",
  4.    releasedatestring = "Dec 16th, 2008",
  5.    author = "ewemoa",
  6.    updateurl = "",
  7.    homepageurl = "",
  8.    shortdescription = "Akete",
  9.    longdescription = "FARR-specific file associations",
  10.    advconfigstring = "",
  11.    readmestring = "FScript",
  12.    iconfilename = "Akete.ico",
  13.    //
  14.    aliasstr = "",
  15.    regexstr = "",
  16.    regexfilterstr = "",
  17.    keywordstr = "",
  18.    scorestr = "";
  19. // SEE THE BOTTOM OF THE FILE FOR MAKING GLOBAL ENTRY POINTS
  20. //
  21. // dan - (d)estructuring (a)ssignment (n)eeded :)
  22. // XXX: why the parens surrounding the function () { ... } below?
  23. //           seems to help notepad++'s Function List plugin
  24. // XXX: dan is not preceded by 'var' because then delete will fail...
  25. dan = (function () {
  26.      // emitResult() / onProcessTrigger() types
  27.  var UNKNOWN = 0, FILE = 1, FOLDER = 2, ALIAS = 3, URL = 4,
  28.      PLUGIN = 5, CLIP = 6, ALIASFILE = 7,
  29.      // postprocessing for emitResult()
  30.      IMMEDIATE_DISPLAY = 0, ADD_SCORE = 1, MATCH_AGAINST_SEARCH = 2,
  31.      // search state
  32.      STOPPED = 0, SEARCHING = 1,
  33.      // trigger results
  34.      HANDLED = 1, CLOSE = 2;
  35.  function onProcessTrigger(path, title, groupname, pluginid, thispluginid,
  36.                            score, entrytype, args) {
  37.    var i, ma, apppath, launchstr, kwds, owre, uvname;
  38.    switch (entrytype) {
  39.      case FILE:
  40.        kwds = FARR.getStrValue("Search.keywords").split(" ");
  41.        owre = /(openwith[^=]+)/;
  42.        for (i = 0; i < kwds.length; i += 1) {
  43.          ma = owre.exec(kwds[i]);
  44.          if (ma !== null) {
  45.            uvname = ma[1];
  46.            break; // XXX: end on first match
  47.          }
  48.        }
  49.        if (uvname === undefined) {
  50.          // XXX: dot inside square brackets escaping?
  51.          ma = /\.([^\.]+)$/i.exec(path);
  52.          // XXX: in general, better to handle an alias string w/
  53.          //      $$1-style interpolation, but not doing that yet
  54.          if (ma === null) {
  55.            return;
  56.          }
  57.          uvname = ma[1];
  58.        }
  59.        try {
  60.          apppath = FARR.getStrValue("uservar.Akete." + uvname);
  61.        } catch (e) {
  62.          // XXX: log or feedback?
  63.          return;
  64.        }
  65.        // XXX: check whether path makes sense?
  66.        if (apppath !== "") {
  67.          launchstr = apppath + " " + "\"" + path + "\"";
  68.          FARR.setStrValue("launch", launchstr);
  69.          return HANDLED | CLOSE;
  70.        }
  71.        return;
  72.        //break;
  73.      default:
  74.        return;
  75.    }
  76.    return;
  77.  }
  78.  return [onProcessTrigger];
  79. } ());
  80. // defined entry points
  81. var onProcessTrigger = dan[0];
  82.  
  83. // jslint complains, but mdc documentation on delete suggests this should work
  84. delete dan;
  85.  
  86. // Local Variables:
  87. // c-basic-offset: 2
  88. // End:
Logged
phitsc
Honorary Member
**
Posts: 1,010



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #7 on: December 16, 2008, 05:04:47 AM »

Works perfectly! Even with an empty aliasstr now which is really strange.

Concerning parsing FARR's ini file: I agree that it's probably not a good idea. I am nevertheless doing it currently in my never released Windows Search plugin to query the max. entries to display values. It would really be good to have an officially supported way to query some FARR settings (sorry, just wanted to use this chance to repeat that yet again Wink)
Logged

ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #8 on: December 16, 2008, 06:30:35 AM »

Glad to hear it's working for you!

I have my fingers crossed for the enumeration feature smiley
Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #9 on: December 23, 2008, 11:07:12 PM »

With the latest FARR beta (2.42.03), it is possible to have custom context menu items per result.

I have modified Akete to make use of this functionality.

If anyone is interested, I can upload my latest -- if there is no hurry, there may be a few more things I might attend to before releasing another version.
Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #10 on: December 25, 2008, 04:58:52 AM »

I added a few more things -- and there is an updated README.txt Wink

If interested, please see attachment.

* Akete-1.0.1.0.zip (126.36 KB - downloaded 211 times.)
Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #11 on: December 25, 2008, 07:47:28 AM »

Incorporated some feedback from mouser, removed a bug, and gave it a bit of polish.

* Akete-1.0.1.1.zip (126.61 KB - downloaded 224 times.)
Logged
mouser
First Author
Administrator
*****
Posts: 33,612



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #12 on: December 25, 2008, 01:19:24 PM »

It's confusing to have the download in the first link and also attached..
Maybe best is to always update the one linked to in the first post, and then later on in the thread you can always just say:
"download the latest from the link in the first thread" instead of attaching?
Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #13 on: December 25, 2008, 09:49:49 PM »

I wanted to make a distinction between what I considered more-or-less usable (what's in the first post) and what I considered more-or-less speculative smiley

I suppose I could put 2 links in the first post...
Logged
mouser
First Author
Administrator
*****
Posts: 33,612



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #14 on: December 25, 2008, 09:54:43 PM »

Quote
I suppose I could put 2 links in the first post...
better!
Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #15 on: December 25, 2008, 10:05:22 PM »

Ok, ok -- it is done smiley
Logged
raybeere
Supporting Member
**
Posts: 94


see users location on a map View Profile Read user's biography. Give some DonationCredits to this forum member
« Reply #16 on: January 09, 2009, 04:21:36 PM »

This is a great idea, but from my point of view there are two things that keep it from being useful when run from a USB stick. (At least from the description. I haven't tried it out yet. The last time I played around with anything on my stick, I was very, very sorry.) First, I'd like to see a simple way to turn it on and off, so when I wanted to use my own machine's associations, I could. (I do this when setting up a stick on my machine to keep the programs on it from running, so I get less reads / writes to the stick.) Second, I'd like to see a way to specify the relative path from the root without needing to specify a drive letter. After all, if I have to use my stick on another machine, I have no idea what letter it will be assigned - and if I'm doing that, nine times out of ten I'm in no mood to go in and change a bunch of settings right then.

Two other nice features would help out, a lot. One would be a chance to specify two options, by keyword, such as Open and Edit. I think the point there should be pretty clear. The other one is a workaround for a particular program I use, Liquid Story Binder XE. It is a great writing program, but it has one quirk. All files are arranged in a "library" by "book" - each book is a folder under one user-specified folder for the library. Each book actually contains a whole set of files. So, to open a "book" in LSB, you have to run LSB with the book's folder specified in the command line or shortcut. Is there any way to let the user specify such behaviour? (Open X app with the path of the selected file specified, but strip away the filename...)
« Last Edit: January 09, 2009, 04:23:09 PM by raybeere » Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #17 on: January 10, 2009, 05:42:10 AM »

First, I'd like to see a simple way to turn it on and off, so when I wanted to use my own machine's associations, I could.

I have an idea or two about this -- I intend to figure out whether they are practical.

Quote
Two other nice features would help out, a lot. One would be a chance to specify two options, by keyword, such as Open and Edit. I think the point there should be pretty clear.

If it doesn't have to be by keyword, there is already a way to specify multiple paths for each file extension -- this information is used in augmenting the context menu for a search result by a context menu item per path (you end up seeing something like "Open with myapp.exe" for each path).  I think I documented this feature in the README.txt of the plugin, but I don't recall at the moment.

Quote
The other one is a workaround for a particular program I use, Liquid Story Binder XE. It is a great writing program, but it has one quirk. All files are arranged in a "library" by "book" - each book is a folder under one user-specified folder for the library. Each book actually contains a whole set of files. So, to open a "book" in LSB, you have to run LSB with the book's folder specified in the command line or shortcut. Is there any way to let the user specify such behaviour? (Open X app with the path of the selected file specified, but strip away the filename...)

Currently, this is not supported.  mouser made a similar suggestion and we have discussed the possibility of support for something like what one can specify for an alias string.  So for example, you might be able to express something like:

  %PROGRAMFILES%\Something\Another.exe /p /e "$$1"

and $$1 would get filled in with the file identified via FARR and %PROGRAMFILES% would get resolved to the relevant path.

I intend to investigate this further too.
Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #18 on: January 13, 2009, 09:34:12 AM »

I am drafting some documentation for a newer version and thinking that it may act as a specification.  This post should contain my first attempt.  Feedback is welcome Wink


Edit: Updated draft
« Last Edit: January 14, 2009, 03:45:58 AM by ewemoa » Logged
mouser
First Author
Administrator
*****
Posts: 33,612



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #19 on: January 14, 2009, 04:18:14 AM »

great stuff ewe, very clear and great functionality!!
the only thing that would be nice is maybe to think of something shorter than "openwith" as the prefix needed for that function.
Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #20 on: January 14, 2009, 06:38:05 AM »

Thanks for taking the time and making the effort to read the draft -- I really appreciate it!

As to the keywords that begin with "openwith", I chose this based on phitsc's example and am not particularly attached to it -- except that if it's changed, I guess trying to maintain backward compatibility might be something to consider.

Oh no, don't say we should be able to configure what the keyword starts with via FARR User Variables! Wink
Logged
phitsc
Honorary Member
**
Posts: 1,010



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #21 on: January 14, 2009, 06:57:46 AM »

I agree with mouser, looks very good!

As to the keywords that begin with "openwith", I chose this based on phitsc's example and am not particularly attached to it -- except that if it's changed, I guess trying to maintain backward compatibility might be something to consider.
And neither am I. Wouldn't give me a lot of work if you changed it. I'm no big fan of abbreviations though, so I still think openwithnpp would be clearer than something like e.g. ownpp.

What about just using the same definition as used for extensions, e.g. if one specified something like:

txt=%PROGRAMFILES%\Windows NT\Accessories\wordpad.exe

then it would open .txt files with Wordpad, but one could also do this:

C:\boot.ini +txt

and it would also open with Wordpad.

I could then choose whatever definition I liked (even openwithnpp Wink ) and since there are no files with an extension of .openwithnpp it would just work with this C:\boot.ini +openwithnpp. You would have to check if it might give problems with other keywords though.
Logged

ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #22 on: January 14, 2009, 07:59:02 AM »

Thank you phitsc, for also taking the time and making the effort to read the draft and comment on it smiley

The idea you suggested sounds interesting.  As you pointed out, there does seem to be a potential issue with keyword collision and I am mulling over what might be done about that.  Perhaps allowing a configurable prefix (which defaults to something) for the keyword and reusing the definitions from file extensions as you suggested might work out.

My impression at the moment is that having a particular prefix helps in picking out an appropriate keyword from the query.  Supposing that there is no particular prefix string for the keywords this plugin should handle, if a query contains multiple keywords, I am not sure how to decide which keyword (possibly multiple?) should be selected by the plugin.

Regarding a default keyword prefix, "open" or "with" seem like possibilities to me.

What do folks think?
Logged
mouser
First Author
Administrator
*****
Posts: 33,612



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #23 on: January 14, 2009, 08:18:04 AM »

both prefixes seem good to me, or even use "ow" as a prefix (for open with)
so
+owtxt
would open with whatever is configured as txt editor.
Logged
ewemoa
Honorary Member
**
Posts: 2,484



View Profile Give some DonationCredits to this forum member
« Reply #24 on: January 15, 2009, 08:38:33 AM »

I think I'll go with a default of "with" as the prefix, provide a way to change the prefix, and leverage any existing file extension association configuration so that it may be used with a keyword (e.g. if you have an association defined for 'html', then the plugin should recognize the keyword 'withhtml').

I discovered that one can use period-separated names for both section names (e.g. "Akete.Options") and variable names (e.g. "Options.KeywordPrefix") in FARR User Variables.  Also, that:

  [Akete.Options]
  KeywordPrefix=test

ends up being the same (?) as (at least as far as requesting the value from FARR is concerned):

  [Akete]
  Options.KeywordPrefix=test

I'm currently leaning toward suggesting the use of the variable names in the official documentation.
Logged
Pages: [1] 2 3 Next   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.123s | Server load: 0.04 ]