From d66a19b62e77d7cd447fe5961668644fdee6e261 Mon Sep 17 00:00:00 2001 From: Bruno Carlin Date: Tue, 16 Jun 2020 07:09:08 +0200 Subject: [PATCH] show the number of unread mail in i3bar --- bin/.local/bin/update-mail-count | 3 +++ i3wm/.config/i3status/config | 7 +++++++ .../user/timers.target.wants/update-mail-count.timer | 1 + .../.config/systemd/user/update-mail-count.service | 6 ++++++ systemd/.config/systemd/user/update-mail-count.timer | 11 +++++++++++ 5 files changed, 28 insertions(+) create mode 100755 bin/.local/bin/update-mail-count create mode 120000 systemd/.config/systemd/user/timers.target.wants/update-mail-count.timer create mode 100644 systemd/.config/systemd/user/update-mail-count.service create mode 100644 systemd/.config/systemd/user/update-mail-count.timer diff --git a/bin/.local/bin/update-mail-count b/bin/.local/bin/update-mail-count new file mode 100755 index 0000000..1a28942 --- /dev/null +++ b/bin/.local/bin/update-mail-count @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +fd -t f . "$HOME/.cache/mail/waarp/INBOX/new/" | wc -l > "$HOME/.cache/mail/waarp.unreadcount" diff --git a/i3wm/.config/i3status/config b/i3wm/.config/i3status/config index cc844f0..3e6447c 100644 --- a/i3wm/.config/i3status/config +++ b/i3wm/.config/i3status/config @@ -22,6 +22,7 @@ order += "battery all" order += "volume master" order += "load" order += "cpu_usage" +order += "read_file unreadmail" order += "tztime local" wireless _first_ { @@ -70,3 +71,9 @@ disk "/" { disk "/home" { format = "  %avail (%percentage_avail)" } + +read_file unreadmail { + path = "/home/bca/.cache/mail/waarp.unreadcount" + format = " %content" + Max_characters = 10 +} diff --git a/systemd/.config/systemd/user/timers.target.wants/update-mail-count.timer b/systemd/.config/systemd/user/timers.target.wants/update-mail-count.timer new file mode 120000 index 0000000..8a14d9e --- /dev/null +++ b/systemd/.config/systemd/user/timers.target.wants/update-mail-count.timer @@ -0,0 +1 @@ +/home/bca/.config/systemd/user/update-mail-count.timer \ No newline at end of file diff --git a/systemd/.config/systemd/user/update-mail-count.service b/systemd/.config/systemd/user/update-mail-count.service new file mode 100644 index 0000000..c64c451 --- /dev/null +++ b/systemd/.config/systemd/user/update-mail-count.service @@ -0,0 +1,6 @@ +[Unit] +Description=Update mail count for display in i3status + +[Service] +Type=oneshot +ExecStart=/home/bca/.local/bin/update-mail-count diff --git a/systemd/.config/systemd/user/update-mail-count.timer b/systemd/.config/systemd/user/update-mail-count.timer new file mode 100644 index 0000000..ff02670 --- /dev/null +++ b/systemd/.config/systemd/user/update-mail-count.timer @@ -0,0 +1,11 @@ +[Unit] +Description=mail count timer + +[Timer] +OnBootSec=1m +OnUnitActiveSec=1m +Persistent=true +Unit=update-mail-count.service + +[Install] +WantedBy=timers.target