From 85fa353a824363733e949be519000bd505a92cf2 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 14 May 2019 15:48:13 +0200 Subject: Better align warning messages with full minute --- src/main.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index 312c16d..502865b 100644 --- a/src/main.c +++ b/src/main.c @@ -191,10 +191,12 @@ int main( int argc, char **argv ) warnUser( usr, WARN_LOGOUT, remaining ); CAP_SLEEP( remaining ); } else if ( remaining < 310 ) { - warnUser( usr, WARN_LOGOUT_LOW, remaining ); - CAP_SLEEP( remaining - ( ( remaining - 30 ) / 60 * 60 ) ); + if ( remaining % 30 < 10 ) { + warnUser( usr, WARN_LOGOUT_LOW, remaining ); + } + CAP_SLEEP( remaining - ( ( remaining - 30 ) / 60 * 60 + 2 ) ); } else { - CAP_SLEEP( remaining - 300 ); + CAP_SLEEP( remaining - 299 ); } usr->logoutTime = NOW + remaining; } @@ -264,16 +266,18 @@ int main( int argc, char **argv ) nextAction.disarmed = true; nextAction.force = false; } else if ( remaining < 310 ) { - enum Warning w = WARN_REBOOT; - if ( nextAction.action == POWEROFF ) { - w = WARN_POWEROFF; - } - for ( idx = 0; idx < count; ++idx ) { - warnUser( &users[idx], w, remaining ); + if ( remaining % 30 < 10 ) { + enum Warning w = WARN_REBOOT; + if ( nextAction.action == POWEROFF ) { + w = WARN_POWEROFF; + } + for ( idx = 0; idx < count; ++idx ) { + warnUser( &users[idx], w, remaining ); + } } - CAP_SLEEP( remaining - ( ( remaining - 30 ) / 60 * 60 ) ); + CAP_SLEEP( remaining - ( ( remaining - 30 ) / 60 * 60 + 2 ) ); } else { - CAP_SLEEP( remaining ); + CAP_SLEEP( remaining - 299 ); } } } -- cgit v1.2.3-55-g7522