summaryrefslogtreecommitdiff
path: root/home/scripts
diff options
context:
space:
mode:
authorElizabeth <me@liz.coffee>2025-05-19 23:03:02 -0700
committerElizabeth <me@liz.coffee>2025-05-19 23:03:02 -0700
commit15b24ab9d782a8e5683f305ec8b1c31849a64246 (patch)
treebdb7c85f0d1f81e493c43360125ca61d6d26145c /home/scripts
downloaddotfiles-15b24ab9d782a8e5683f305ec8b1c31849a64246.tar.gz
dotfiles-15b24ab9d782a8e5683f305ec8b1c31849a64246.zip
initial commit
Diffstat (limited to 'home/scripts')
-rwxr-xr-xhome/scripts/greet.sh29
-rwxr-xr-xhome/scripts/log.sh32
-rwxr-xr-xhome/scripts/pinentry.sh20
-rwxr-xr-xhome/scripts/platform.sh11
-rwxr-xr-xhome/scripts/system_name.sh14
-rwxr-xr-xhome/scripts/theme.sh22
6 files changed, 128 insertions, 0 deletions
diff --git a/home/scripts/greet.sh b/home/scripts/greet.sh
new file mode 100755
index 0000000..00b6be5
--- /dev/null
+++ b/home/scripts/greet.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+source log.sh "greet.sh"
+
+pick_greeting() {
+ path="$1"
+ greetings=("$1"/*)
+ greeting="${greetings[$RANDOM % ${#greetings[@]}]}"
+ echo "$greeting"
+}
+
+GREETINGS_LIST="$XDG_CONFIG_HOME/zsh/greetings"
+if [ ! -d "$GREETINGS_LIST" ]; then
+ log DEBUG "no such file $GREETINGS_LIST"
+ exit 0
+fi
+
+for greetings in $(ls "$GREETINGS_LIST" | sort); do
+ echo
+ log DEBUG "greeting $greetings"
+
+ path="$GREETINGS_LIST/$greetings"
+ if [ ! -d "$path" ]; then
+ log DEBUG "greetings $path is not a directory"
+ continue
+ fi
+
+ greeting=$(pick_greeting "$path")
+ cat "$greeting"
+done
diff --git a/home/scripts/log.sh b/home/scripts/log.sh
new file mode 100755
index 0000000..8895097
--- /dev/null
+++ b/home/scripts/log.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# usage:
+# > source log.sh <CALLER>
+# > log INFO "hello"
+# > log "this is epic"
+# > log DEBUG "yo"
+
+_LOG_CALLER=$(basename "$1")
+
+log() {
+ LEVEL=$1
+ shift
+
+ case "$LEVEL" in
+ INFO|DEBUG|ERROR)
+ ;;
+ *)
+ set -- "INFO" "$LEVEL" "$@"
+ LEVEL="INFO"
+ ;;
+ esac
+
+ TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
+ MESSAGE="$*"
+
+ if [ "$LEVEL" = "DEBUG" ] && [ -z "$DEBUG" ]; then
+ return
+ fi
+
+ echo "[$TIMESTAMP] [$_LOG_CALLER] [$LEVEL] $MESSAGE"
+}
diff --git a/home/scripts/pinentry.sh b/home/scripts/pinentry.sh
new file mode 100755
index 0000000..f02ee6f
--- /dev/null
+++ b/home/scripts/pinentry.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+source log.sh "pinentry.sh"
+
+#-- <gpg> --
+bin="${HOMEBREW_PREFIX:-"/usr"}/bin"
+case "$PINENTRY_USER_DATA" in
+ *USE_TTY*) pe=$bin/pinentry-tty ;;
+ *USE_CURSES*) pe=$bin/pinentry-curses ;;
+ *USE_QT*) pe=$bin/pinentry-qt ;;
+ *USE_MAC*) pe=$bin/pinentry-mac ;;
+ *USE_GTK2*) pe=$bin/pinentry-gtk-2 ;;
+ *USE_GNOME3*) pe=$bin/pinentry-gnome3 ;;
+ *USE_X11*) pe=$bin/pinentry-x11 ;;
+esac
+
+log DEBUG "$pe"
+
+exec $pe "$@"
+#-- </gpg> --
diff --git a/home/scripts/platform.sh b/home/scripts/platform.sh
new file mode 100755
index 0000000..9449ceb
--- /dev/null
+++ b/home/scripts/platform.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+case "$OSTYPE" in
+ solaris*) echo "solaris" ;;
+ darwin*) echo "osx" ;;
+ linux*) echo "linux" ;;
+ bsd*) echo "bsd" ;;
+ msys*) echo "windows" ;;
+ cygwin*) echo "windows" ;;
+ *) echo "unknown" ;;
+esac
diff --git a/home/scripts/system_name.sh b/home/scripts/system_name.sh
new file mode 100755
index 0000000..92b714a
--- /dev/null
+++ b/home/scripts/system_name.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+platform="$(platform.sh)"
+
+MACHINE="$HOST"
+if [ "$platform" = "osx" ]; then
+ MACHINE="$(scutil --get ComputerName)"
+elif [ "$platform" = "linux" ]; then
+ MACHINE="$(cat /proc/sys/kernel/hostname)"
+fi
+
+echo $MACHINE | awk -F\. '{print $1}' \
+ | tr '[:upper:]' '[:lower:]' \
+ | tr ' ' '-'
diff --git a/home/scripts/theme.sh b/home/scripts/theme.sh
new file mode 100755
index 0000000..3608c14
--- /dev/null
+++ b/home/scripts/theme.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# usage: theme.sh <theme_name>
+
+source log.sh "theme.sh"
+
+THEME="$1"
+log DEBUG "setting theme $THEME"
+
+THEME_SRC="$XDG_CONFIG_HOME/theme"
+THEME_DEST="$HOME/.theme"
+log DEBUG "src $THEME_SRC -> dest $THEME_DEST"
+
+THEME_TEMPL="{{THEME}}"
+
+find "$THEME_SRC/" -type f | while read source_file; do
+ destination_file=`echo "$source_file" | sed "s|^$THEME_SRC|$THEME_DEST|g"`
+ mkdir -p `dirname $destination_file`
+ log DEBUG "src $source_file -> dest $dest_file"
+ cat "$source_file" | sed "s|$THEME_TEMPL|$THEME|g" > $destination_file
+done
+