From 30b0961b2e0b8187289ec7b9b038a344a85b0171 Mon Sep 17 00:00:00 2001 From: Samuel Dudik Date: Thu, 13 Aug 2020 17:37:40 +0200 Subject: [PATCH] Don't unnecessarily call alarm when duration is zero --- .gitignore | 1 + TODO.md | 4 ++++ config.h | 2 +- herbe.c | 6 ++++-- 4 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 TODO.md diff --git a/.gitignore b/.gitignore index 00bb0a0..2e64ea4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ herbe +.ccls-cache diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..dae735f --- /dev/null +++ b/TODO.md @@ -0,0 +1,4 @@ +* Handle multiple notifications at the same time +* Properly handle duration = 0 +* Keyboard shortcut to dismiss and accept notifications (also mouse) +* Properly print new lines diff --git a/config.h b/config.h index 6611bad..e0e8dfd 100644 --- a/config.h +++ b/config.h @@ -13,4 +13,4 @@ static const unsigned int pos_y = 60; enum corners { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT }; enum corners corner = TOP_RIGHT; -static const unsigned int duration = 5; /* in seconds */ \ No newline at end of file +static const unsigned int duration = 5; /* in seconds */ diff --git a/herbe.c b/herbe.c index 503e6f2..93a2b91 100644 --- a/herbe.c +++ b/herbe.c @@ -67,7 +67,9 @@ int main(int argc, char *argv[]) die("Usage: %s body", argv[0]); signal(SIGALRM, expire); - alarm(duration); + + if (duration != 0) + alarm(duration); display = XOpenDisplay(0); @@ -165,4 +167,4 @@ int main(int argc, char *argv[]) XCloseDisplay(display); exit(EXIT_SUCCESS); -} \ No newline at end of file +}