diff options
author | Simon Rettberg | 2019-05-14 15:48:13 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-05-14 15:48:13 +0200 |
commit | 85fa353a824363733e949be519000bd505a92cf2 (patch) | |
tree | a3e77201b33f97b8ee5311b605203d3623981085 /src | |
parent | Fix DPMS timeout calculation (diff) | |
download | idle-daemon-85fa353a824363733e949be519000bd505a92cf2.tar.gz idle-daemon-85fa353a824363733e949be519000bd505a92cf2.tar.xz idle-daemon-85fa353a824363733e949be519000bd505a92cf2.zip |
Better align warning messages with full minute
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -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 ); } } } |