Alternative way to check zen mode enabled

I’m using ToggleZenModeAction.isZenModeEnabled(project) to check if zen mode enabled.

Now the API marks internal since 2026.1 EAP, it’s there any alternatives?

You can see how it is implemented:

    fun isZenModeEnabled(project: Project): Boolean {
      if (!DistractionFreeModeController.isDistractionFreeModeEnabled()) {
        return false
      }
      if (isFullScreenApplicable()) {
        val frame = project.getFrame()
        if (frame != null && !frame.isInFullScreen) {
          return false
        }
      }
      return true
    }

You mostly need DistractionFreeModeController.isDistractionFreeModeEnabled()

Actions in general are not really API

Thanks for the fast reply.

I did this:

private fun Project.getFrame() = WindowManagerEx.getInstanceEx().findFrameHelper(this)

        private fun isZenModeEnabled(project: Project): Boolean {
            if (!DistractionFreeModeController.isDistractionFreeModeEnabled()) {
                return false
            }
            if (WindowManager.getInstance().isFullScreenSupportedInCurrentOS) {
                val frame = project.getFrame()
                if (frame != null && !frame.isInFullScreen) {
                    return false
                }
            }
            return true
        }

but the findFrameHelper is another internal API…

Or maybe this is the right solution?

fun isZenModeEnabled(): Boolean {
   return DistractionFreeModeController.isDistractionFreeModeEnabled()
}

I hope so, should be sufficient for applied use in plugins

1 Like