When I watch a full-screen Video in Firefox
while using XMonad, it doesn't
properly disable DPMS so my screen blanks every five minutes in to the
video. Rather than try to figure out why that was, I would invoke systemd-inhibit
to inhibit screen blanking. This
was fine, but I'd run it in a terminal emulator which I would promptly
forget about. Cue my laptop having a dead battery or my monitor burning
in the lock-screen text overnight when I would manually lock the desktop
and head to bed.
I whipped this Emacs global minor mode up
so that I would have a modeline
entry and
a simple toggle. Enabling systemd-inhibit-mode
will, by default prevent
any of the "idle" actions from happening. No screen blanking, no lock
screen, no sleep, just video. If you want to use it like Caffeine
to prevent sleep while your code
compiles or something you can customize systemd-inhibit-what
.
list "idle")
(defcustom systemd-inhibit-what ("Type of operation to inhibit with systemd-inhibit"
:type '(repeat string)
"shutdown" "sleep" "idle"
:options '("handle-power-key" "handle-suspend-key"
"handle-hibernate-key" "handle-lid-switch"))
defvar systemd-inhibit-mode-process nil)
(
(define-minor-mode systemd-inhibit-mode"When active, SystemD will not lock or blank the screen depending on configuration."
t
:global nil
:init-value "[INHIBIT]"
:lighter if systemd-inhibit-mode
(setq systemd-inhibit-mode-process
("systemd-inhibit" " *systemd-inhibit*"
(start-process "systemd-inhibit"
"--mode=block"
"--why=emacs-systemd-inhibit-mode"
"--what=" (s-join ":" systemd-inhibit-what))
(concat "watch" "-n" "45" "date"))
progn
(
(kill-process systemd-inhibit-mode-process)setq systemd-inhibit-mode-process nil))))
(
provide 'cce/systemd-inhibit) (