lost real diff because of autoformatter
This commit is contained in:
parent
cb1b26770a
commit
b85c9d4df2
65
_reve.sh
65
_reve.sh
@ -13,25 +13,30 @@ util_readf () {
|
|||||||
if [[ -f "$filename" ]]; then
|
if [[ -f "$filename" ]]; then
|
||||||
cat "$filename"
|
cat "$filename"
|
||||||
else
|
else
|
||||||
echo "[reve] [E] util_readf: File not found: $filename" >&2
|
error E "util_readf" "File not found: $filename"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
util_read_config () {
|
util_where_config() {
|
||||||
local config_key=$1
|
local config_key=$1
|
||||||
pre_removed_key=${config_key/#base./}
|
pre_removed_key=${config_key/#base./}
|
||||||
config_path=$(echo "$pre_removed_key" | sed 's/\./\//g')
|
config_path=$(echo "$pre_removed_key" | sed 's/\./\//g')
|
||||||
util_readf "$reve_config/$config_path"
|
echo "$reve_config/$config_path"
|
||||||
|
}
|
||||||
|
|
||||||
|
util_read_config() {
|
||||||
|
local fp_config
|
||||||
|
fp_config=$(util_where_config "$1")
|
||||||
|
util_readf "$fp_config"
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
util_write_config() {
|
util_write_config() {
|
||||||
local config_key=$1 new_value=$2
|
local fp_config new_value=$2
|
||||||
pre_removed_key=${config_key/#base./}
|
fp_config=$(util_where_config "$1")
|
||||||
config_path=$( echo "$pre_removed_key" | sed 's/\./\//g' )
|
mkdir -p "$(dirname "$fp_config")"
|
||||||
mkdir -p "$( dirname "$reve_config/$config_path" )"
|
echo "$new_value" >"$fp_config"
|
||||||
echo "$new_value" > "$reve_config/$config_path"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
util_delete_config() {
|
util_delete_config() {
|
||||||
@ -42,3 +47,47 @@ util_delete_config () {
|
|||||||
dir=$(dirname "$reve_config/$config_path")
|
dir=$(dirname "$reve_config/$config_path")
|
||||||
[ -z "$(ls -A "$dir")" ] && rm -r "$dir"
|
[ -z "$(ls -A "$dir")" ] && rm -r "$dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
util_run_chore() {
|
||||||
|
local chore_path="$reve_installation/chores/$1"
|
||||||
|
if [ -x "$chore_path.sh" ]; then
|
||||||
|
error I "util_run_chore" "Running single chore: $(basename "$1")"
|
||||||
|
bash "$chore_path.sh"
|
||||||
|
else
|
||||||
|
error E "util_run_chore" "$chore_path is not executable"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
util_run_utility() {
|
||||||
|
local utility_path="$reve_installation/utility/$1"
|
||||||
|
if [ -x "$utility_path.sh" ]; then
|
||||||
|
error I "util_run_utility" "Running utility script: $(basename "$1")"
|
||||||
|
bash "$utility_path.sh"
|
||||||
|
else
|
||||||
|
error E "util_run_utility" "$utility_path is not executable"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
reload() {
|
||||||
|
util_run_chore "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
reload_util() {
|
||||||
|
util_run_utility "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
util_toggle_dm() {
|
||||||
|
if [[ $(util_read_config base.desktop_mode) == "dark" ]]; then
|
||||||
|
util_write_config base.desktop_mode light
|
||||||
|
else
|
||||||
|
util_write_config base.desktop_mode dark
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
error() {
|
||||||
|
local level=$1 location=$2 cause=$3
|
||||||
|
message="[reve] [$level] [$location] $cause"
|
||||||
|
echo "$message"
|
||||||
|
now=$(date -Iminutes)
|
||||||
|
echo "${now::-6} $message" >>"$reve_installation/reve.log"
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user