-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail-counting.html
104 lines (79 loc) · 4.29 KB
/
mail-counting.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html lang="en" xml:lang="en">
<head>
<title>Resolving unread mail count with different mail clients - When software gets in the way - Dimitrios Semitsoglou-Tsiapos</title>
<meta charset="utf-8">
<meta name="description" content="Resolving unread mail count with different mail clients">
<meta name="keywords" content="linux,mail,client,count">
<meta name="author" content="Dimitrios Semitsoglou-Tsiapos">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"/>
<link rel="alternate" type="application/rss+xml" title="When software gets in the way" href="/feed.xml" />
<style>
html {background-color: #fff;}
body {margin: auto; max-width: 6.67in; font-size: 11pt; padding: 0 1em 1em 1em; opacity: .8;}
hr {border: 0; border-top: 1px solid #c6c5c6;}
a {text-decoration: none;}
a:link {color: #3189c5;}
a:visited {color: #a131c5;}
a:hover {text-decoration: underline;}
h1, h2, h3 {opacity: .8;}
h1 {font-size: x-large;}
h2 {font-size: large;}
h3 {font-size: medium;}
.preview {max-height: 20vw; margin-left: 4ch; overflow: hidden;}
pre {font-size: 10pt; background-color: #eee; padding: .5em; overflow: auto;}
nav {display: inline-block; width: 100%;}
#menu {float: right; -webkit-columns: 2; -moz-columns: 2; columns: 2;}
#menu li {text-align: right; display: block; padding-top: 0.4em;}
#menu div {border-bottom: #c6c5c6 1px solid; width: 6em;}
.skip {position: absolute; opacity:0; pointer-events: none;}
.skip:active, .skip:focus {opacity:1;}
</style>
</head>
<body>
<a href="#content" class="skip" tabindex="1">Skip to content</a>
<nav>
<ul id="menu">
<li><div><a href="/">notes</a></div></li>
<li><div><a href="/pages/astro.html">astro</a></div></li>
<li><div><a href="/pages/hacking.html">hacking</a></div></li>
<li><div><a href="/pages/words.html">words</a></div></li>
<li><div><a target="_blank" href="https://github.com/search?o=desc&q=author:dset0x+&s=created&type=Issues&utf8=✓">github</a></div></li>
</ul>
</nav>
<main id="content">
<article>
<h1>Resolving unread mail count with different mail clients</h1>
<p>While looking for a new MUA, I’ve had to come up with different ways for displaying an unread mail count on my desktop.</p>
<h2>notmuch</h2>
<p>Naturally, <code>notmuch</code> is the easiest, as long as you’ve finalized your policy as to <em>what</em> consitutes new mail.</p>
<pre><code>notmuch search tag:inbox and <OTHER CONDITIONS> | wc -l
</code></pre>
<h2>claws</h2>
<p><code>claws</code> has excellent command line switches for just about everything.</p>
<pre><code>claws-mail --status-full | awk '/INBOX$/ { sum+=$2 } END { print sum; }'",
</code></pre>
<h2>evolution</h2>
<p><code>evolution</code> doesn’t have a good command line interface. One has to go through its cache, which seems to be kept up-to-date.</p>
<pre><code>for i in ~/.cache/evolution/mail/*; do
sqlite3 "$i/folders.db" "select count(*) read from INBOX where read == 0";
done | awk '{ sum += $1; } END { print sum; }'")
</code></pre>
<h3>“Work offline” status</h3>
<p>It’s easy to flip the “work offline” switch in evolution without noticing. Luckily you can get its value easily.</p>
<pre><code>gsettings get org.gnome.evolution.shell start-offline
</code></pre>
<h2>thunderbird</h2>
<p><code>thunderbird</code> has no interface either. You should avoid reading <code>global-messages-db.sqlite</code>, because thunderbird doesn’t really update it:</p>
<pre><code>sqlite3 ~/.thunderbird/*/global-messages-db.sqlite 'SELECT count(*) FROM messageAttributes where attributeID=58 and value=1'
</code></pre>
<p>Instead, grab <a href="https://addons.mozilla.org/en-US/thunderbird/addon/unread-count/"><code>Unread Count</code></a> (yes, it works with versions >= 31) and run this instead:</p>
<pre><code>awk -F: '{ sum += $1; } END { print sum; }' ~/.thunderbird/*/unread-counts
</code></pre>
</article>
</main>
<footer>
</footer>
</body>
</html>