mirror of
https://github.com/fairyglade/ly.git
synced 2025-12-21 03:34:54 +00:00
Merge branch 'master' of https://github.com/fairyglade/ly
This commit is contained in:
@@ -4,6 +4,11 @@
|
|||||||
# matrix -> CMatrix
|
# matrix -> CMatrix
|
||||||
animation = none
|
animation = none
|
||||||
|
|
||||||
|
# Stop the animation after some time
|
||||||
|
# 0 -> Run forever (default)
|
||||||
|
# 1..2e12 -> Stop the animation after this many seconds
|
||||||
|
animation_timeout_sec = 0
|
||||||
|
|
||||||
# Format string for clock in top right corner (see strftime specification). Example: %c
|
# Format string for clock in top right corner (see strftime specification). Example: %c
|
||||||
# If null, the clock won't be shown
|
# If null, the clock won't be shown
|
||||||
clock = null
|
clock = null
|
||||||
|
|||||||
@@ -57,3 +57,4 @@ brightness_down_key: []const u8 = "F5",
|
|||||||
brightness_up_key: []const u8 = "F6",
|
brightness_up_key: []const u8 = "F6",
|
||||||
brightnessctl: []const u8 = "/usr/bin/brightnessctl",
|
brightnessctl: []const u8 = "/usr/bin/brightnessctl",
|
||||||
brightness_change: []const u8 = "10",
|
brightness_change: []const u8 = "10",
|
||||||
|
animation_timeout_sec: u12 = 0,
|
||||||
|
|||||||
31
src/main.zig
31
src/main.zig
@@ -65,6 +65,12 @@ pub fn main() !void {
|
|||||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||||
defer _ = gpa.deinit();
|
defer _ = gpa.deinit();
|
||||||
|
|
||||||
|
// to be able to stop the animation after some time
|
||||||
|
|
||||||
|
var tv_zero: std.c.timeval = undefined;
|
||||||
|
_ = std.c.gettimeofday(&tv_zero, null);
|
||||||
|
var animation_timed_out: bool = false;
|
||||||
|
|
||||||
const allocator = gpa.allocator();
|
const allocator = gpa.allocator();
|
||||||
|
|
||||||
// Load arguments
|
// Load arguments
|
||||||
@@ -384,10 +390,12 @@ pub fn main() !void {
|
|||||||
if (auth_fails < 10) {
|
if (auth_fails < 10) {
|
||||||
_ = termbox.tb_clear();
|
_ = termbox.tb_clear();
|
||||||
|
|
||||||
switch (config.animation) {
|
if (!animation_timed_out) {
|
||||||
.none => {},
|
switch (config.animation) {
|
||||||
.doom => doom.draw(),
|
.none => {},
|
||||||
.matrix => matrix.draw(),
|
.doom => doom.draw(),
|
||||||
|
.matrix => matrix.draw(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.bigclock and buffer.box_height + (bigclock.HEIGHT + 2) * 2 < buffer.height) draw_big_clock: {
|
if (config.bigclock and buffer.box_height + (bigclock.HEIGHT + 2) * 2 < buffer.height) draw_big_clock: {
|
||||||
@@ -533,8 +541,21 @@ pub fn main() !void {
|
|||||||
var timeout: i32 = -1;
|
var timeout: i32 = -1;
|
||||||
|
|
||||||
// Calculate the maximum timeout based on current animations, or the (big) clock. If there's none, we wait for the event indefinitely instead
|
// Calculate the maximum timeout based on current animations, or the (big) clock. If there's none, we wait for the event indefinitely instead
|
||||||
if (animate) {
|
if (animate and !animation_timed_out) {
|
||||||
timeout = config.min_refresh_delta;
|
timeout = config.min_refresh_delta;
|
||||||
|
|
||||||
|
// check how long we have been running so we can turn off the animation
|
||||||
|
var tv: std.c.timeval = undefined;
|
||||||
|
_ = std.c.gettimeofday(&tv, null);
|
||||||
|
|
||||||
|
if (config.animation_timeout_sec > 0 and tv.tv_sec - tv_zero.tv_sec > config.animation_timeout_sec) {
|
||||||
|
animation_timed_out = true;
|
||||||
|
switch (config.animation) {
|
||||||
|
.none => {},
|
||||||
|
.doom => doom.deinit(),
|
||||||
|
.matrix => matrix.deinit(),
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (config.bigclock and config.clock == null) {
|
} else if (config.bigclock and config.clock == null) {
|
||||||
var tv: std.c.timeval = undefined;
|
var tv: std.c.timeval = undefined;
|
||||||
_ = std.c.gettimeofday(&tv, null);
|
_ = std.c.gettimeofday(&tv, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user