diff options
Diffstat (limited to '.local/share/mode/plug.d/10_lib')
| -rw-r--r-- | .local/share/mode/plug.d/10_lib | 41 | 
1 files changed, 41 insertions, 0 deletions
| diff --git a/.local/share/mode/plug.d/10_lib b/.local/share/mode/plug.d/10_lib index 61817bc..b3a0276 100644 --- a/.local/share/mode/plug.d/10_lib +++ b/.local/share/mode/plug.d/10_lib @@ -1,5 +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 +} + |