wayneko now sleeps at night

This commit is contained in:
Leon Henrik Plickat 2023-10-11 02:36:51 +02:00
commit 4a80ed2c09
2 changed files with 11 additions and 0 deletions

View file

@ -22,6 +22,7 @@ wayneko \- Neko on Wayland
.P
Display an animated neko cat on the bottom of an output.
Responds to the pointer being near the bottom edge of that output.
While most cats are usually active at night, wayneko likes to sleep when it's late.
.P
Requires the Wayland server to implement \fBzwlr-layer-shell-unstable-v1\fR.
.

View file

@ -793,6 +793,16 @@ static bool animation_next_state_with_hotspot (uint32_t x)
/** Returns true if new frame is needed. */
static bool animation_next_state_normal (void)
{
/* Neko likes to sleep at night. */
const long now = time(NULL);
struct tm tm = *localtime(&now);
if ( tm.tm_hour >= 23 || tm.tm_hour <= 6 )
{
const bool need_frame = current_neko != NEKO_SLEEP_1 && current_neko != NEKO_SLEEP_2;
animation_neko_do_sleep();
return need_frame;
}
switch (current_neko)
{
case NEKO_STARE: