aboutsummaryrefslogtreecommitdiff
path: root/home/dot_local/share/mode/plug.d/10_lib
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2026-08-02 14:48:29 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2026-08-02 14:48:29 +0200
commite43eb1177872f52e949fb5f0f93396ed94b0d093 (patch)
tree78b73af6a989fa2996d71b112e161b70d35081ef /home/dot_local/share/mode/plug.d/10_lib
parent2f14a896e4b897bd747c24d7ad8e9e7bb3237d03 (diff)
move to chezmoi
Diffstat (limited to 'home/dot_local/share/mode/plug.d/10_lib')
-rw-r--r--home/dot_local/share/mode/plug.d/10_lib46
1 files changed, 46 insertions, 0 deletions
diff --git a/home/dot_local/share/mode/plug.d/10_lib b/home/dot_local/share/mode/plug.d/10_lib
new file mode 100644
index 0000000..b3a0276
--- /dev/null
+++ b/home/dot_local/share/mode/plug.d/10_lib
@@ -0,0 +1,46 @@
+#!/bin/sh
+# utility library functions
+hex_to_rgb_array() { pastel format rgb "$1" | cut -c4- | tr '()' '[]' ; }
+
+mix_rgb() { pastel mix --colorspace=RGB --fraction="$3" "$1" "$2" | pastel format hex ; }
+
+getvar() {
+ key="$1"
+ eval "printf '%s' \"\$$key\""
+}
+
+setvar() {
+ key="$1"
+ value="$2"
+ eval "$key='$(printf '%s' "$value")'"
+}
+
+themevar() {
+ key="$1"
+ if [ $# -eq 1 ] ; then
+ value="$(getvar "$key")"
+ else
+ value="$2"
+ setvar "$key" "$value"
+ fi
+
+ vars="$vars
+$(printf "export %s='%s'" "$key" "$value")"
+ eval "export $key"
+}
+
+mkcd() {
+ mkdir -p "$1"
+ cd "$1"
+}
+
+respawn_daemon() {
+ killall -q "$1" && fork "$@"
+}
+
+silent_fail_if_no_commmand() {
+ for name in "$@" ; do
+ [ -z "$(command -v "$name")" ] && exit
+ done
+}
+