Plug-In: Toggle Focus for Folders Apple Vision Pro

A pair of plug-ins for toggling the focus of folders named: “Work” or “Personal.” If items are already focused, the plug-ins will either add or remove the folders from the array of focused items.

NOTE: If folders named “Work” or “Personal” don’t already exist at the top level of the OmniFocus Library, they will be automatically created.

TIP: On macOS, for quick access, place the plug-ins on the OmniFocus toolbar.

TIP: Once these plug-ins are installed, they can be triggered from within the Quick Open input by entering “T-O-G” and selecting the desired plug-in from the list.

Return to: OmniFocus Plug-In Collection

Toggle Focus: Personal
   

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automator", "identifier": "com.omni-automation.of.toggle-focus-for-personal", "version": "1.0", "description": "Toggles focus of folder titled “Personal.”", "label": "Toggle Focus: Personal", "shortLabel": "Toggle Focus: Personal", "paletteLabel": "Toggle Focus: Personal", "image": "folder.circle" }*/ (() => { const action = new PlugIn.Action(async function(selection, sender){ try { targetFolder = folderNamed("Personal") || new Folder("Personal") focusItems = document.windows[0].focus if(focusItems.includes(targetFolder)){ console.log("Removing Folder from Focus") index = focusItems.indexOf(targetFolder); if (index > -1) { focusItems.splice(index, 1) document.windows[0].focus = focusItems } } else { console.log("Adding Folder to Focus") focusItems.push(targetFolder) document.windows[0].focus = focusItems } } catch(err){ if(!err.causedByUserCancelling){ console.error(err.name, err.message) new Alert(err.name, err.message).show() } } }); action.validate = function(selection, sender){ return true }; return action; })();
Toggle Focus: Work
   

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automator", "identifier": "com.omni-automation.of.toggle-focus-for-work", "version": "1.0", "description": "Toggles focus of folder titled “Work.”", "label": "Toggle Focus: Work", "shortLabel": "Toggle Focus: Work", "paletteLabel": "Toggle Focus: Work", "image": "folder.circle" }*/ (() => { const action = new PlugIn.Action(async function(selection, sender){ try { targetFolder = folderNamed("Work") || new Folder("Work") focusItems = document.windows[0].focus if(focusItems.includes(targetFolder)){ console.log("Removing Folder from Focus") index = focusItems.indexOf(targetFolder); if (index > -1) { focusItems.splice(index, 1) document.windows[0].focus = focusItems } } else { console.log("Adding Folder to Focus") focusItems.push(targetFolder) document.windows[0].focus = focusItems } } catch(err){ if(!err.causedByUserCancelling){ console.error(err.name, err.message) new Alert(err.name, err.message).show() } } }); action.validate = function(selection, sender){ return true }; return action; })();