A script for focusing on work, blocking non-work stuff.

Related tags

Utility work.sh
Overview

A script for focusing on work, blocking non-work stuff. The idea is to forbid mindless app/website context-switching while you're focused.

Once you're done, all blocked things are restored.

I find this workflow a middle ground between "block this specific thing forever" (which may only be sustainable for a season) and "don't block it" (which can excessively depend on willpower). In other words, temporary blocking is particularly fine-grained.

Since N things are blocked/unblocked at once, one gets to fiddle less with configs or UIs, so one is encouraged to focus more often and more heavily.

These are the techniques/apps being composed:

On focus in

  • Continuously ensures you're in a specific macOS space
    • I use the first space as a 'coding work' space (the other two ones being 'work communications' [mainly Slack] and 'personal')
    • Contexts.app makes macOS spaces actually useful.
      • Specifically you can use it to restrict command-tab on a per-space basis.
    • So, as soon as you switch to another space, the script will switch back to the targeted space.
  • Starts Thyme.app
    • It's a simple timer, it saves all timing history.
    • Normally I work in batches of ~1h; this way I can know if I'm undershooting / overshooting.
  • Starts Focus.app
    • Blocks selected websites and applications.
  • Marks you on Slack as absent
    • So that people will (hopefully) ping you less
  • Sets a custom Slack status explaining the prior point

On focus out

All previous steps are undone.

Requisites

gcc should be accessible (I think it's XCode that installs it).

# ensure latest:
brew install curl
# for `chronic` (which is not essential - can be stripped from the script): 
brew install moreutils

Ensure the Control + 0 shortcut is bound to "Switch to Desktop 1" (see https://apple.stackexchange.com/a/213566).

Usage

Clone this repo.

Reading the source is recommended - never run blindly scripts from the internet!

Run from a terminal:

# Token obtention is described in source
SLACK_TOKEN=... work.sh

...and leave that process open. (Normally I have a bunch of persistent tabs anyway, like Docker or a REPL. So it's not too obstrusive)

Ctrl-C will cleanly undo all effects and exit.

Notes

I don't use this script as-is; my copy has extra goodies. For example I also copy a restrictive hosts file to /etc/hosts on "focus in" and undo it later.

(For that reason the flush_dns_cache helper is bundled)

Credits

Uses a modified version of https://github.com/alt-jero/McSpaces, which in turn is based on https://archive.is/fy4JQ

You might also like...
MQTTNIO - Non-blocking, event-driven Swift client for MQTT build on SwiftNIO

This library has support for WebSocket connections and TLS. It runs on all platforms Swift NIO runs on (e.g. macOS, iOS, Linux, etc.).

πŸ”Œ  Non-blocking TCP socket layer, with event-driven server and client.
πŸ”Œ Non-blocking TCP socket layer, with event-driven server and client.

Original authors Honza Dvorsky - http://honzadvorsky.com, @czechboy0 Matthias Kreileder - @matthiaskr1 At the request of the original authors, we ask

A Swift Multiplatform Single-threaded Non-blocking Web and Networking Framework
A Swift Multiplatform Single-threaded Non-blocking Web and Networking Framework

Serverside non-blocking IO in Swift Ask questions in our Slack channel! Lightning (formerly Edge) Node Lightning is an HTTP Server and TCP Client/Serv

πŸ”Œ  Non-blocking TCP socket layer, with event-driven server and client.
πŸ”Œ Non-blocking TCP socket layer, with event-driven server and client.

Original authors Honza Dvorsky - http://honzadvorsky.com, @czechboy0 Matthias Kreileder - @matthiaskr1 At the request of the original authors, we ask

A Swift Multiplatform Single-threaded Non-blocking Web and Networking Framework
A Swift Multiplatform Single-threaded Non-blocking Web and Networking Framework

Serverside non-blocking IO in Swift Ask questions in our Slack channel! Lightning (formerly Edge) Node Lightning is an HTTP Server and TCP Client/Serv

Peanut is an orginizational application focusing on user customization whithin a simple interface.
Peanut is an orginizational application focusing on user customization whithin a simple interface.

Peanut Peanut is an organizational application focusing on user customization within a simple interface. Table of Contents User Features Architecture

building cool stuff with swiftui
building cool stuff with swiftui

Featured ✨ Clubhouse Drop-in audio chat View source code πŸ”Ž View Figma design 🎨 Watch me build πŸ‘€ Spotify Clone Music app View source code πŸ”Ž Tinder

List of awesome iOS & Swift stuff!!
List of awesome iOS & Swift stuff!!

Awesome iOS Developer Feel free to fork this repository and pull requests!! πŸ”Ž Content Coding Convention Swift Lint Design Pattern Adaptor Delegation

Headless iOS/Mac SDK for saving stuff to Pocket.
Headless iOS/Mac SDK for saving stuff to Pocket.

This SDK is deprecated Howdy all! πŸ‘‹ Thanks for checking out this repo. Your πŸ‘€ mean a lot to us. πŸ’— Unfortunately, this project is deprecated, and th

A library to manage NVRAM Stuff in Swift

libNVRAMSwift A Library to manage NVRAM Stuff, written in Swift. CLI Example utility here Library Usage Declare a new instance of the NVRAM Struct, fo

A library and CLI Utility to manage NVRAM Stuff, written in Swift.

NVRAMKit A Library and CLI Utility to manage NVRAM Stuff, written in Swift. Library Adding Library to Project Simply add this line to the dependencies

Class for logging excessive blocking on the main thread
Class for logging excessive blocking on the main thread

Watchdog Class for logging excessive blocking on the main thread. It watches the main thread and checks if it doesn’t get blocked for more than define

Work-hours-mac - Simple app that tracks your work hours from the status bar
Work-hours-mac - Simple app that tracks your work hours from the status bar

Track Your Work Hours Simple app that tracks your work hours from status bar. Fe

Script to support easily using Xcode Asset Catalog in Swift.
Script to support easily using Xcode Asset Catalog in Swift.

Misen Misen is a script to support using Xcode Asset Catalog in Swift. Features Misen scans sub-directories in the specified Asset Catalog and creates

PillowTalk - An iOS & SwiftUI server monitor tool for linux based machines using remote proc file system with script execution.
PillowTalk - An iOS & SwiftUI server monitor tool for linux based machines using remote proc file system with script execution.

An iOS & SwiftUI server monitor tool for linux based machines using remote proc file system with script execution.

Game of Life Use the custom SwiftLint script

Game of Life The deployement target of the project is iOS 13.0 and the project use cocopoads as dependency manager

Script to support easily using Xcode Asset Catalog in Swift.
Script to support easily using Xcode Asset Catalog in Swift.

Misen Misen is a script to support using Xcode Asset Catalog in Swift. Features Misen scans sub-directories in the specified Asset Catalog and creates

An executable that can be called from a Run Script Build Phase that makes comments such as // TODO: or // SERIOUS: appear in Xcode's Issue Navigator giving them project-wide visibility.

XcodeIssueGenerator An executable that can be called from a Run Script Build Phase that makes comments such as // TODO: or // SERIOUS: appear in Xcode

Pjmgmt - Pentest project management script

pjmgmt Managing pentest projects is a painful task, it often leads to files and

Owner
null
🚘 A simple tool for updating Carthage script phase

Do you use Carthage? Are you feel tired of adding special script and the paths to frameworks (point 4, 5 and 6 in Getting Started guide) manually? Me

Artem Novichkov 184 Dec 11, 2021
How Swift standard types and classes were supposed to work.

How Swift standard types and classes were supposed to work. A collection of useful extensions for the Swift Standard Library, Foundation, and UIKit.

Goktug Yilmaz 3k Dec 22, 2022
Extensions that allow you to work with optionals

RxOptionals Sometimes it happens that you need to bind to several optional binders or to an optional method (for example, when using weak). To do this

Dane4ka 3 Aug 9, 2021
Easy way to detect iOS device properties, OS versions and work with screen sizes. Powered by Swift.

Easy way to detect device environment: Device model and version Screen resolution Interface orientation iOS version Battery state Environment Helps to

Anatoliy Voropay 582 Dec 25, 2022
A non gesture blocking, non clipping by default custom scroll view implementation with example code

A non gesture blocking, non clipping by default custom scroll view implementation with example code

Marco Boerner 10 Dec 6, 2022
OpenSwiftUIViews - A non gesture blocking, non clipping by default custom scroll view implementation with example code.

OpenSwiftUIViews - A non gesture blocking, non clipping by default custom scroll view implementation with example code.

Marco Boerner 11 Jan 4, 2023
Stuff application – keep track of your stuff.

stuff-app Stuff application – keep track of your stuff. Platforms App to be released for iOS 15, iPadOS 15 and macOS 12 Monterey. Purpose Project is d

Danis Tazetdinov 1 Dec 15, 2021
Stuff application – keep track of your stuff

stuff-app Stuff application – keep track of your stuff. Platforms App to be released for iOS 15, iPadOS 15 and macOS 12 Monterey. Purpose Project is d

Danis Tazetdinov 1 Dec 15, 2021
πŸ”Œ Non-blocking TCP socket layer, with event-driven server and client.

Original authors Honza Dvorsky - http://honzadvorsky.com, @czechboy0 Matthias Kreileder - @matthiaskr1 At the request of the original authors, we ask

Vapor Community 574 Dec 7, 2022
A Swift Multiplatform Single-threaded Non-blocking Web and Networking Framework

Serverside non-blocking IO in Swift Ask questions in our Slack channel! Lightning (formerly Edge) Node Lightning is an HTTP Server and TCP Client/Serv

SkyLab 316 Oct 6, 2022