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!
I tried workspaces several times but there must be something wrong with them in the current state, at least for me. Would really like to make use of them.
BTW is there a reason that the dictionary is missing a property that returns the current workspace?
Not sure, maybe accessibility. But with a “current workspace” property it will be possible to write a script and assign a shortcut. I prefer spending some time to set things up and afterwards never think about them again rather than digging around in menus