Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
fc7c80d6ec | |||
|
fae48b4a8d | ||
|
cf66a347b1 | ||
|
183a5c8076 | ||
|
07756a8b19 | ||
|
290395903e | ||
|
0e27e17597 | ||
|
5c714a69c4 | ||
|
e8918895f4 | ||
|
d16a6f28cf | ||
|
403867b2eb | ||
|
f101f67a30 | ||
|
812c342bcb |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
build
|
||||
dist
|
||||
pygtk-imap-chk-v?.?
|
||||
|
24
README
24
README
@ -1,10 +1,14 @@
|
||||
PyGTK IMAP Checker v1.0
|
||||
PyGTK IMAP Checker v1.3
|
||||
By Josh Holtrop
|
||||
|
||||
This script creates an undecorated window containing a number which tracks
|
||||
the unread message count obtained for a particular mailbox folder via IMAP.
|
||||
Only IMAP SSL is used.
|
||||
|
||||
Window Interaction:
|
||||
Middle Click: Disconnect/Reconnect to IMAP server
|
||||
Right Click: Exit program
|
||||
|
||||
Usage: pygtk-imap-chk.exe <config-file>
|
||||
|
||||
The config-file argument is required and should be the name of a configuration
|
||||
@ -34,6 +38,24 @@ Available configuration parameters:
|
||||
This value will be updated by the program when it closes.
|
||||
'mailbox': String giving the name of the mailbox directory to search for
|
||||
the unread message count (if unspecified, uses "Inbox").
|
||||
You may specify subfolders such as "Inbox/Folder".
|
||||
'mouse': A hash which configures the actions for the program to take
|
||||
in response to a mouse click. The keys of this hash can be
|
||||
'left', 'middle', or 'right'. The values of the hash can take
|
||||
the following forms:
|
||||
'exit' - the program will terminate
|
||||
'reconnect' - the program will reconnect to the IMAP server
|
||||
'cmd:COMMAND' - the command COMMAND will be executed
|
||||
The cmd:COMMAND form can be used to execute arbitrary processes
|
||||
in response to a mouse click. This can be used to raise a mail
|
||||
client window, for example:
|
||||
mouse = {
|
||||
'middle': 'reconnect',
|
||||
'right': 'exit',
|
||||
'left': 'cmd:"C:\\Program Files\\Microsoft Office\\'
|
||||
'Office12\\OUTLOOK.EXE" /recycle '
|
||||
'/select "outlook:Sent Items"'
|
||||
}
|
||||
'password': String containing the password to use to connect to the server
|
||||
'port': String containing the port number of the IMAP SSL port on
|
||||
the mail server.
|
||||
|
40
Window.py
40
Window.py
@ -1,9 +1,11 @@
|
||||
|
||||
import re
|
||||
import gtk
|
||||
import gobject
|
||||
import imaplib
|
||||
import math
|
||||
from datetime import datetime, timedelta
|
||||
from subprocess import *
|
||||
|
||||
class Window(object):
|
||||
def __init__(self, title, conf):
|
||||
@ -29,18 +31,30 @@ class Window(object):
|
||||
self.conf['flash_rate'] = 3000
|
||||
if not 'font_size' in self.conf:
|
||||
self.conf['font_size'] = 18
|
||||
if not 'mouse' in self.conf:
|
||||
self.conf['mouse'] = {}
|
||||
if not 'left' in self.conf['mouse']:
|
||||
self.conf['mouse']['left'] = ''
|
||||
if not 'middle' in self.conf['mouse']:
|
||||
self.conf['mouse']['middle'] = 'reconnect'
|
||||
if not 'right' in self.conf['mouse']:
|
||||
self.conf['mouse']['right'] = 'exit'
|
||||
if not 'always_on_top' in self.conf:
|
||||
self.conf['always_on_top'] = True
|
||||
if not 'sticky' in self.conf:
|
||||
self.conf['sticky'] = True
|
||||
|
||||
self.font_sz = int(1024 * self.conf['font_size'])
|
||||
self.fgcolor = ''.join(map(lambda x: '%02x' % int(0xFF * x),
|
||||
self.conf['fgcolor']))
|
||||
sticky = True
|
||||
if 'sticky' in self.conf:
|
||||
sticky = self.conf['sticky']
|
||||
|
||||
self.window = gtk.Window()
|
||||
self.window.set_title(title)
|
||||
self.window.set_decorated(False)
|
||||
if sticky:
|
||||
if self.conf['sticky']:
|
||||
self.window.stick()
|
||||
if self.conf['always_on_top']:
|
||||
self.window.set_keep_above(True)
|
||||
self.window.connect('destroy', self.destroy_event)
|
||||
|
||||
self.label = gtk.Label('-')
|
||||
@ -120,7 +134,7 @@ class Window(object):
|
||||
delta = datetime.now() - self.flash_start_dt
|
||||
delta_msec = delta.seconds * 1000 + delta.microseconds / 1000
|
||||
period = delta_msec / float(self.conf['flash_rate'])
|
||||
mix = (math.sin(math.pi * 2 * period) + 1.0) / 2.0
|
||||
mix = (1.0 - math.cos(math.pi * 2 * period)) / 2.0
|
||||
else:
|
||||
mix = 0
|
||||
linear_combination = lambda (x, y): x + (y - x) * mix
|
||||
@ -138,6 +152,18 @@ class Window(object):
|
||||
return False
|
||||
|
||||
def button_release(self, widget, event):
|
||||
if event.button == 3:
|
||||
self.destroy_event()
|
||||
try:
|
||||
btn_name = {1: 'left', 2: 'middle', 3: 'right'}[event.button]
|
||||
action = self.conf['mouse'][btn_name]
|
||||
m = re.match(r'\s*cmd:\s*(.*)', action)
|
||||
if m is not None:
|
||||
cmd = m.group(1)
|
||||
Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
|
||||
elif action == 'reconnect':
|
||||
self.disconnect()
|
||||
self.connect()
|
||||
elif action == 'exit':
|
||||
self.destroy_event()
|
||||
except KeyError:
|
||||
return False
|
||||
return True
|
||||
|
Loading…
x
Reference in New Issue
Block a user