inbox-imap-pythongpg: add pgp feature (close #119)

master
x70b1 2019-02-22 22:31:59 +01:00
parent d51114aee9
commit 414e8d1640
6 changed files with 44 additions and 30 deletions

View File

@ -41,7 +41,7 @@ Is this your first time here? You should definitely take a look at these scripts
[![notification-chess](polybar-scripts/notification-chess/screenshots/1.png)](polybar-scripts/notification-chess/)
[![notification-reddit](polybar-scripts/notification-reddit/screenshots/1.png)](polybar-scripts/notification-reddit/)
[![vpn-openvpn-isrunning](polybar-scripts/vpn-openvpn-isrunning/screenshots/1.png)](polybar-scripts/vpn-openvpn-isrunning/)
[![inbox-imap-python](polybar-scripts/inbox-imap-python/screenshots/1.png)](polybar-scripts/inbox-imap-python/)
[![inbox-imap-pythongpg](polybar-scripts/inbox-imap-pythongpg/screenshots/1.png)](polybar-scripts/inbox-imap-pythongpg/)
[![openweathermap-fullfeatured](polybar-scripts/openweathermap-fullfeatured/screenshots/1.png)](polybar-scripts/openweathermap-fullfeatured/)
[![ticker-btceur](polybar-scripts/ticker-btceur/screenshots/1.png)](polybar-scripts/ticker-btceur/)
[![info-airqualityindex](polybar-scripts/info-airqualityindex/screenshots/1.png)](polybar-scripts/info-airqualityindex/)

View File

@ -1,20 +0,0 @@
# Script: inbox-imap-python
A script that shows if there are unread mails in your IMAPs inbox.
![inbox-imap-python](screenshots/1.png)
## Configuration
For Gmail, you must allow [less secure apps](https://myaccount.google.com/security#connectedapps).
## Module
```ini
[module/inbox-imap-python]
type = custom/script
exec = ~/polybar-scripts/inbox-imap-python.py
interval = 60
```

View File

@ -1,9 +0,0 @@
#!/usr/bin/python
import imaplib
obj = imaplib.IMAP4_SSL('imap.mail.net', 993)
obj.login('userlogin', 'pass123')
obj.select()
print(len(obj.search(None, 'unseen')[1][0].split()))

View File

@ -0,0 +1,29 @@
# Script: inbox-imap-pythongpg
A script that shows if there are unread mails in your IMAPs inbox. Passwords are encrypted with gpg.
![inbox-imap-pythongpg](screenshots/1.png)
## Configuration
You must have a gpg key to secure your password in configuration files. Encrypt your password using your gpg key like this.
```ini
echo 'your password' > /tmp/imappass
gpg -er 'your gpg keyid' /tmp/imappass
mv /tmp/imappass.gpg ~/.imappass.gpg
shred /tmp/imappass && rm /tmp/imappass
```
For Gmail, you must allow [less secure apps](https://myaccount.google.com/security#connectedapps).
## Module
```ini
[module/inbox-imap-pythongpg]
type = custom/script
exec = ~/polybar-scripts/inbox-imap-pythongpg.py
interval = 60
```

View File

@ -0,0 +1,14 @@
#!/usr/bin/python
import imaplib
import os
import subprocess
completed_process = subprocess.run(['gpg', '-dq', os.path.join(os.getenv('HOME'), '.imappass.gpg')], check=True, stdout=subprocess.PIPE, encoding="utf-8");
password = completed_process.stdout[:-1]
obj = imaplib.IMAP4_SSL('imap.mail.net', 993)
# Only put your email address below.
obj.login('your email address', password)
obj.select()
print(len(obj.search(None, 'unseen')[1][0].split()))

View File

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 542 B