check root permissions only where needed
This commit is contained in:
parent
6014d630ed
commit
6f99c255ba
1 changed files with 8 additions and 6 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue