From 6f99c255ba641d2941a4a6b25db7c5a0495ab565 Mon Sep 17 00:00:00 2001 From: velvettear Date: Tue, 6 Apr 2021 17:07:06 +0200 Subject: [PATCH] check root permissions only where needed --- scripts/blinky-feed.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/blinky-feed.sh b/scripts/blinky-feed.sh index df50c1e..46d2207 100755 --- a/scripts/blinky-feed.sh +++ b/scripts/blinky-feed.sh @@ -9,22 +9,23 @@ blinky_mode="morph" blinky_duration="2500" # temperature -max_temp="85000" -crit_temp="90000" +max_temp="65000" +crit_temp="70000" threshold_upper="66" threshold_lower="33" thermal_zones=( - "*" + "3" ) -# check for root permissions -[[ "$EUID" != 0 ]] && printf "error: permission denied!\n" && exit 1 - # argument to lowercase arg="${1,,}" # functions +function checkRoot() { + [[ "$EUID" != 0 ]] && printf "error: permission denied!\n" && exit 1 +} + # convert a temperature value to a rgb color value function temperatureToRGB() { [[ ! "$1" ]] && printf "error: did not receive a temperature value to convert to a rgb value\n" && exit 1 @@ -76,6 +77,7 @@ function getTemperature() { # main part case "$arg" in -t|--temp|--temperature) + checkRoot getTemperature temperatureToRGB "$result" sendPOST "color=$result" "mode=$blinky_mode" "duration=$blinky_duration"