diff install.py @ 471:31079b060068

Update mutt config.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 09 Apr 2019 19:09:04 -0700
parents 3b9394a0a58b
children 97412ea9b3fa
line wrap: on
line diff
--- a/install.py	Tue Apr 09 18:58:39 2019 -0700
+++ b/install.py	Tue Apr 09 19:09:04 2019 -0700
@@ -21,6 +21,18 @@
     is_mac = True
 
 
+def _is_executable(fpath):
+    return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
+
+
+def which(exename):
+    for path in os.environ.get("PATH", "").split(os.pathsep):
+        exepath = os.path.join(path, exename)
+        if _is_executable(exepath):
+            return exepath
+    return None
+
+
 def _p(*paths, force_unix=False):
     res = os.path.join(dotfiles_dir, *paths)
     if force_unix:
@@ -242,8 +254,14 @@
 
 @only_on_nix
 def install_mutt():
+    if which('gpg2'):
+        gpgbin = 'gpg2'
+    else:
+        if not which('gpg'):
+            print("WARNING: no GPG tools seem to be installed!")
+        gpgbin = 'gpg'
     writelines('~/.muttrc', [
-        'source "gpg2 -dq %s |"' % _p('mutt/variables.gpg'),
+        'source "%s -dq %s |"' % (gpgbin, _p('mutt/variables.gpg')),
         'source "%s"' % _p('mutt/muttrc'),
         'source "%s"' % _p('lib/mutt/mutt-colors-solarized/'
                            'mutt-colors-solarized-dark-256.muttrc')