brightness control, inhibit sleep, install fonts

This commit is contained in:
Rune Juhl (Atea) 2024-09-14 04:16:51 +02:00
parent 1ba93e4cad
commit 547d40ff46
3 changed files with 87 additions and 0 deletions

43
brightness_control Executable file
View file

@ -0,0 +1,43 @@
#!/usr/bin/env bb
(ns brightness-control
"Script to toggle between light and dark themes. Inspired by
https://github.com/pedrocr/dotfiles/blob/master/.config/sway/envsetup."
(:require [clojure.java.shell :refer [sh]]
[clojure.string]
[clojure.math :as math]))
(def devices
(->> (sh "brightnessctl" "--class" "backlight" "--list")
:out
clojure.string/split-lines
(drop 1)
(partition-by #(re-find #"^Device" %))
(partition 2)
(reduce (fn [acc [[sd] [scb smb]]]
(assoc acc
(keyword (last (re-find #"^Device '(.+?)'" sd)))
{:current (Integer. (last (re-find #"Current brightness: (\d+)" scb)))
:max (Integer. (last (re-find #"Max brightness: (\d+)" smb)))}
))
{})
))
(case (some->> *command-line-args*
first)
"get" (println (name (current-theme)))
"switch"
(let [switch-to (next-theme)
gnome-theme ((:gnome themes) switch-to)]
(run!
#(sh "gsettings" "set" "org.gnome.desktop.interface" (str % "-theme") gnome-theme)
theme-preferences)
(sh "emacsclient" "-e" (str "(load-theme '" ((:emacs themes) switch-to) ")"))
nil))
(let [steps 20
tau (/ Math/PI 2)]
(map (fn [n] (* (math/sin n) 100)) (range 0 tau (/ tau steps))))