Yesterday, I noticed that the Stocks Dashboard widget in Mojave was no longer working. I couldn't find a similar (small window, always there, only stock prices) app that did what I wanted, but I did discover mop, a Go program that runs in Terminal. Using mop and Terminal's ability to save a window layout, I was able to craft a solution that worked for me.
Then commenter smayer97 asked…
Any solution to replace the mini-graphs at the bottom of the old Dashboard widget?
I didn't pay much attention to the graphs in the widget, so I hadn't considered them in my solution. And there's no way I was going to find a tidy graphing solution that also worked in Terminal. What I came up with isn't quite as convenient as having the graphs available at all times, but it's pretty close—I just have to click on a ticker symbol while holding down some modifier keys:
As you might have guessed, this is powered by a Keyboard Maestro macro, and I love how well it works.
If you'd like to use this macro yourself, download the file, unzip it, then double-click it. It will install itself in Keyboard Maestro, in a new Group named _Terminal (feel free to rename that if you wish). This group is set up to limit its macros to only working when Terminal is active—there's no need for this to be a global macro.
Note: After import, the group will be disabled; click the large 'x' icon next to the group's name to activate it (it will become a large checkmark).
The macro itself is relatively simple:
I used the This device key trigger, and set it to trigger when I press the mouse button with a couple modifier keys down—I used Shift and Command, but you can change these as you desire.
The macro has only six steps:
- A brief pause, which is needed to let the activation occur—without this, I found it sometimes didn't select and copy the ticker symbol.
- A double-click action, sent to the mouse's current location—you must be hovering over a ticker symbol for this to work. In macOS, a double-click over text selects all continguous text, so the ticker symbol is now selected.
- The selected text is copied.
- A URL is built with a charting site and the copied ticker symbol.
- The URL is opened.
- The variable used to create the charting URL is cleared.
As saved, the macro uses eTrade's charting page, but there are a number of different services available—and you can easily add others, assuming they have a URL format you can automate. Expand the Select a site to provide the charts section, and you'll see all of the options:
To switch to another chart service, click the gear icon next to e-trade's entry, and select Disable Action from the pop-up menu. Click the gear icon for the service you'd like to use, and select Enable Action from the pop-up menu.
You can only have one service active at a time. I mean, you can enable as many as you like, but the macro uses the same variable for every charting service—so whichever service is last in the list will wind up with the final URL that gets opened.
If you'd like to add your own charting service, select one of the existing entries and duplicate it—remember to disable the currently-active service, too.
There are only two things you need to change. First, click the gear icon on the duplicated service and select Rename from the contextual menu, then name it appropriately. Second, you need to edit the URL string, which looks like this for e-trade:
Change that to match the URl of the site you're using. The easiest way to do this is to generate a chart for some stock on that site, then copy the URL. Paste the copied URL into the action in Keyboard Maestro, and anywhere you see the stock's ticker symbol in the URL, replace it with %SystemClipboard%, which holds the copied URL. That's all you need to do.
I'm glad smayer97 asked that innocent question—I'm really liking the combination of a small tidy stock list window and charts available with a simple click of my mouse.
Very nice. And a fast and simple solution. Thx.
At the risk of stating what is probably most obvious but not explicitly stated, the graphing opens up and relies on the default browser, correct?
Any suitable cheap or free alternatives to KeyMaestro? If one does not already have KeyMaestro, it is a bit steep just for that purpose (unless one comes up with more uses).
Yes, it opens in the default browser, though Keyboard Maestro will let you specify one if you prefer.
My first try was to create an Automator service, but I got frustrated by its inability to manipulate text. But after reading your comment, I had a thought to just ignore Automator's inabilities, and use AppleScript within Automator...and it worked!
I'll post it very shortly as a new post, as I don't want to make this one even longer and more complicated.
Comments are closed.