July 06, 2014

Customizing window icons in your favorite program

Customizing a program's window icons

When you have a window open in your favorite program, most often the little widgets you see in the window interface—arrows, icons, symbols, etc.—are just a collection of images sitting in the Resources folder of the application bundle. That is to say, if you'd like to customize the look of the window, feel free to experiment with looking through the bundle and making your own alterations.
I will here demonstrate how to do so with everyone's favorite bible program, Accordance Bible Software. Accordance uses a pencil icon and a little note(s) icon in the right margin of a text to conveniently provide the user the opportunity to interact with their own user notes. Let's
explore how we could change the notes icon to something a little less subtle.
I have previously show how to customize the "Highlighting Symbols" that Accordance uses in "Taming the Symbols in Accordance". This process is very similar.

Note that altering the contents of a program bundle is certainly not something a program author should necessarily encourage. If you delete something accidentally, you will need to reinstall the app. Any changes you make inside an application bundle can likely get written over the next time you update the app.

Changing the notes icon in the margin in Accordance:

1. Quit Accordance.

2. Find the Accordance.app application file in Finder. It's probably in your /Application folder. (You can right-click (or ^ control-click) on the Accordance icon in the Dock and select ⇢More options⇢Show in Finder.

3. Right-click (or ^ control-click) on the Accordance app and select from the popup contextual menu ⇢Show package contents. You will see inside this new folder the innards of the application (that's technical jargon).

4. Navigate to the folder /Contents/Resources/Icons/  This folder contains all the images that the program uses to build it's interface. Scrolling down, you will find the pencil icon image is 11255.png. The Note image is 11260.png and the Notes image is 11261.png.

5. Select 11260.png and 11261.png in the Icons folder and copy them to your desktop or elsewhere for safe keeping, so you can always go back. Because these are in a application bundle, the files have extra protection, so you'll have to hold down the ⌥ option key to copy them. (A plus sign will show up as you drag. You down want the arrow sign which only creates an alias link to the files.)

6. Once again, select 11260.png and 11261.png in the Icons folder and delete them. Because of the special protections, you may be asked to authorize as an administrator with privileges.

7. Choose a replacement icon. You may want to use one of the other images in this /Icons folder. I like 10331.png as a little notes icon, or perhaps you'd like to use a small diamond dot, which is 294.png. You can even search the web for your own icon. Searching for "web dot png", I found a simple little round dot you could drag to the desktop. If you find your own image, keep it within the size of the original, which is 14 pixels wide x 18 pixels high.

8. Select the new image you want to use in Finder. Duplicate the file twice in menu ⇢File⇢Duplicate (assuming you wish to use the same image for a single note and multiple notes).

9. Select the file and rename it to 11260.png and another as 11261.png and move then into the /Contents/Resources/Icons/ folder if they are not already there.

10. Notice that there is also a folder beside the /icons/ folder called /icons@2x/. These are slightly larger versions of many of the same images for higher resolution uses. You can also do the same process for the images in this folder. The Notes images are within 28x40 pixels.

11. Restart Accordance and enjoy the new look. Don't like it? Change it.

If you wish to change the Notes image, chances are you also don't want the original Pencil image. You can change it as well, although there is an option to remove it all together in Accordance Preferences…/User Files/Hide Add User Note pencil.

Note: Here's an example of doing the same kind of thing for Dropbox, just altering the image files in the application bundle.

July 05, 2014

Creating a New Automation Service for Accordance

As of Accordance 10.4.3, Automator Actions are now included that allow you to build your own OSX Services as well as other Automator Workflows. The best starting place is to download the sample Services from Accordance, and get familiar with those, including the Instruction file included with them.
This is a tutorial on how you could go about building a new Service workflow, one that queries you for a verse reference in a dialog box and then inserts the full text of that reference in whatever document you're in. (This tutorial uses OSX 10.9.)

1. Launch Automator.app which is located in the /Applications folder.

2. When the dialog box for a new workflow shows up (you may have to select menu File/New), choose the option to create a new "Service". A Service is a special type of Automator Workflow that gets installed in the system-wide Services menu for quick access to automation tasks from inside other programs.

This opens a new Workflow in Automator. A Workflow is the palette that you can create individual steps for the Workflow to run that results in automated tasks being accomplished. The pane on the right is the canvas where you create the steps. The top pane on the left are the individual Automator Actions. These actions represents a large number of single tasks that can be added to the Workflow (by dragging them over). They are the building blocks of your automation Workflow. The pane below on the left shows the description of each Action... what kind of input it works on, what it accomplishes, what the results will be. As you add Actions to the Workflow on the right, the results (output) of one Action get passed on to the next Action in the Workflow.

3. Select menu File/Save and name the Service something descriptive of what it will accomplish. We will name this service "Acc - Query Insert Verses". The 'Acc' will group it with other Accordance Services, the 'Query' indicates it will first ask you for input, and the rest describes that it will insert the full text of the verses.

4. For creating our Service, the first task we need to accomplish is bringing up a dialog box to allow us to input the verse references we want to insert. There is an Automator Action called "Ask for Text", which brings up a dialog box. This Action is flawed, however, in that once it pops up you still have to click on it to type in it. So, we won't use it. We can overcome this flaw with a little Applescript. Find the Action titled "Run Applescript" and drag it into the Workflow space.

5.  Change the text of the default Applescript content to bring up a dialog box. You don't need to know anything about scripting to accomplish this. You might observe that the script will run every command between the words "on run" and "end run". So, let's change what the text runs.
Delete the line that says:
return input
(You can also delete the "(* Your script goes here *)" line if you like. It's just a comment.)
Paste the following command onto its own line, in between the "on run" and "end run" lines.
return text returned of (display dialog "Enter a verse reference:" default answer "")
Note that this text is all one paragraph. The result should look like this:

6. Next, find the Accordance Actions. You can do so by typing "acc" in the search bar above the Actions. You will see two Accordance actions. One is "View Text in Accordance". This Action building block is for taking references and searches and bring Accordance forward in order to run those searches in a new text or tool of you choosing. Find the Action called "Get Text From Accordance" and drag it underneath your Applescript action in the Workflow.

7. Select the options you desire in the "Get Text from Accordance" Action. The popup menu will populate with the short name of all the Text Modules you have installed in Accordance. I'm going to select "First Text Module" which will pull the verses from the module at the top of my module list in the Accordance Library. You can also choose whether the text is to be formatted using the Citation format you stipulate in Accordance Preferences, or if you prefer it to just use one verse per paragraph.

8. At the top of the Workflow, change the option to display "Service receives no input". This means that the Service does not require you to have anything selected in order to activate it (because you will be providing the input in a dialog box.)

9. Close to that option, select the option for "Output replaces selected text". This is what instructs the Service to insert the results of the Workflow into the current cursor/selection of your current document. This means that our Services will only be available in the Services menu when the current selection is a type of document that you can in fact edit/type into.

10. Save the Service Workflow and quit Automator, and you're done.

Now, you can be in a text document/email/etc. and insert verses quickly by:
1. Placing the curser where you want and invoking the Service "Acc - Query Insert Verses":

2. Enter a valid verse reference in the dialog box:

3. Enjoy the textual goodness that results:

You can peruse the Actions in Automator (especially those in the "Text" section) to get an idea of the possibilities of what you can create.
Note that the Service you just created, as well as the sample Accordance Services you should have installed, are located in ~/Library/Services/. If you want to add a new Service that's only a slight change from one you already have, you can select the file in that folder, duplicate it, open it in Automator by double-clicking, change the options (such as selecting "Second Text Module", rename the file and save and quit.
Note also, that if you have a Service you end up using often, do yourself a favor and add a global keyboard shortcut using the Apple Preferences / Keyboard Preferences.
You can find more information about this in the Instructions that come bundled with the sample Accordance Services.

July 03, 2014

Automation in Accordance 10.4.3

Accordance 10.4.3 has added new features that have opened up new avenues for automation. These new capabilities are the primary feature enhancement for this point upgrade.  I am delighted in their efforts.

The new features are:
1. A URI protocol that allows creators to embed links into web pages/pdfs/emails/other documents that will open Accordance to the specified text or tool, even searching the specified field for the specified text. This link will open your default text module and search for "Joseph": accord://search/;Words?Joseph

2. New Services that allow for
  • selecting text in some other document and searching for and viewing it in Accordance
  • inserting full text into your document
3. Two new Automator Actions that allow any number of automation applications (of which the above mentioned Services are actually just beginning examples of what can be created in Automator).

Since I have Applescripts and Services and Actions etc. floating around out there that have tried to fill the gap to date, I thought it would be helpful to update users on the new situation regarding automation.

I have for years produced the Accordance Script Library for automating Accordance. When users drug this into their ~/Library/Scripts folder, they could then use other scripts/services/actions  created by me and other industrious users for doing the same kinds of things the new Services make possible.

My Accordance Script Library pulled text out of Accordance invisibly using Applescript APIs (hooks that allow you to programmatically get data from a process). This capability will not change.
The Library also allowed for bringing Accordance to the front, opening a Tool of choice and running a search, but it accomplished all this through [quite] clever uses of User Interface Scripting—simulating menu selections, key presses and mouse-clicks through scripts. It was always clunky. The new URI protocols now accomplishes much of the same thing and makes it much more robust. A short Applescript can use the URI protocol to interact with Accordance, using the 'open location' command:

    open location "accord://search/;Words?Joseph"

In time, I will be rewriting the Accordance Script Library to use the URI protocols where appropriate to interact with Accordance.

One note, however, is that my previous Accordance Services are now obsolete. I will this weekend be removing them from my Downloads section, and join others in supporting Accordance's new options using Automator to create the Services you might like.