Browse Source

initial version 0.10

pull/3/head 0.10
Rinaldus 7 years ago
commit
0ffa071746
  1. 21
      README.md
  2. BIN
      icons/check_now.png
  3. BIN
      icons/mailbox_empty.png
  4. BIN
      icons/mailbox_full.png
  5. BIN
      icons/menu_quit.png
  6. 115
      mail-notifier.py
  7. 3605
      res.py
  8. 8
      resources.qrc
  9. BIN
      screenshot.jpg

21
README.md

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
## About
This is Light weight mail notifier written in PyQt5. It checks your mailbox periodically and notify you if you have new mail.
## Screenshot
![Screenshot](https://raw.github.com/rinaldus/mail-notify/master/screenshot.jpg)
## Install
You need to install PyQt5 as dependency. Then just clone this git repository or download release and copy all files where you want to store this program. No additional installation is required.
*In version 0.10 you also need to edit mail-notifier.py and fill your mailbox credentials in 70-72 rows*
## Launch
Give execute permission to mail-notifier.py
```sh
$ chmod +x mail-notifier.py
```
## Todo
* Settings window
* "About program" window

BIN
icons/check_now.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
icons/mailbox_empty.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
icons/mailbox_full.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
icons/menu_quit.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

115
mail-notifier.py

@ -0,0 +1,115 @@ @@ -0,0 +1,115 @@
#!/usr/bin/env python3
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import (QAction, QApplication, QCheckBox, QComboBox,
QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
QMessageBox, QMenu, QPushButton, QSpinBox, QStyle, QSystemTrayIcon,
QTextEdit, QVBoxLayout)
from PyQt5.QtCore import (QThread, QTimer)
import imaplib
import subprocess
import res
#variables
timers = []
programTitle = "Mail Notifier"
class Window(QDialog):
def __init__(self):
super(Window, self).__init__()
# UI
self.createActions()
self.setTitle=programTitle
self.createTrayIcon()
self.trayIcon.setIcon(QIcon(":icons/mailbox_empty.png"))
self.trayIcon.setToolTip("You have no unread letters")
self.trayIcon.show()
# Menu actions
def createActions(self):
self.quitAction = QAction(QIcon(':icons/menu_quit.png'),"&Quit", self,
triggered=QApplication.instance().quit)
self.checkNow = QAction(QIcon(':icons/check_now.png'),"&Check now", self,
triggered=self.checkNow)
# self.restoreAction = QAction("&Restore", self,
# triggered=self.showNormal)
# UI functions
def createTrayIcon(self):
self.trayIconMenu = QMenu(self)
self.trayIconMenu.addAction(self.checkNow)
self.trayIconMenu.addAction(self.quitAction)
#self.trayIconMenu.addAction(self.restoreAction)
self.trayIcon = QSystemTrayIcon(self)
self.trayIcon.setContextMenu(self.trayIconMenu)
def mailboxEmpty(self):
self.trayIcon.setToolTip ("You have no unread mail")
self.trayIcon.setIcon(QIcon(":icons/mailbox_empty.png"))
def mailboxFull(self):
self.trayIcon.setToolTip ("You have "+ str(Mail().checkMail())+" unread letters")
self.trayIcon.setIcon(QIcon(":icons/mailbox_full.png"))
notify ("You have "+ str(Mail().checkMail())+" unread letters")
def checkNow (self):
if Mail().checkMail() == 0:
self.mailboxEmpty()
notify("You have no unread mail")
else:
self.mailboxFull()
def closeEvent(self, event):
print ("Closing the app")
# Common functions
class Mail():
def __init__(self):
self.user= 'YOUR_MAILBOX_LOGIN'
self.password= 'YOUR_MAILBOX_PASSWORD'
self.M = imaplib.IMAP4_SSL('MAIL_SERVER', 'PORT(i.e 993)')
self.M.login(self.user, self.password)
def checkMail(self):
self.M.select()
self.unRead = self.M.search(None, 'UnSeen')
return len(self.unRead[1][0].split())
def mail_check():
if Mail().checkMail() == 0:
window.mailboxEmpty()
else:
window.mailboxFull()
def notify(message):
subprocess.Popen(['notify-send', programTitle, message])
return
class Thread(QThread):
def __init__(self):
QThread.__init__(self)
def run(self):
timer = QTimer()
timer.timeout.connect(mail_check)
timer.start(1000*60*5)
timers.append(timer)
self.exec_()
if __name__ == '__main__':
import sys
app = QApplication(sys.argv)
if not QSystemTrayIcon.isSystemTrayAvailable():
QMessageBox.critical(None, "Mail notifier",
"I couldn't detect any system tray on this system.")
sys.exit(1)
QApplication.setQuitOnLastWindowClosed(False)
window = Window()
window.hide()
# UI started. Starting required functions after UI start
mail_check()
thread_instance = Thread()
thread_instance.start()
sys.exit(app.exec_())

3605
res.py

File diff suppressed because it is too large Load Diff

8
resources.qrc

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/">
<file>icons/mailbox_empty.png</file>
<file>icons/mailbox_full.png</file>
<file>icons/menu_quit.png</file>
<file>icons/check_now.png</file>
</qresource>
</RCC>

BIN
screenshot.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Loading…
Cancel
Save