+ force mode for chore, new pos. arg: poll
This commit is contained in:
parent
b85c9d4df2
commit
c22bf5a0f8
44
reve.sh
44
reve.sh
@ -33,6 +33,7 @@ util_help () {
|
|||||||
echo "reason {reason} run reve with reason, accepts 'network' or 'time'"
|
echo "reason {reason} run reve with reason, accepts 'network' or 'time'"
|
||||||
echo "chore {chore_name} run a single chore, accepts chore name"
|
echo "chore {chore_name} run a single chore, accepts chore name"
|
||||||
echo "where returns where reve's installed"
|
echo "where returns where reve's installed"
|
||||||
|
echo "poll runs reve to update desktop_mode & power_mode, and do chores"
|
||||||
echo "help [subcommand] shows help message"
|
echo "help [subcommand] shows help message"
|
||||||
echo "== Subcommands =="
|
echo "== Subcommands =="
|
||||||
echo "1. config gets/sets configuration values"
|
echo "1. config gets/sets configuration values"
|
||||||
@ -57,16 +58,6 @@ util_mkdirs () {
|
|||||||
mkdir -p "$reve_folder"
|
mkdir -p "$reve_folder"
|
||||||
}
|
}
|
||||||
|
|
||||||
util_run_single_chore () {
|
|
||||||
local chore_fullname="$reve_chores_mode/$1"
|
|
||||||
if [ -x "$chore_fullname.sh" ]; then
|
|
||||||
echo "[reve] [I] Running single chore: $chore_fullname"
|
|
||||||
bash "$chore_fullname.sh"
|
|
||||||
else
|
|
||||||
echo "[reve] [E] util_run_single_chore: $chore_fullname is not executable"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
f_shell_completion () {
|
f_shell_completion () {
|
||||||
if [ "$in_shell_comp" == "fish" ]; then
|
if [ "$in_shell_comp" == "fish" ]; then
|
||||||
cp "$rt_script_dir/completions/reve.fish" "$HOME/.config/fish/completions/reve.fish"
|
cp "$rt_script_dir/completions/reve.fish" "$HOME/.config/fish/completions/reve.fish"
|
||||||
@ -122,6 +113,7 @@ prepare () {
|
|||||||
util_mkdirs
|
util_mkdirs
|
||||||
set_desktop_mode
|
set_desktop_mode
|
||||||
rt_has_mode_changed="$?"
|
rt_has_mode_changed="$?"
|
||||||
|
echo $rt_has_mode_changed
|
||||||
}
|
}
|
||||||
|
|
||||||
# Called when the mode (the default state, is either dark or light) changes
|
# Called when the mode (the default state, is either dark or light) changes
|
||||||
@ -136,6 +128,21 @@ chores_mode () {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
util_handle_pos () {
|
||||||
|
local forced_mode
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [[ "$arg" == "-d" || "$arg" == "--dark" ]]; then
|
||||||
|
forced_mode="dark"
|
||||||
|
elif [[ "$arg" == "-l" || "$arg" == "--light" ]]; then
|
||||||
|
forced_mode="light"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $( util_read_config base.desktop_mode ) != "$forced_mode" ]]; then
|
||||||
|
util_write_config "$forced_mode"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
sub_config () {
|
sub_config () {
|
||||||
local config_key=$2
|
local config_key=$2
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -163,13 +170,13 @@ main () {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$in_chore_name" != "" ]]; then
|
if [[ "$in_chore_name" != "" ]]; then
|
||||||
util_run_single_chore "$in_chore_name"
|
util_run_chore "$in_chore_name"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
config)
|
config)
|
||||||
sub_config $2 $3 $4
|
sub_config "$2" "$3" "$4"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
update)
|
update)
|
||||||
@ -196,7 +203,16 @@ case "$1" in
|
|||||||
in_reason="$2"
|
in_reason="$2"
|
||||||
;;
|
;;
|
||||||
chore)
|
chore)
|
||||||
in_chore_name="$2"
|
util_handle_pos "$@"
|
||||||
|
util_run_chore "$2"
|
||||||
|
util_toggle_dm
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
poll)
|
||||||
|
;;
|
||||||
|
"")
|
||||||
|
util_help "$2"
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid command or subcommand: $1"
|
echo "Invalid command or subcommand: $1"
|
||||||
@ -204,5 +220,5 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
prepare
|
prepare "$@"
|
||||||
main
|
main
|
||||||
|
Loading…
x
Reference in New Issue
Block a user