Last active
August 12, 2024 17:17
-
-
Save rept0id/7703dde2300b6c211da0418d24148fbf to your computer and use it in GitHub Desktop.
RootedMailNotifier2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os, sys, getpass, imaplib | |
from gi.repository import Gtk as gtk | |
from gi.repository import AppIndicator3 as appindicator | |
USER_MAIL = '[email protected]' | |
USER_PASS = 'password-example' | |
os.system('export DISPLAY=:0') | |
if ('USER_MAIL' in locals()) and ('USER_PASS' in locals()): | |
global PROV_LINK | |
global PROV_IMAP | |
global MAILS_UNREAD | |
if 'gmail' in USER_MAIL: | |
PROV_LINK = 'http://www.gmail.com' | |
PROV_IMAP = 'imap.gmail.com' | |
elif 'yahoo' in USER_MAIL: | |
PROV_LINK = 'https://mail.yahoo.com' | |
PROV_IMAP = 'imap.mail.yahoo.com' | |
elif ('outlook' in USER_MAIL) or ('hotmail' in USER_MAIL): | |
PROV_LINK = 'https://www.outlook.com' | |
PROV_IMAP = 'imap-mail.outlook.com' | |
else: | |
os.system('notify-send "RootedMailNotifier" "Mail provider not supported yet"') | |
try: | |
x = imaplib.IMAP4_SSL(PROV_IMAP, 993) | |
x.login(USER_MAIL, USER_PASS) | |
x.select('INBOX') | |
status, response = x.status('INBOX', "(UNSEEN)") | |
MAILS_UNREAD = int(response[0].split()[2].strip(').,]')) | |
except : | |
os.system('notify-send "RootedMailNotifier" "The username/password specified is not valid"') | |
if 'gmail' in USER_MAIL: | |
ER_MSG1 = "zenity --error --no-wrap --height=40 --title=\'RML Rooted Mail Notifier\' " | |
ER_MSG2 = "--text=\'ER: ER200 GMAIL ACCESS DENIED\n\nRML access to Gmail denied.\nPlease go to the links below and check your " | |
ER_MSG3 = "settings.\n\n<a href=\"https://www.google.com/settings/security/lesssecureapps\">https://www.google.com/settings/security/lesssecure" | |
ER_MSG4 = "apps➚</a>\n<a href=\"https://accounts.google.com/DisplayUnlockCaptcha\">https://accounts.google.com/DisplayUnlockCaptcha➚</a>\'" | |
os.system((ER_MSG1 + ER_MSG2 + ER_MSG3 + ER_MSG4)) | |
if MAILS_UNREAD > 0 : | |
# | |
global APPINDICATOR_ID | |
global APPINDICATOR_IMG | |
global APPINDICATOR_NUM | |
APPINDICATOR_NUM = MAILS_UNREAD | |
APPINDICATOR_ID = 'RootedMailNotifier' | |
APPINDICATOR_IMG = '/usr/share/icons/ubuntu-mono-dark/status/24/indicator-messages.svg' | |
#APPINDICATOR_IMG = '/usr/share/icons/hicolor/scalable/status/indicator-messages.svg' | |
#APPINDICATOR_IMG = '/usr/share/icons/hicolor/16x16/status/indicator-messages-new.png' | |
#APPINDICATOR_IMG = '/usr/share/icons/oxygen/16x16/places/mail-message.png' | |
# | |
def indicator_main(): | |
indicator = appindicator.Indicator.new(APPINDICATOR_ID, os.path.abspath(APPINDICATOR_IMG), appindicator.IndicatorCategory.SYSTEM_SERVICES) | |
indicator.set_status(appindicator.IndicatorStatus.ACTIVE) | |
indicator.set_menu(indicator_build_menu()) | |
gtk.main() | |
# | |
def indicator_build_menu(): | |
menu = gtk.Menu() | |
item_name = 'Open' + '(' + str(MAILS_UNREAD) + ')' | |
item_open = gtk.MenuItem(item_name) | |
item_open.connect('activate', indicator_open) | |
item_quit = gtk.MenuItem('Quit') | |
item_quit.connect('activate', indicator_quit) | |
menu.append(item_open) | |
menu.append(item_quit) | |
menu.show_all() | |
return menu | |
# | |
def indicator_open(source): | |
x = 'xdg-open ' + PROV_LINK | |
os.system(x) | |
# | |
def indicator_quit(source): | |
gtk.main_quit() | |
# | |
indicator_main() | |
# | |
else: | |
os.system('notify-send "RootedMailNotifier" "The username/password specified is not valid"') | |
exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment