Macjutsu / super

S.U.P.E.R.M.A.N. optimizes the macOS software update experience.
Apache License 2.0
609 stars 82 forks source link

Feature request: Option(s) to manage focus filters #25

Open wakco opened 1 year ago

wakco commented 1 year ago

I was looking at the focus code, and I was wondering if we could allow for managing the kinds of focus, for example, I have 4 focus settings setup and scheduled, so my devices are always in one focus or another, so I'm looking for a way of identifying the difference.

What I'm thinking is identifying the difference between a custom focus, and a standard focus like Do Not Disturb or Sleep, I've discovered from your code that they can be filtered and differentiated: % plutil -extract data.0.storeAssertionRecords.0.assertionDetails.assertionDetailsModeIdentifier raw -o - "/Users/wakco/Library/DoNotDisturb/DB/Assertions.json" com.apple.sleep.sleep-mode % plutil -extract data.0.storeAssertionRecords.0.assertionDetails.assertionDetailsModeIdentifier raw -o - "/Users/wakco/Library/DoNotDisturb/DB/Assertions.json" com.apple.donotdisturb.mode.default % plutil -extract data.0.storeAssertionRecords.0.assertionDetails.assertionDetailsModeIdentifier raw -o - "/Users/wakco/Library/DoNotDisturb/DB/Assertions.json" com.apple.focus.work % plutil -extract data.0.storeAssertionRecords.0.assertionDetails.assertionDetailsModeIdentifier raw -o - "/Users/wakco/Library/DoNotDisturb/DB/Assertions.json" com.apple.focus.personal-time % plutil -extract data.0.storeAssertionRecords.0.assertionDetails.assertionDetailsModeIdentifier raw -o - "/Users/wakco/Library/DoNotDisturb/DB/Assertions.json" | grep -v focus | grep -ic com.apple. 0

As you can see, a custom focus is identified as com.apple.focus.name while a standard focus identifies the focus type without the word focus.

This option would however require being limited to macOS 12 Monterey or newer. I checked macOS 11,12,13, and saw the code for macOS 11 and earlier was not as flexible.

Macjutsu commented 1 year ago

Gold star for you! Not only is that a great idea, you provided example code!

In my mind this feature would also bookend a method to mange different kinds of display assertions. For example it's probably important to avoid interrupting the user if they are in a Zoom, but not while watching YouTube. Both set a screen assertion, and right now super considers any screen assertion as equally valid.

Worshipping this idea... how would you "feature-ize" this? Would you want to define a list of focus states that are allowed always... or ignore certain focus types? For example; --focus-allow=thing1,thing2 and --focus-disallow=thing1,thing2. Again, the goal is to provide the most straight forward options for the command string.

Full disclosure though, I have to get major upgrades working first...

wakco commented 1 year ago

As far as "major upgrades working first..." goes, yes, I already consider this idea a minor feature.

In the long run, yes, but maybe also a basic on/off as well, where when turned on, if those two options are empty, then just the basic idea of filtering a custom focus, i.e. --focus-filter, and --no-focus-filter, with --focus-(dis)allow=thing1,thing2 both requiring --focus-filter.

So turning it on, and leaving the allow/disallow options empty, defaults to filtering the word focus. Setting the allow/disallow options to anything, would override the basic focus filter. Turning it off, lets it operate the way it is now (which should remain the default if neither option is supplied).

In short most people probably are not using the Focus feature intentionally (that is they have no custom focus'), so allowing for the basic just focus makes it easier for admins.

iDrewbs commented 1 year ago

I was just about to submit this as a feature request and am glad I see someone already had the idea. I agree with the idea to use --focus-allow=thing1,thing2 and --focus-disallow=thing1,thing2 options. I've been using the Work focus mode lately and would like to make sure that doesn't block super, along with something like YouTube.

wakco commented 1 year ago

Oh as a minor workaround for anyone interested in editing their copy of super for this, find the line that reads: focusSTATUS=$(plutil -extract data.0.storeAssertionRecords.0.assertionDetails.assertionDetailsModeIdentifier raw -o - "/Users/$currentUSER/Library/DoNotDisturb/DB/Assertions.json" | grep -ic com.apple.)

And insert either grep -v com.apple.focus | or grep -v com.apple.focus.FocusNameHere | before the existing grep, i.e. focusSTATUS=$(plutil -extract data.0.storeAssertionRecords.0.assertionDetails.assertionDetailsModeIdentifier raw -o - "/Users/$currentUSER/Library/DoNotDisturb/DB/Assertions.json" | grep -v com.apple.focus | grep -ic com.apple.)

This is what I have been doing with mine. Note: grep can take multiple -v's allowing for the identification of multiple custom focuses.