From c22bf5a0f8bdc6c262ec7cc06e867b7d54624514 Mon Sep 17 00:00:00 2001 From: Yigid BALABAN Date: Mon, 23 Sep 2024 17:12:43 +0300 Subject: [PATCH] + force mode for chore, new pos. arg: poll --- reve.sh | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/reve.sh b/reve.sh index 9637a74..b5bf4f4 100755 --- a/reve.sh +++ b/reve.sh @@ -33,6 +33,7 @@ util_help () { echo "reason {reason} run reve with reason, accepts 'network' or 'time'" echo "chore {chore_name} run a single chore, accepts chore name" 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 "== Subcommands ==" echo "1. config gets/sets configuration values" @@ -57,16 +58,6 @@ util_mkdirs () { 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 () { if [ "$in_shell_comp" == "fish" ]; then cp "$rt_script_dir/completions/reve.fish" "$HOME/.config/fish/completions/reve.fish" @@ -122,6 +113,7 @@ prepare () { util_mkdirs set_desktop_mode rt_has_mode_changed="$?" + echo $rt_has_mode_changed } # Called when the mode (the default state, is either dark or light) changes @@ -136,6 +128,21 @@ chores_mode () { 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 () { local config_key=$2 case "$1" in @@ -163,13 +170,13 @@ main () { fi if [[ "$in_chore_name" != "" ]]; then - util_run_single_chore "$in_chore_name" + util_run_chore "$in_chore_name" fi } case "$1" in config) - sub_config $2 $3 $4 + sub_config "$2" "$3" "$4" exit 0 ;; update) @@ -196,7 +203,16 @@ case "$1" in in_reason="$2" ;; 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" @@ -204,5 +220,5 @@ case "$1" in ;; esac -prepare +prepare "$@" main