Compare commits
No commits in common. "18ff2a0636900c72679d9e68b3c683e4476c967e" and "b0d9b2c7178d1adb0d12ce8ae32fb605b8421a49" have entirely different histories.
18ff2a0636
...
b0d9b2c717
4 changed files with 2 additions and 103 deletions
|
|
@ -1,13 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
case "${1}" in
|
|
||||||
get)
|
|
||||||
head -c1 /sys/firmware/acpi/platform_profile | tr '[:lower:]' '[:upper:]'
|
|
||||||
;;
|
|
||||||
toggle)
|
|
||||||
current="$(cat /sys/firmware/acpi/platform_profile)"
|
|
||||||
choices="$(cat /sys/firmware/acpi/platform_profile_choices)"
|
|
||||||
next="$(echo "${choices} ${choices}" | tr \ \\n | grep -A1 "${current}" | tail -n+2 | head -n1)"
|
|
||||||
echo "${next}" | sudo tee /sys/firmware/acpi/platform_profile
|
|
||||||
esac
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
#!/usr/bin/env -S bb
|
|
||||||
(ns toggle-displays
|
|
||||||
(:require [clojure.edn :as edn]
|
|
||||||
[clojure.java.io :as io]
|
|
||||||
[clojure.java.shell :refer [sh]]
|
|
||||||
[babashka.fs :as fs]))
|
|
||||||
|
|
||||||
(def state-file
|
|
||||||
(fs/path
|
|
||||||
(System/getenv "XDG_RUNTIME_DIR")
|
|
||||||
(str (fs/file-name (or (System/getProperty "babashka.file") *file*)) ".state")))
|
|
||||||
|
|
||||||
(defn get-state!
|
|
||||||
[]
|
|
||||||
(if (fs/exists? state-file)
|
|
||||||
(some->>
|
|
||||||
(->> state-file
|
|
||||||
fs/unixify
|
|
||||||
io/reader
|
|
||||||
java.io.PushbackReader.
|
|
||||||
edn/read))
|
|
||||||
(some->>
|
|
||||||
(sh "journalctl" "--user" "--unit" "kanshi.service" "--reverse" "--lines" "1")
|
|
||||||
;; {:exit 0, :out "Mar 06 07:39:48 aegir kanshi[3318847]: configuration for profile 'kvm-1' applied\n", :err ""}
|
|
||||||
:out
|
|
||||||
(re-find #"configuration for profile '(.+?)' applied")
|
|
||||||
(second)
|
|
||||||
(keyword))))
|
|
||||||
|
|
||||||
(defn save-state!
|
|
||||||
[state]
|
|
||||||
(spit (fs/unixify state-file) state))
|
|
||||||
|
|
||||||
(defn apply-state!
|
|
||||||
[state]
|
|
||||||
(sh "kanshictl" "switch" (name state)))
|
|
||||||
|
|
||||||
(defn next-state
|
|
||||||
[state]
|
|
||||||
(let [modes (apply concat (repeat 2 [:kvm-left
|
|
||||||
:kvm-right
|
|
||||||
:single]))]
|
|
||||||
(nth modes (inc (.indexOf modes state)))))
|
|
||||||
|
|
||||||
(defn -main
|
|
||||||
[& [toggle?]]
|
|
||||||
(when toggle?
|
|
||||||
(let [state (get-state!)
|
|
||||||
state* (next-state state)]
|
|
||||||
(apply-state! state*)
|
|
||||||
(save-state! state*))))
|
|
||||||
|
|
||||||
(when (= *file* (System/getProperty "babashka.file"))
|
|
||||||
(apply -main *command-line-args*))
|
|
||||||
|
|
@ -8,11 +8,11 @@
|
||||||
(def themes
|
(def themes
|
||||||
{:light {:emacs "doom-oksolar-light"
|
{:light {:emacs "doom-oksolar-light"
|
||||||
:gnome "Adwaita"
|
:gnome "Adwaita"
|
||||||
:kitty "Doom OKsolar Light"}
|
:kitty "doom-oksolar-light"}
|
||||||
|
|
||||||
:dark {:emacs "doom-opera"
|
:dark {:emacs "doom-opera"
|
||||||
:gnome "Adwaita-dark"
|
:gnome "Adwaita-dark"
|
||||||
:kitty "Default"}})
|
:kitty "Solarized Darcula"}})
|
||||||
|
|
||||||
(def theme-preferences
|
(def theme-preferences
|
||||||
["gtk"
|
["gtk"
|
||||||
|
|
|
||||||
34
ymmw
34
ymmw
|
|
@ -1,34 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
"""Re-format YAML passed on stdin or read from any arguments."""
|
|
||||||
|
|
||||||
import yaml
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
# https://stackoverflow.com/a/72265455
|
|
||||||
def str_presenter(dumper, data):
|
|
||||||
if len(data.splitlines()) > 1 or "\n" in data:
|
|
||||||
text_list = [line.rstrip() for line in data.splitlines()]
|
|
||||||
fixed_data = "\n".join(text_list)
|
|
||||||
return dumper.represent_scalar("tag:yaml.org,2002:str", fixed_data, style="|")
|
|
||||||
return dumper.represent_scalar("tag:yaml.org,2002:str", data)
|
|
||||||
|
|
||||||
|
|
||||||
yaml.add_representer(str, str_presenter)
|
|
||||||
|
|
||||||
|
|
||||||
def ymmw(files):
|
|
||||||
if not files:
|
|
||||||
files=[sys.stdin]
|
|
||||||
|
|
||||||
for f in files:
|
|
||||||
try:
|
|
||||||
print(f)
|
|
||||||
print(yaml.dump(yaml.load(open(f) if not f == sys.stdin else f, Loader=yaml.FullLoader)), end='')
|
|
||||||
except OSError as ex:
|
|
||||||
sys.exit(f"""ERROR: Couldn't read input from stdin, or couldn't write output to stdout. Exiting.
|
|
||||||
|
|
||||||
{ex}""")
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
ymmw(sys.argv[1:])
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue