Compare commits

..

4 Commits

4 changed files with 39 additions and 31 deletions

View File

@ -17,4 +17,4 @@ if ! command -v kitty &>/dev/null; then
exit 1 exit 1
fi fi
kitten themes --reload-in=all "$(util_read_config chore.kitty."$RV_CURRENT_THEME")" kitten themes --reload-in=all "$(util_read_config chore.kitty."$RV_CURRENT_MODE")"

13
chores/mode/nvim_theme.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
# reve desktop environment framework
# Yigid BALABAN <fyb@fybx.dev> 2024
# chore script
# type mode
# name nvim_theme.sh
# desc sends a signal to nvim to fetch desktop_mode
# vars none
# reload none
kill -USR1 $(pgrep -f 'nvim')

View File

@ -1,18 +1,18 @@
#!/usr/bin/env bash #!/bin/bash
# reve desktop environment framework # reve desktop environment framework
# Yigid BALABAN <fyb@fybx.dev> 2024 # Yigid BALABAN <fyb@fybx.dev> 2024
# chore script # chore script
# type mode # type mode
# name chore_script.sh # name chore_script.sh
# desc ... # desc ...
# vars ... # vars ...
# reload ...
reve_folder="$HOME/.config/reve" # shellcheck source=../_reve.sh
reve_desktop_mode="$reve_folder/desktop_mode" source "$(reve where)/_reve"
source "$( reve -w )/_reve" echo "Hello, world! Current mode is $RV_CURRENT_MODE."
current_mode=$( util_readf "$reve_desktop_mode" ) reload mode/gtk_theme
echo "Hello, world! Current mode is $current_mode."

35
reve.sh
View File

@ -36,7 +36,7 @@ util_help() {
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 "poll runs reve to update desktop_mode & power_mode, and do chores"
echo "help [subcomma{nd] 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"
echo "2. update updates chores" echo "2. update updates chores"
@ -85,26 +85,26 @@ f_shell_completion() {
} }
set_desktop_mode() { set_desktop_mode() {
if [[ -n "$in_desktop_mode" ]]; then
echo "$in_desktop_mode" >"$reve_desktop_mode"
return 1 # since mode has changed
fi
local previous_mode num_day num_night current_time local previous_mode num_day num_night current_time
previous_mode=$(util_read_config base.desktop_mode) previous_mode=$(util_read_config base.desktop_mode)
num_day=$(awk -F: '{print $1 * 60 + $2}' <<<"$(util_read_config base.time_day)")
num_night=$(awk -F: '{print $1 * 60 + $2}' <<<"$(util_read_config base.time_night)")
current_time=$(awk -F: '{print $1 * 60 + $2}' <<<"$(date +%H:%M)")
if ((num_night > current_time && current_time >= num_day)); then if [[ -n "$in_desktop_mode" ]]; then
rt_current_mode="light" rt_current_mode="$in_desktop_mode"
echo "$in_desktop_mode" >"$reve_desktop_mode"
else else
rt_current_mode="dark" num_day=$(awk -F: '{print $1 * 60 + $2}' <<<"$(util_read_config base.time_day)")
num_night=$(awk -F: '{print $1 * 60 + $2}' <<<"$(util_read_config base.time_night)")
current_time=$(awk -F: '{print $1 * 60 + $2}' <<<"$(date +%H:%M)")
if ((num_night > current_time && current_time >= num_day)); then
rt_current_mode="light"
else
rt_current_mode="dark"
fi
echo "$rt_current_mode" >"$reve_desktop_mode"
fi fi
echo "[reve] [I] Setting the mode: $rt_current_mode" echo "[reve] [I] Setting the mode: $rt_current_mode"
echo "$rt_current_mode" >"$reve_desktop_mode"
if [ "$rt_current_mode" == "$previous_mode" ]; then if [ "$rt_current_mode" == "$previous_mode" ]; then
return 0 # since mode did not change return 0 # since mode did not change
else else
@ -115,12 +115,7 @@ set_desktop_mode() {
# 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
chores_mode() { chores_mode() {
for file in "$reve_chores_mode"/*; do for file in "$reve_chores_mode"/*; do
if [ -x "$file" ]; then util_run_chore "mode/$(basename "${file%.sh}")" $rt_current_mode
echo "[reve] [I] Running chore: $(basename "$file")"
util_run_chore "$file" $rt_current_mode
else
echo "[reve] [E] chores_mode: $file is not executable"
fi
done done
} }