(By the way, @BLUEFROG, I went ahead and bought Sal S.'s book 1-2-3 Applescript based on our discussions on this forum)
Nice! Sal is the Man, for sure. He and Shane Stanely are giants in Mac automation.
(By the way, @BLUEFROG, I went ahead and bought Sal S.'s book 1-2-3 Applescript based on our discussions on this forum)
You can change the icon for the script in the Finder, but currently it will be bounded in a button. Like so…
@cgrunenberg would have to assess whether this can be changed to allow for just displaying the icon itself. (I’m guessing it would not be a simple change.)
A couple changes:
*improved the dialog for selection
*@ngan added code to close all open windows before loading the new ones
-- Load Workspace
-- from a list of all saved workspaces
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application id "DNtp"
try
set theWorkspaces to workspaces
set mychoice to (choose from list theWorkspaces with prompt "Load this workspace" default items "None" OK button name {"Load"} cancel button name {"Cancel"})
if mychoice is not false then
set theSelection to item 1 of mychoice
close every think window
load workspace theSelection
end if
end try
end tell
This script can be paired with the following script, which will save your workspace to one of your saved ones. If you put these scripts in the tool bar, it makes it easy to load and save workspaces for individual projects, etc.
-- Save Current Workspace
-- to a list of all saved workspaces
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application id "DNtp"
try
set theWorkspaces to workspaces
set mychoice to (choose from list theWorkspaces with prompt "Save this workspace to:" default items "None" OK button name {"Save"} cancel button name {"Cancel"})
if mychoice is not false then
set theSelection to item 1 of mychoice
save workspace theSelection
end if
end try
end tell
In this forum, u can ask for anything and very likely will be getting a response. FYI, I also didn’t know where to place a script and not even understand what a script is about 18 months ago.
For putting script under the toolbar menu, see pg 179-180 of the manual. Just remember to quit and re-open DT3 AFTER you place the script in the folder. The customisation of button is mostly similar to other app, ctrl-click the toolbar and you see a list of buttons for drag and drop on to the toolbar.
Also even if you aren’t on DevonThink, combined with bring DT front and your script, this script brings DT front then brings window to choose workspaces.
activate application "DEVONthink 3"
tell application "System Events"
tell process "DEVONthink 3"
try -- Symbols
set focused of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of window 1 to true
end try
try -- List
set focused of outline 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of window 1 to true
end try
try -- Columns
set focused of scroll area -2 of scroll area 1 of browser 1 of splitter group 1 of group 1 of splitter group 1 of splitter group 1 of window 1 to true
end try
try -- Two pane
set focused of outline 1 of scroll area 1 of splitter group 1 of group 1 of splitter group 1 of splitter group 1 of window 1 to true
end try
try -- Three pane / Tags
set focused of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of group 1 of splitter group 1 of splitter group 1 of window 1 to true
end try
end tell
end tell
tell application id "DNtp"
try
set theWorkspaces to workspaces
set mychoice to (choose from list theWorkspaces with prompt "Load this workspace" default items "None" OK button name {"Load"} cancel button name {"Cancel"})
if mychoice is not false then
set theSelection to item 1 of mychoice
close every think window
load workspace theSelection
end if
end try
end tell
(1) Create a dummy file anywhere in any database, and gets its uuid, but never delete it. (2) Also drag and drop the dummy to the “Favorites”. (3) Add two more lines of script to ur workspace-loading script.
Every time you change the workspace, the dummy filename changes accordingly.
Just a suggestion.
tell application id "DNtp"
try
set theWorkspaces to workspaces
-- get the dummy that is under "Favorites", I just make-up an arbitrary uuid here
set wsFlag to get record with uuid "3874ABCB-2073-46A9-ABA4-730A8BF70C40"
set mychoice to (choose from list theWorkspaces with prompt "Load this workspace" default items "None" OK button name {"Load"} cancel button name {"Cancel"})
if mychoice is not false then
set theSelection to item 1 of mychoice
close every think window
load workspace theSelection
-- or any naming format you'd like to use
set name of wsFlag to "*Workspace: " & theSelection
end if
end try
end tell
Just want to make sure that I’m not misleading you. The added lines just change the name of the dummy to reflect which workspace has been loaded coz you mentioned that you forget which workspace is loaded sometimes.
No, the dummy doesn’t need to be in favourites. Just that I thought you may want to see that right in the sidebar. It is one possible idea and there is no need to waste too much time on it…
No, I get it. It’s using the dummy file as a way to store the currently active workspace. I just made the following script to update the current workspace.It looks up your dummy file, trims out the name of the workspace from it, and saves the current workspace to it.
tell application id "DNtp"
try
--change uuid to the item link of your dummy file
set wsFlag to get record with uuid "043DA815-DB89-46D5-A0B7-D403D724365E"
--assumes the name of this file is "*workspace: " + the workspace name
set wsName to the name of wsFlag as text
set wsName to ((characters 13 thru -1 of wsName) as string)
save workspace wsName
beep
end try
end tell
I’m not a fan of using “characters 13 thru -1” to strip out the prefix, but I couldn’t find a simple command to remove a substring. Anyone have a suggestion for how remove a substring (e.g. "*workspace: ") from a longer string (e.g. “*workspace: savedname”)?
@dansroka By chance, do you know if it’s possible to limit the windows that DEVONthink saves for a given workspace? For example, is it possible to only save the frontmost window or those on your current desktop/space?
Like yourself, I use a lot of workspaces (and use a similar script, which I feed into Alfred to make the selection and saving of workspaces a little easier). At any given time, I usually have a few different workspaces open - which makes updating them tricky (i.e., because it requires opening a closing the windows that aren’t associated with a particular workspace). In any case, given your use of workspaces, I just thought you might have a trick for this. Thanks for your help!