Skip to content

btf-org/flocus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flocus

By the end of the day, I have too many windows open to think. If you were to watch my screen, you'd think there was a monkey behind the keyboard who got a banana every time he opened a new browser tab.

I built this system using Applescripts (very underrated) to purposefully move from one window configuration to another in OSX (browser tabs, Notion pages, open applications)

Check out the demo!

Screen Shot 2022-03-29 at 3 50 24 PM

Contributors Welcome!

I'd like to keep improving this and share the benefits with others. If you'd like to contribute, fork it or reach out to me

TLDR Setup

  1. Install FastScripts
  2. Make Flocus an Applescript Library
# cd into root of project
. install.sh
  1. Copy a script into FastScript's script library
mkdir -p ~/Library/Scripts
cp examples/notion-slack-brave.applescript ~/Library/Scripts
  1. You should see it show up in the FastScript menu bar dropdown Screen Shot 2022-01-05 at 9 54 49 PM

More Explanation

Applescript Library

src/Flocus.applescript is a collection of functions, aka "handlers" in Applescript terminology. To make these "handlers" globally visible to Applescripts, they need to live in ~/Library/Script Libraries (or one of the other 7 default path locations ). Running install.sh will move Flocus into the right folder for you.

Text versus Compiled Applescript

If you use Script Debugger or Script Editor to save scripts as .app or .scpt, the script will get compiled and will be unreadable. For the sake of source control, Flocus is saved as plain text (.applescript). install.sh compiles it while moving it into ~/Library/Script Libraries.

FastScripts

FastScripts is a menu bar dropdown for running your scripts. This is helpful for a couple reasons:

  1. It provides quick and easy access to running scripts
  2. FastScripts is the entrypoint, so if you give it, say, permission to access Finder, you only have to do so on FastScripts, instead of having to permission each one of your individual scripts.

By default, FastScripts will include folders that you likely don't care about. To only show the one folder with your scripts, quit FastScripts, run the following, then restart.

defaults write com.red-sweater.fastscripts3 ScriptTreePathsKey '("~/Library/Scripts")'

Example Usage

This piece of code calls a handler/function called flocus that...

  1. Closes every application except for Finder, Notion, Slack and Brave
  2. Closes every Brave tab except for Instapaper
  3. Closes every Notion window except for the one specified in the URL
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use script "Flocus"

on run
	set whiteList to {"Finder", "Notion", "Slack", "Brave Browser"}
	set webURLs to {"https://www.instapaper.com/u"} -- Applescript lists are contained within curly brackets 
	set notionURLs to {"notion://www.notion.so/Public-Notion-Page-Example-2b2841ed7e3a4335aa3f854d3efe9b22"}
	tell script "Flocus" to flocus(whiteList, webURLs, notionURLs)
end run

About

Purposefully move from one window configuration to another (browser tabs, Notion pages, open applications)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors