From 4a80ed2c096c5d91d9e5c628d3a8c7706b9608c7 Mon Sep 17 00:00:00 2001 From: Leon Henrik Plickat Date: Wed, 11 Oct 2023 02:36:51 +0200 Subject: [PATCH] wayneko now sleeps at night --- wayneko.1 | 1 + wayneko.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/wayneko.1 b/wayneko.1 index 167cd9d..2fc4b0f 100644 --- a/wayneko.1 +++ b/wayneko.1 @@ -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. . diff --git a/wayneko.c b/wayneko.c index e15efc0..87ea2a2 100644 --- a/wayneko.c +++ b/wayneko.c @@ -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: