bin/heat: 24h wrapping
[nethome.git] / bin / heat
index 2320115..bab4730 100755 (executable)
--- a/bin/heat
+++ b/bin/heat
@@ -145,6 +145,10 @@ sub setstate() {
   info "->$newstate";
   writefile $statefile,"$newstate\n" if $state ne $newstate;
   logmsg "$state->$newstate" if $state ne $newstate;
+  if ($newstate ne "s") {
+    my $pid=readfile "pidof -x dnf;true|";
+    die "\nchange refused: dnf running: $pid" if $pid;
+  }
   my $both={"s"=>[0,0],"0"=>[1,0],"1"=>[1,1]}->{$newstate};
   spawn "$usbrelay 1 ".$both->[0];
   spawn "$usbrelay 2 ".$both->[1];
@@ -162,7 +166,7 @@ if (!defined $newreset) {
 }
 $reset=$newreset;
 if ($reset=~/^\d+$/) {
-  $resetminutes=$reset+$minutes;
+  $resetminutes=($reset+$minutes)%(24*60);
   $reset=printminutes($resetminutes)." reset\n";
   setstate;
 } else {