aboutsummaryrefslogtreecommitdiff
path: root/terminal.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-30 20:06:02 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-30 20:06:02 +0000
commite3dc184882e6512453929a6a8932785a6658aaab (patch)
tree0e4271c2d84100bb75e03ea3c1da4f2ec130b414 /terminal.c
parentfootrc: add 'workers' (diff)
term: break out 'flash' to a separate 'term' function
Diffstat (limited to 'terminal.c')
-rw-r--r--terminal.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/terminal.c b/terminal.c
index d6742259..2bc68746 100644
--- a/terminal.c
+++ b/terminal.c
@@ -4,6 +4,7 @@
#include <unistd.h>
#include <assert.h>
+#include <sys/timerfd.h>
#include <linux/input-event-codes.h>
#define LOG_MODULE "terminal"
@@ -485,3 +486,19 @@ term_set_window_title(struct terminal *term, const char *title)
term->window_title = strdup(title);
render_set_title(term, term->window_title);
}
+
+void
+term_flash(struct terminal *term, unsigned duration_ms)
+{
+ LOG_DBG("FLASH for %ums", duration_ms);
+
+ struct itimerspec alarm = {
+ .it_value = {.tv_sec = 0, .tv_nsec = duration_ms * 1000000},
+ };
+
+ if (timerfd_settime(term->flash.fd, 0, &alarm, NULL) < 0)
+ LOG_ERRNO("failed to arm flash timer");
+ else {
+ term->flash.active = true;
+ }
+}