Automatically inhibit screensaver activation in EXWM.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Ian Eure b11d3df7a5
Placate package lint; add missing requires.
7 months ago
README.org Initial commit. 8 months ago
exwm-ss.el Placate package lint; add missing requires. 7 months ago

README.org

EXWM-SS

EXWM-SS is a global minor mode which inhibits the screensaver automatically when watching videos. This fills a gap in EXWM, compared to other Linux DEs.

The default behavior is to inhibit the screensaver if:

  • Any X client is fullscreen and visible (that is: not in a workspace which isnt being displayed by some monitor).
  • A special X client is visible (even if its not fullscreen).

    • Special clients are MPV, VLC, and Jellyfin Media Player, but this can be extended.

Installation

Use straight.el. You can install straight-weirdware to add the recipe, or install manually with:

  (use-package exwm-ss
    :defer t
    :after exwm
    :straight (exwm-ss :repo "https://codeberg.org/emacs-weirdware/exwm-ss.git")
    :init
    (exwm-ss-mode 1))

Use

Enable the mode:

  (exwm-ss-mode 1)

Design

For maximum flexibility, EXWM-SS is factored out into several pieces:

  • Class EXWM-SS determines how the screensaver is inhibited.

    • Class EXWM-SS--DPMS-COMMAND is an EXWM-SS implementation which uses xset(1) to control DPMS screen blanking.
    • Class EXWM-SS--XSCREENSAVER is an EXWM-SS implementation which calls xscreensaver-command -deactivate every 60 seconds, to prevent it from activating.
  • Class EXWM-SS-CONTROL determines when the screensaver should (or should not) be activated.

    • It handles hooking into EXWM to pick up state change events.
    • Generic function EXWM-SS-INHIBITED? determines whether the current WM state should cause the screensaver to be inhibited.
    • Class EXWM-SS-BASE is an EXWM-SS-CONTROL implementation which contains the default logic for when the screensaver should be inhibited — visible fullscreen or visible special client.
  • Class EXWM-SS-CONTROL-DEFAULT is the composite default EXWM-SS-CONTROL implementation. It contains no logic of its own, and inherits from EXWM-SS-CONTROL-BASE, EXWM-SS--DPMS-COMMAND, and EXWM-SS--XSCREENSAVER.
  • Alternate controller classes may be specified by customizing EXWM-SS-CONTROLLER-CLASS. Your controller must inherit from EXWM-SS-CONTROL and mix in one or more EXWM-SS classes.

Example of Extending EXWM-SS

Say that youd like the screensaver to be inhibited when a hypothetical new video player, Coolplayer, is visible.

First, create a new implementation of EXWM-SS-CONTROL:

  (defclass my-exwm-ss-control (exwm-ss-control-default)
    ()
    :documentation "My personal `EXWM-SS-CONTROL' implementation.")

  (cl-defmethod exwm-ss-special? ((ssc my-exwm-ss-control) buf)
    (or (cl-call-next-method ssc buf)
        (string= exwm-class-name "coolplayer")))

Then, customize EXWM-SS-CONTROLLER-CLASS:

  (use-package exwm-ss
    :defer t
    :after exwm
    :straight (exwm-ss :repo "http://codeberg.org/ieure/exwm-ss.git")
    :custom (exwm-ss-controller-class 'my-exwm-ss-control)
    :init
    (exwm-ss-mode 1))

If you need a new mechanism for disabling screensavers, that can be done by creating an EXWM-SS implementation, and declaring a new class which mixes it in:

  (defclass my-exwm-ss-control (exwm-ss-control-base my-exwm-ss-screensaver-method)
    ())

Then set the controller class the same way.