Small app that checks focus status under macOS 12

Related tags

Utility infocus
Overview

infocus

swift-version macos-version xcode-version

install

What

Small app for Mac Admins that checks focus status under macOS 11 and 12 and can be used to add Do Not Disturb support to management scripts.

Infocus runs from the command line. If the user has a Focus mode set, infocus exits with code 1, otherwise exits with code 0

For a pre-built preview, check the Releases page.

Why

Because you're a nice #MacAdmin that doesn't want to disturb your users with some popup or other event that ordinarily wouldn't adhear to macOS Notification framework.

How

Through the Magic of Swift! on macOS 11 it reads a local plist to get DND data. Under macOS 12 it uses the communications notifications entitlements but because of app sandbox rules that come with adding the entitlements, required for macOS 12, there is a seperate infocuscli binary included in the app bundle for use on macOS 11. Within the sandbox the app can't read the local plist. Fun.

Demo

The following script will run the correct version for the OS, check focus state and exit if focus/DND is enabled

#!/bin/zsh

infocusapppath="/Applications/Utilities/infocus.app"

autoload is-at-least
if is-at-least 12.0 $(sw_vers -productVersion); then
    infocus="${infocusapppath}/Contents/MacOS/infocus"
else
    infocus="${infocusapppath}/Contents/Resources/infocuscli"
fi

# Running Infocus - if DND is enabled (i.e. exit code is 1), then exit
if [[ -e ${infocus} ]]; then
  ${infocus} || exit 0
else
  echo "Infocus is not installed - Do Not Disturb preferences will not be considered" 
fi

# ... continuing with the rest of the script if focus/DND is not enabled.
# ...

Compiling

Requires Xcode 13.1 or newer, which includes the correct frameworks for macOS 12.

After building, run codesign --force --deep --sign - infocus.app on the app bundle to fix the signature for distribution.

You might also like...
Simple utility to change macOS Big Sur menu bar color by appending a solid color or gradient rectangle to a wallpaper image
Simple utility to change macOS Big Sur menu bar color by appending a solid color or gradient rectangle to a wallpaper image

Change menu bar color in macOS Big Sur Simple utility to change macOS Big Sur menu bar color by appending a solid color or gradient rectangle to a wal

A set of utilities (vmcli + vmctl) for macOS Virtualization.framework

VMCLI A set of utilities to help you manage VMs with Virtualization.framework Installation Prerequisites macOS Big Sur (11+) XCode.app installed # mak

SwiftyUpdateKit is a framework for iOS and macOS.
SwiftyUpdateKit is a framework for iOS and macOS.

SwiftyUpdateKit is a framework for iOS and macOS. This framework supports for a user to update your app when new app version is released on the App Store.

This is a Swift package with support for macOS that allows to start Java Jar's with the default or a custom JVM.

Jar.swift jar runner for macos Jar.swift is created and maintaned with ❥ by Sascha Muellner. What? This is a Swift package with support for macOS that

A simple macOS utility that can be used to control the behaviour of Bose QC35 Headphones straight from the menu bar.

bose-macos-utility A simple macOS utility that can be used to control the behaviour of Bose QC35 Headphones straight from the menu bar. Why Have you e

Hermes is a Swift 5 payload for macOS.

Hermes is a Swift 5 payload for macOS. This version currently supports Mythic 2.2.8 and will update as necessary. It will not work with Mythic 2.1 and lower.

Check for suspicious processes on macOS.

pschk Check for suspicious processes on macOS. Installation $ make $ sudo make install or $ brew tap x13a/tap $ brew install x13a/tap/pschk Usage USAG

A tiny macOS utility to foster sustainable OSS

SustainableOSS SustainableOSS is a status bar app for macOS that indexes the third-party dependencies your projects depend on, sorts them by usage, an

Easy CBOR encoding and decoding for iOS, macOS, tvOS and watchOS.

CBORCoding CBORCoding is a lightweight framework containing a coder pair for encoding and decoding Codable conforming types to and from CBOR document

Releases(v0.1)
  • v0.1(Oct 22, 2021)

    Includes the cli app (for macos 11 or older) inside the app bundle.

    on macos 10.15 and 11 run /Applications/infocus.app/Contents/Resources/infocuscli

    on macOS 12 run /Applications/infocus.app/Contents/MacOS/infocus

    So why are there two versions?

    In order to read focus preferences under macOS 12 the app needs to run within the App Sandbox. This prevents the pre-macOS 12 code from reading the do not disturb plist, even if the cli app is called automatically it will be within the sandbox. Running infocuscli directly does not incur the sandbox restriction.

    To run the app bundle for the first time, extract and run xattr -d -r /your/path/infocus.app or double click to launch, then open System Preferences -> Security $ Privacy -> General and click the "Launch Anyway" button.

    Source code(tar.gz)
    Source code(zip)
    infocus.zip(164.93 KB)
Owner
Bart Reardon
Bart Reardon
Checks if there is a newer version of your app in the AppStore and alerts the user to update.

YiAppUpdater Checks if there is a newer version of your app in the AppStore and alerts the user to update. Installation YiAppUpdater is available thro

coderyi 4 Mar 17, 2022
Focus is an Optics library for Swift (where Optics includes Lens, Prisms, and Isos)

Focus Focus is an Optics library for Swift (where Optics includes Lens, Prisms, and Isos) that is inspired by Haskell's Lens library. Introduction Foc

TypeLift 201 Dec 31, 2022
Another Virtualization.framework demo project, with focus to iBoot (WIP)

Virtual iBoot Fun This is just another Virtualization.framework sample project (WIP), but with focus on iBoot (iOS/macOS/tvOS/etc. bootloader) For a m

john 119 Dec 7, 2022
Sovran-Swift: Small, efficient, easy. State Management for Swift

Sovran-Swift: Small, efficient, easy. State Management for Swift

Segment 5 Jan 3, 2023
Add “Launch at Login” functionality to your macOS app in seconds

LaunchAtLogin Add “Launch at Login” functionality to your macOS app in seconds It's usually quite a convoluted and error-prone process to add this. No

Sindre Sorhus 1.3k Jan 6, 2023
Versions tracker for your iOS, macOS, and tvOS app

VersionTrackerSwift VersionTrackerSwift is a versions / builds tracker to know which version has been installed by a user. Usage In your ApplicationDe

Tom Baranes 82 Oct 5, 2022
macOS system library in Swift

SystemKit A macOS system library in Swift based off of libtop, from Apple's top implementation. For an example usage of this library, see dshb, a macO

null 323 Jan 5, 2023
A macOS application displaying the thermal, voltage and current sensor values.

Sensors About A macOS application displaying the thermal, voltage and current sensor values. License Project is released under the terms of the MIT Li

Jean-David Gadina 82 Jan 3, 2023
macOS utility for converting fat-frameworks to SPM-compatible XCFramework with arm64-simulator support

xcframework-maker macOS utility for converting fat-frameworks to SPM-compatible XCFramework with arm64-simulator support. ?? Description make-xcframew

Dariusz Rybicki 312 Dec 22, 2022
ALO sync allows you to sync resources form an ALO endpoint to your macOS file system.

ALO sync allows you to sync resources form an ALO endpoint to your macOS file system. Prerequisites macOS 11 No support for search* No suppor

Lawrence Bensaid 2 Jan 22, 2022