brightness control, inhibit sleep, install fonts
This commit is contained in:
parent
1ba93e4cad
commit
547d40ff46
3 changed files with 87 additions and 0 deletions
43
brightness_control
Executable file
43
brightness_control
Executable 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))))
|
||||||
26
inhibit_sleep
Executable file
26
inhibit_sleep
Executable file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env bb
|
||||||
|
(ns inhibit-sleep
|
||||||
|
(:require [clojure.java.shell :refer [sh]]))
|
||||||
|
|
||||||
|
|
||||||
|
(defn has-lock? []
|
||||||
|
(->> (sh "systemd-inhibit")
|
||||||
|
:out
|
||||||
|
(clojure.string/split-lines)
|
||||||
|
(filter #(re-find #"inhibit-sleep" %))
|
||||||
|
seq))
|
||||||
|
|
||||||
|
(case (some->> *command-line-args*
|
||||||
|
first)
|
||||||
|
"get" (if (boolean (has-lock?))
|
||||||
|
"inhibited"
|
||||||
|
"normal")
|
||||||
|
|
||||||
|
"toggle"
|
||||||
|
(if (has-lock?)
|
||||||
|
nil
|
||||||
|
(apply sh (clojure.string/split
|
||||||
|
"systemd-inhibit \
|
||||||
|
--what=handle-lid-switch:sleep \
|
||||||
|
--why=':inhibit-sleep' \
|
||||||
|
--mode=block cat" #"\s+"))))
|
||||||
18
install-atea-fonts.sh
Executable file
18
install-atea-fonts.sh
Executable file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
command -v woff2_decompress
|
||||||
|
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
pushd "${tmp}"
|
||||||
|
for style in Light Regular Medium Bold; do
|
||||||
|
f="Inter-${style}.woff2"
|
||||||
|
wget "https://www.atea.dk/fonts/${f}"
|
||||||
|
woff2_decompress "${f}"
|
||||||
|
done
|
||||||
|
|
||||||
|
mv ./*.ttf ~/.local/share/fonts
|
||||||
|
fc-cache -f -v
|
||||||
|
popd
|
||||||
|
rm "${tmp}"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue