aboutsummaryrefslogtreecommitdiffstats
path: root/mbsync/usr
diff options
context:
space:
mode:
authorGravatar Tom Willemse2019-08-14 23:45:13 -0700
committerGravatar Tom Willemse2019-08-14 23:45:13 -0700
commit946b7425dec6b3a97abdd631f1c00f7f4ca79a4f (patch)
tree15f73fbda4707f826fee94d87f650f43b48cdf2b /mbsync/usr
parent587bcae5e6bd3a930f08363c0494f618ff4b1d3d (diff)
downloadnew-dotfiles-946b7425dec6b3a97abdd631f1c00f7f4ca79a4f.tar.gz
new-dotfiles-946b7425dec6b3a97abdd631f1c00f7f4ca79a4f.zip
Fix (automatic) syncing of email
- Load the necessary environment variables from ‘gnome-keyring-daemon’ when loading fish. - Don’t sync the Archive directory from ryuslash.org, it’s too big and mbsync seems to get really confused about it. - Disable old email accounts from syncing with mbsync. - Fix the ‘get-mail-password’ and ‘set-mail-password’ scripts. - Use ‘secretstorage’ instead of ‘keyring’, this appears to be newer and easier to use.
Diffstat (limited to 'mbsync/usr')
-rwxr-xr-xmbsync/usr/bin/get-mail-password19
-rwxr-xr-xmbsync/usr/bin/set-mail-password25
2 files changed, 21 insertions, 23 deletions
diff --git a/mbsync/usr/bin/get-mail-password b/mbsync/usr/bin/get-mail-password
index 02f4033..ecfbb09 100755
--- a/mbsync/usr/bin/get-mail-password
+++ b/mbsync/usr/bin/get-mail-password
@@ -1,15 +1,12 @@
#!/usr/bin/python3
-import gi
-
-gi.require_version('GnomeKeyring', '1.0')
-
-import logging
-
-logger = logging.getLogger('keyring')
-logger.addHandler(logging.StreamHandler())
-
-import keyring
import sys
+import secretstorage
+
+connection = secretstorage.dbus_init()
+collection = secretstorage.get_collection_by_alias(connection, "login")
-print(keyring.get_password('offlineimap', sys.argv[1]))
+for foo in collection.search_items(
+ {"application": "mbsync", "account": sys.argv[1]}
+):
+ print(foo.get_secret().decode())
diff --git a/mbsync/usr/bin/set-mail-password b/mbsync/usr/bin/set-mail-password
index 022b5f7..c36e39b 100755
--- a/mbsync/usr/bin/set-mail-password
+++ b/mbsync/usr/bin/set-mail-password
@@ -1,16 +1,17 @@
#!/usr/bin/python3
-import gi
-
-gi.require_version('GnomeKeyring', '1.0')
-
-import logging
-
-logger = logging.getLogger('keyring')
-logger.addHandler(logging.StreamHandler())
-
-import keyring
import sys
-import getpass
+from getpass import getpass
+import secretstorage
+
+connection = secretstorage.dbus_init()
+collection = secretstorage.get_collection_by_alias(connection, "login")
+attributes = {"application": "mbsync", "account": sys.argv[1]}
-keyring.set_password('offlineimap', sys.argv[1], getpass.getpass())
+collection.create_item(
+ "Password for '{}' on '{}'".format(
+ attributes["account"], attributes["application"]
+ ),
+ attributes,
+ getpass().encode(),
+)