config subcommand impl.
+ _reve/util_read_config {config_key}
+ _reve/util_write_config {config_key} {value}
+ _reve/util_delete_config {config_key}
+ let shellcheck know what we're sourcing
This commit is contained in:
29
_reve.sh
29
_reve.sh
@@ -3,6 +3,10 @@
|
||||
# reve desktop environment framework
|
||||
# Yigid BALABAN <fyb@fybx.dev> 2024
|
||||
|
||||
# VERY CRITICAL: change this if install.sh is updated
|
||||
reve_installation="$HOME/.local/bin/reve"
|
||||
reve_config="$HOME/.config/reve"
|
||||
|
||||
util_readf () {
|
||||
local filename=$1
|
||||
|
||||
@@ -13,3 +17,28 @@ util_readf () {
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
util_read_config () {
|
||||
local config_key=$1
|
||||
pre_removed_key=${config_key/#base./}
|
||||
config_path=$( echo "$pre_removed_key" | sed 's/\./\//g' )
|
||||
util_readf "$reve_config/$config_path"
|
||||
return $?
|
||||
}
|
||||
|
||||
util_write_config () {
|
||||
local config_key=$1 new_value=$2
|
||||
pre_removed_key=${config_key/#base./}
|
||||
config_path=$( echo "$pre_removed_key" | sed 's/\./\//g' )
|
||||
mkdir -p "$( dirname "$reve_config/$config_path" )"
|
||||
echo "$new_value" > "$reve_config/$config_path"
|
||||
}
|
||||
|
||||
util_delete_config () {
|
||||
local config_key=$1
|
||||
pre_removed_key=${config_key/#base./}
|
||||
config_path=$( echo "$pre_removed_key" | sed 's/\./\//g' )
|
||||
rm "$reve_config/$config_path"
|
||||
dir=$( dirname "$reve_config/$config_path")
|
||||
[ -z "$( ls -A "$dir")" ] && rm -r "$dir"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user