Initial commit

This commit is contained in:
Andrew S. Rightenburg 2023-04-14 02:59:50 -04:00
commit d32ca5902d
25 changed files with 349 additions and 0 deletions

39
README.md Normal file
View File

@ -0,0 +1,39 @@
# evolution-notify
Provides a system tray icon for the Evolution email client which displays your unread email count
## About
**For the moment, Evolution must be manually configured** to run this script when you receive an email. I plan to write an Evolution plugin which will make this unnecessary.
Here's how you can configure Evolution to do it:
- Open Evolution
- Edit -> Message Filters
- "Add" (for Incoming)
- Click the "Remove" button next to the example "condition" (Sender contains, etc)
- Under "Then", change "Move to Folder" to "Run Program"
- Find **"/usr/bin/evolution-notify-add"**
Clicking on the system tray icon will minimize Evolution to the tray (or bring it up again if you've already minimized it)
## Installation
Releases are provided on GitHub
This can also be easily installed via the **deb.rail5.org** Debian repository:
```
sudo curl -s -o /etc/apt/trusted.gpg.d/rail5.gpg "https://deb.rail5.org/rail5.gpg"
sudo curl -s -o /etc/apt/sources.list.d/rail5.list "https://deb.rail5.org/debian/rail5.list"
sudo apt update
sudo apt install evolution-notify
```
## Requirements
Requires evolution, xdotool, and bash

5
debian/changelog vendored Normal file
View File

@ -0,0 +1,5 @@
evolution-notify (0.1) bullseye; urgency=low
* Initial release
-- rail5 <andrew@rail5.org> Tue, 14 Apr 2023 02:58:08 -0400

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
10

16
debian/control vendored Normal file
View File

@ -0,0 +1,16 @@
Source: evolution-notify
Priority: optional
Maintainer: rail5 <andrew@rail5.org>
Build-Depends: debhelper (>= 8.0.0)
Standards-Version: 3.9.3
Section: utils
Package: evolution-notify
Version: 0.1
License: GPL-3.0
Vendor: rail5 <andrew@rail5.org>
Priority: optional
Architecture: all
Depends: evolution, xdotool, bash
Description: Provides a systray icon displaying unread email count in Evolution
evolution-notify provides a systray icon which displays your unread email count

16
debian/copyright vendored Normal file
View File

@ -0,0 +1,16 @@
Copyright (C) 2022 Andrew S Rightenburg (rail5)
evolution-notify is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
evolution-notify is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with evolution-notify. If not, see <http://www.gnu.org/licenses/>.
On Debian systems, the complete text of the GNU General Public License
can be found in `/usr/share/common-licenses/GPL-3'.

37
debian/evolution-notify.1 vendored Normal file
View File

@ -0,0 +1,37 @@
.\" Automatically generated by Pandoc 2.9.2.1
.\"
.TH "evolution-notify" "1" "" "Version 0.1" "Manual for evolution-notify"
.hy
.SH NAME
.PP
evolution-notify - provides a systray icon for evolution displaying
unread email count
.SH SYNOPSIS
.PP
\f[C]evolution-notify\f[R]
.PP
\f[C]evolution-notify-add\f[R]
.PP
\f[C]evolution-notify-subtract\f[R]
.SH OPTIONS
.SS OVERVIEW
.PP
evolution-notify-add
.IP
.nf
\f[C]
Add 1 to the unread email count
evolution-notify must already be running
\f[R]
.fi
.PP
evolution-notify-subtract
.IP
.nf
\f[C]
Subtract 1 from the unread email count
evolution-notify must already be running
\f[R]
.fi

1
debian/manpages vendored Normal file
View File

@ -0,0 +1 @@
debian/evolution-notify.1

22
debian/rules vendored Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/make -f
%:
dh $@
override_dh_auto_install:
chmod +x evolution-notify
chmod +x evolution-notify-add
chmod +x evolution-notify-subtract
install -D -m 0755 evolution-notify "$$(pwd)/debian/evolution-notify/usr/bin/evolution-notify"
install -D -m 0755 evolution-notify-add "$$(pwd)/debian/evolution-notify/usr/bin/evolution-notify-add"
install -D -m 0755 evolution-notify-subtract "$$(pwd)/debian/evolution-notify/usr/bin/evolution-notify-subtract"
install -D images/0.png "$$(pwd)/debian/evolution-notify/usr/share/evolution-notify/images/0.png"
install -D images/1.png "$$(pwd)/debian/evolution-notify/usr/share/evolution-notify/images/1.png"
install -D images/2.png "$$(pwd)/debian/evolution-notify/usr/share/evolution-notify/images/2.png"
install -D images/3.png "$$(pwd)/debian/evolution-notify/usr/share/evolution-notify/images/3.png"
install -D images/4.png "$$(pwd)/debian/evolution-notify/usr/share/evolution-notify/images/4.png"
install -D images/5.png "$$(pwd)/debian/evolution-notify/usr/share/evolution-notify/images/5.png"
install -D images/6.png "$$(pwd)/debian/evolution-notify/usr/share/evolution-notify/images/6.png"
install -D images/7.png "$$(pwd)/debian/evolution-notify/usr/share/evolution-notify/images/7.png"
install -D images/8.png "$$(pwd)/debian/evolution-notify/usr/share/evolution-notify/images/8.png"
install -D images/9.png "$$(pwd)/debian/evolution-notify/usr/share/evolution-notify/images/9.png"
install -D images/10.png "$$(pwd)/debian/evolution-notify/usr/share/evolution-notify/images/10.png"

123
evolution-notify Executable file
View File

@ -0,0 +1,123 @@
#!/bin/bash
# evolution-notify
## Provides a system tray icon for Evolution
## Which can be clicked to minimize to Evolution to the systray,
## Clicked again to bring it back,
## And which shows an icon with the number of unread emails you have
set -e
tempdirectory=$(dirname $(mktemp -u))
# Establish "quit" filename
## The program will run until it sees this file created
export quitfile="$tempdirectory/evolution-notify.quit"
# Get the process ID of evolution
# If evolution is not already running, start it
export evolutionpid=$(pidof evolution)
if [[ "$evolutionpid" == "" ]]; then
evolution & disown
export evolutionpid=$(pidof evolution)
fi
# Store a flag in a file to tell us whether the Evolution window is currently displayed (1)
# Or minimized to the tray (0)
export evolutiondisplayingfile=$(mktemp --tmpdir ${0##*/}-display.XXXXXXXX)
echo "1" > $evolutiondisplayingfile
# Create a FIFO file, used to manage the I/O redirection from shell
PIPE=$(mktemp -u --tmpdir ${0##*/}.XXXXXXXX)
mkfifo $PIPE
export PIPE
# Attach a file descriptor to the file
exec 3<> $PIPE
# Create a tmp file to store the email count as we go
export countfile="$tempdirectory/evolution-notify.count"
# Set the current count to zero
echo "0" > $countfile
# Add handler to manage process shutdown
function on_exit() {
# Send command to yad through pipe
echo "quit" >&3
rm -f $PIPE
rm -f $countfile
rm -f $evolutiondisplayingfile
}
trap on_exit EXIT
function set_count_to_zero() {
emailcount=0
echo "$emailcount" > $countfile
exec 3<> $PIPE
echo "icon:/usr/share/evolution-notify/images/$emailcount.png" >&3
}
export -f set_count_to_zero
function on_click() {
windowids=$(xdotool search --pid $evolutionpid)
windowcurrentlydisplayed=$(cat $evolutiondisplayingfile)
if [[ $windowcurrentlydisplayed -eq 1 ]]; then
# If the window is up, 'unmap' it
for id in $windowids; do
xdotool windowunmap $id
echo "0" > $evolutiondisplayingfile
done
else
# If the window is unmapped, remap it
for id in $windowids; do
xdotool windowmap $id
echo "1" > $evolutiondisplayingfile
done
fi
}
export -f on_click
# Add handler for right click menu Quit entry function
on_quit() {
echo $quitfile
# Create the quitfile
echo "quit" > $quitfile
exec 3<> $PIPE
echo "quit" >&3
kill $evolutionpid
}
export -f on_quit
function update_icon() {
# Get current email count
emailcount=$(cat $countfile)
exec 3<> $PIPE
echo "icon:/usr/share/evolution-notify/images/$emailcount.png" >&3
}
export -f update_icon
# Create the system tray icon
yad --notification \
--listen \
--image="/usr/share/evolution-notify/images/0.png" \
--text="evolution-notify" \
--menu="Quit!bash -c on_quit|Clear count!bash -c set_count_to_zero" \
--no-middle \
--command="bash -c on_click" <&3 &
while [ ! -f "$quitfile" ]; do
update_icon
sleep 60
done
rm -f $quitfile

19
evolution-notify-add Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
tempdirectory=$(dirname $(mktemp -u))
countfile="$tempdirectory/evolution-notify.count"
# Get current email count
emailcount=$(cat $countfile)
# Add one
emailcount=$(expr $emailcount + 1)
# We can only go up to 10
if [[ $emailcount -gt 10 ]]; then
emailcount=10
fi
# Update the count in the file
echo "$emailcount" > $countfile

19
evolution-notify-subtract Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
tempdirectory=$(dirname $(mktemp -u))
countfile="$tempdirectory/evolution-notify.count"
# Get current email count
emailcount=$(cat $countfile)
# Subtract one
emailcount=$(expr $emailcount - 1)
# We can only go down to 0
if [[ $emailcount -lt 0 ]]; then
emailcount=0
fi
# Update the count in the file
echo "$emailcount" > $countfile

BIN
images/0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
images/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
images/10.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

BIN
images/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

BIN
images/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

BIN
images/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
images/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

BIN
images/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
images/7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
images/8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
images/9.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
images/template.xcf Normal file

Binary file not shown.

26
makefile Normal file
View File

@ -0,0 +1,26 @@
all:
echo "Hello"
install:
chmod +x evolution-notify
chmod +x evolution-notify-add
chmod +x evolution-notify-subtract
install -D -m 0755 evolution-notify /usr/bin/evolution-notify
install -D -m 0755 evolution-notify-add /usr/bin/evolution-notify-add
install -D -m 0755 evolution-notify-subtract /usr/bin/evolution-notify-subtract
install -D images/0.png /usr/share/evolution-notify/images/0.png
install -D images/1.png /usr/share/evolution-notify/images/1.png
install -D images/2.png /usr/share/evolution-notify/images/2.png
install -D images/3.png /usr/share/evolution-notify/images/3.png
install -D images/4.png /usr/share/evolution-notify/images/4.png
install -D images/5.png /usr/share/evolution-notify/images/5.png
install -D images/6.png /usr/share/evolution-notify/images/6.png
install -D images/7.png /usr/share/evolution-notify/images/7.png
install -D images/8.png /usr/share/evolution-notify/images/8.png
install -D images/9.png /usr/share/evolution-notify/images/9.png
install -D images/10.png /usr/share/evolution-notify/images/10.png
manual:
# You must have 'pandoc' installed
rm -f debian/evolution-notify.1
pandoc --standalone --to man ./manpage.md -o debian/evolution-notify.1

25
manpage.md Normal file
View File

@ -0,0 +1,25 @@
% evolution-notify(1) Version 0.1 | Manual for evolution-notify
# NAME
evolution-notify - provides a systray icon for evolution displaying unread email count
# SYNOPSIS
`evolution-notify`
`evolution-notify-add`
`evolution-notify-subtract`
# OPTIONS
## OVERVIEW
evolution-notify-add
Add 1 to the unread email count
evolution-notify must already be running
evolution-notify-subtract
Subtract 1 from the unread email count
evolution-notify must already be running