summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-05-14 15:48:13 +0200
committerSimon Rettberg2019-05-14 15:48:13 +0200
commit85fa353a824363733e949be519000bd505a92cf2 (patch)
treea3e77201b33f97b8ee5311b605203d3623981085
parentFix DPMS timeout calculation (diff)
downloadidle-daemon-85fa353a824363733e949be519000bd505a92cf2.tar.gz
idle-daemon-85fa353a824363733e949be519000bd505a92cf2.tar.xz
idle-daemon-85fa353a824363733e949be519000bd505a92cf2.zip
Better align warning messages with full minute
-rw-r--r--src/main.c26
1 files 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 );
}
}
}