commit ba2d3922fa5ef7c88210c2936d8be0c6725c3003
parent 44395654d8691c800abf0421f4b8270ace288529
Author: Ivan Tham <pickfire@riseup.net>
Date: Sat, 29 Oct 2016 12:40:54 +0800
Display time & state for SIGUSR1
Diffstat:
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/spt.1 b/spt.1
@@ -14,9 +14,10 @@ is a simple timer that uses pomodoro technique with desktop notification to
double your efficiency.
.B spt
receives 2 signals:
+.P
.RS
.B SIGUSR1()
-\- show remaining time
+\- show remaining time, state
.br
.B SIGUSR2()
\- play/pause the timer
diff --git a/spt.c b/spt.c
@@ -31,7 +31,7 @@ volatile static sig_atomic_t display, suspend;
static void die(const char *errstr, ...);
static void spawn(char *cmd, char *cmt);
static void notify_send(char *cmt);
-static void display_time(int timecount);
+static void display_state(int remaining, int suspend);
static void toggle_display(int sigint);
static void toggle_suspend(int sigint);
static void usage(void);
@@ -80,13 +80,14 @@ notify_send(char *cmt)
}
void
-display_time(int timecount)
+display_state(int remaining, int suspend)
{
- char buf[17];
+ char buf[22];
- snprintf(buf, 17, "Remaining: %02d:%02d\n",
- timecount / 60,
- timecount % 60);
+ snprintf(buf, 22, "Remaining: %02d:%02d %s\n",
+ remaining / 60,
+ remaining % 60,
+ (suspend) ? "◼" : "▶");
notify_send(buf);
display = 0;
@@ -155,7 +156,7 @@ main(int argc, char *argv[])
remaining.tv_nsec = 0;
while (remaining.tv_sec) {
if (display)
- display_time(remaining.tv_sec);
+ display_state(remaining.tv_sec, suspend);
if (suspend)
sigsuspend(&emptymask);