stretchly icon indicating copy to clipboard operation
stretchly copied to clipboard

[Feature request]: Support macOS Monterey's "Focus" modes

Open hesyifei opened this issue 3 years ago • 7 comments

Version

  • [X] I'm using version 1.9.0

Existing requests

  • [X] I've checked Existing requests

What operating system are you using?

macOS

Operating System Version

macOS 12.1

Problem description

macOS Monterey has the Focus feature that allows the user to have multiple different Focus modes beside Do Not Disturb. So one might also want to not show breaks when in certain Focus modes.

Possible solution

Instead of a checkbox option "Show breaks even in Do Not Disturb mode", allow setting a list of Focus mode (e.g., "Do not show breaks in these Focus modes:") where if the user is in one of those Focus modes, the app will not show breaks.

Though it does not seem to be an easy way to access the Focus mode. One could use INFocusStatusCenter but that would require native code. And I could not find how we could use AppleScript to get the current Focus mode.

Alternative solutions

On iOS, with Automation, one could run a Shortcut when entering or leaving a Focus mode. However, macOS's Shortcuts.app does not seem to support that yet. If macOS's Shortcuts.app adds support for this, we could easily just have two Automations: one runs a Shortcut that runs the stretchly pause command when entering a Focus mode, and one runs a Shortcut that runs the stretchly resume command when leaving a Focus mode (and then we could add a document in the repo showing how to set this up).

Additional information

Related to https://github.com/hovancik/stretchly/issues/969.

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

hesyifei avatar Jan 02 '22 16:01 hesyifei

If I understand correctly, you can set that up from macOS UI:

image

screenshot from https://appleinsider.com/articles/21/07/19/how-to-use-focus-mode-in-ios-15-macos-monterey

hovancik avatar Jan 12 '22 09:01 hovancik

I recently upgraded to Monterey, and it seems that Stretchly ignores Do not disturb mode? I'm not 100% sure here as I'm new to Focus mode, but as far as I can tell Focus mode turns on Do not disturb mode (slider is 'on', see screenshot). Screenshot 2022-01-26 at 13 42 05 Since I unchecked 'Show breaks even in Do not disturb mode' in the Stretchly settings, I expected no breaks to occur, but they do :(

Before I open a bug ticket, perhaps @hesyifei could share whether Stretchly ignores Do not disturb for them as well? I'm a bit confused about this entire Focus mode so perhaps I'm just doing something wrong.

StevenM1 avatar Jan 26 '22 12:01 StevenM1

@StevenM1 Yes, I am having the same problem where Stretchly ignores Do Not Disturb. I think the new Focus system makes the DnD detection stop working as well (since DnD is now just one possible Focus mode).

hesyifei avatar Jan 26 '22 17:01 hesyifei

Looks like the library I use does not support it, so we will have to wait: https://github.com/felixrieseberg/macos-notification-state/issues/26

hovancik avatar Jan 28 '22 14:01 hovancik

It seems PRs are already open with solution but repo owner has been unavailable for some time :/

axelcostaspena avatar Feb 09 '22 08:02 axelcostaspena

Think it was just merged - https://github.com/felixrieseberg/macos-notification-state/pull/27

StevenM1 avatar Feb 09 '22 08:02 StevenM1

We need to wait for https://github.com/felixrieseberg/electron-notification-state/issues/7 to be solved.

hovancik avatar Apr 20 '22 09:04 hovancik

@hovancik Any plans to fix this still? The dependency has a single more than 1.5 year old commit, so any changes there seem unlikely to me. Would using your Pull Request's version suffice?

Wikiwix avatar Oct 05 '23 08:10 Wikiwix

@Wikiwix I don't know as I don't have latest macOS version, only the old unsupported macbook. If you / someone could try running local version of stretchly with my PR and report, it would be great.

hovancik avatar Oct 07 '23 09:10 hovancik

@hovancik Sure, I am on macOS 14 and am willing to test it. You can either give me a dmg or point me to a stretchly feature branch with the changes included :)

Wikiwix avatar Oct 07 '23 09:10 Wikiwix

@Wikiwix here's the PR: #1378 branch feature/up-focus

Best to use node 18.15.0. I am using nvm to manage versions.

hovancik avatar Oct 07 '23 10:10 hovancik

@hovancik Thanks for the hint. I used the GitHub Action to build the app (I try to avoid installing anything node related on my computer🙈):

  • I needed to make this change for it to build
  • Trying to run it leads to the following error (after I removed the unsigned version from quarantine (reason for my other reported behaviours): image

Previous report (without me knowing about quarantine and the missleading error message by Apple…
  • ~~Trying to run the resulting .app marked with arm64 leads to the following error:~~ image
  • ~~Trying to run the version not suffixed with any architecture brings me the "not signed by trusted developer" warning and once I surpass that I got an "an error occurred" warning and after it closed I am back to the error screenshotted above~~

Wikiwix avatar Oct 07 '23 19:10 Wikiwix

~~Probably will have to do some more digging tomorrow: after reinstalling via brew I get the same error 🤔 . Any idea how this might happen?~~

See next comment

Wikiwix avatar Oct 07 '23 19:10 Wikiwix

@hovancik I updated my previous posts with updated results.

I had my first encounter with Apple's unhelpful Quarantine message. With having this sorted out (which means I am successful at reinstalling the current stable version) I still get the "An error occurred" message after which stretchly closes again

Sorry for the confusion…

Wikiwix avatar Oct 08 '23 05:10 Wikiwix

@Wikiwix the error message seems to be from Stretchly, so that's good news as it should generate error log. On mac sth like ~/Library/Logs/Stretchly/main.log

hovancik avatar Oct 08 '23 14:10 hovancik

@hovancik The path was correct. This should be the full log from the failed start:

Log lines
[2023-10-08 07:23:58.628] [info]  Stretchly: initializing...
[2023-10-08 07:23:58.631] [info]  Stretchly: loading preferences
[2023-10-08 07:23:58.636] [info]  Stretchly: starting Idle time monitoring
[2023-10-08 07:23:58.636] [info]  Stretchly: starting Do Not Disturb monitoring
[2023-10-08 07:23:58.671] [info]  Stretchly: loading default break ideas
[2023-10-08 07:23:58.692] [info]  Stretchly: loading default break ideas
[2023-10-08 07:23:59.647] [error] Error: Cannot find module '@meetfranz/electron-notification-state'
Require stack:
- /Applications/Stretchly.app/Contents/Resources/app.asar/utils/dndManager.js
- /Applications/Stretchly.app/Contents/Resources/app.asar/breaksPlanner.js
- /Applications/Stretchly.app/Contents/Resources/app.asar/main.js
-
    at Module._resolveFilename (node:internal/modules/cjs/loader:1082:15)
    at n._resolveFilename (node:electron/js2c/browser_init:2:117469)
    at Module._load (node:internal/modules/cjs/loader:927:27)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at Module.require (node:internal/modules/cjs/loader:1148:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at get _doNotDisturb [as _doNotDisturb] (/Applications/Stretchly.app/Contents/Resources/app.asar/utils/dndManager.js:37:14)
    at Timeout._onTimeout (/Applications/Stretchly.app/Contents/Resources/app.asar/utils/dndManager.js:45:33)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)
[2023-10-08 07:24:26.808] [error] TypeError: Object has been destroyed
    at Timeout.checkVersion [as _onTimeout] (/Applications/Stretchly.app/Contents/Resources/app.asar/main.js:680:16)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)
[2023-10-08 07:24:28.868] [error] Error: Cannot find module '@meetfranz/electron-notification-state'
Require stack:
- /Applications/Stretchly.app/Contents/Resources/app.asar/utils/dndManager.js
- /Applications/Stretchly.app/Contents/Resources/app.asar/breaksPlanner.js
- /Applications/Stretchly.app/Contents/Resources/app.asar/main.js
-
    at Module._resolveFilename (node:internal/modules/cjs/loader:1082:15)
    at n._resolveFilename (node:electron/js2c/browser_init:2:117469)
    at Module._load (node:internal/modules/cjs/loader:927:27)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at Module.require (node:internal/modules/cjs/loader:1148:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at get _doNotDisturb [as _doNotDisturb] (/Applications/Stretchly.app/Contents/Resources/app.asar/utils/dndManager.js:37:14)
    at Timeout._onTimeout (/Applications/Stretchly.app/Contents/Resources/app.asar/utils/dndManager.js:45:33)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)
[2023-10-08 07:24:31.280] [error] Error: Cannot find module '@meetfranz/electron-notification-state'
Require stack:
- /Applications/Stretchly.app/Contents/Resources/app.asar/utils/dndManager.js
- /Applications/Stretchly.app/Contents/Resources/app.asar/breaksPlanner.js
- /Applications/Stretchly.app/Contents/Resources/app.asar/main.js
-
    at Module._resolveFilename (node:internal/modules/cjs/loader:1082:15)
    at n._resolveFilename (node:electron/js2c/browser_init:2:117469)
    at Module._load (node:internal/modules/cjs/loader:927:27)
    at f._load (node:electron/js2c/asar_bundle:2:13330)
    at Module.require (node:internal/modules/cjs/loader:1148:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at get _doNotDisturb [as _doNotDisturb] (/Applications/Stretchly.app/Contents/Resources/app.asar/utils/dndManager.js:37:14)
    at Timeout._onTimeout (/Applications/Stretchly.app/Contents/Resources/app.asar/utils/dndManager.js:45:33)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7)

Wikiwix avatar Oct 08 '23 18:10 Wikiwix

Cheers! I see the issue now, somehow how I am installing from Github is not OK. I've been playing with it last 30 minutes but can't figure it out ;/

I've pushed update to my branch so you can try, but I think it will not work, still.

hovancik avatar Oct 08 '23 19:10 hovancik

Note to self: Maybe I will have to do some trickery: https://stackoverflow.com/questions/40528053/npm-install-and-build-of-forked-github-repo

hovancik avatar Oct 08 '23 19:10 hovancik

Well, this is beyond me :( Obviously the author of the library is busy to take a look at the issues and there seems to be many forks and I am not able to figure out WTF. I was able to move forward a bit and then it breaks my linux builds and TBH this is too much to comprehend as it is multiple libraries.

hovancik avatar Oct 13 '23 08:10 hovancik

@hovancik: With the platform independent wrapper being seemingly abandoned: Why not use the platform specific versions individually?

  • They do get regular updates
  • They are referenced in the official electron docs
  • The wrapper is only 30 lines and two trivial functions: https://github.com/felixrieseberg/electron-notification-state/blob/master/src/index.ts

Wikiwix avatar Oct 13 '23 10:10 Wikiwix

Yes, I worked on that today and PR is opened but as it goes with electron another unrelated thing is broken so there will be another thing to wait for

hovancik avatar Oct 13 '23 16:10 hovancik