Reduce latency of screen-brightness/{increase,decrease}

As promised in the previous commit, I'm refactoring usages of `shell-command` to
prefer the faster alternative `start-process`. So far, I'm pleased with the
results.
This commit is contained in:
William Carroll 2019-12-23 11:43:27 +00:00
parent 5fbe860b95
commit 7ec4dca723

View file

@ -8,13 +8,6 @@
;; TODO: Define some isomorphisms. E.g. int->string, string->int.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'string)
(require 'dash)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -32,19 +25,23 @@
(defun screen-brightness/increase ()
"Increase the screen brightness."
(interactive)
(->> screen-brightness/step-size
int-to-string
(string/concat "xbacklight -inc ")
shell-command)
(start-process
"*xbacklight<screen-brightness/increase>*"
nil
"xbacklight"
"-inc"
(int-to-string screen-brightness/step-size))
(message "[screen-brightness.el] Increased screen brightness."))
(defun screen-brightness/decrease ()
"Decrease the screen brightness."
(interactive)
(->> screen-brightness/step-size
int-to-string
(string/concat "xbacklight -dec ")
shell-command)
(start-process
"*xbacklight<screen-brightness/decrease>*"
nil
"xbacklight"
"-dec"
(int-to-string screen-brightness/step-size))
(message "[screen-brightness.el] Decreased screen brightness."))
(when screen-brightness/install-kbds?