aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoachim Breitner <mail@joachim-breitner.de>2015-02-18 10:18:16 +0100
committerJoachim Breitner <mail@joachim-breitner.de>2015-02-18 10:18:16 +0100
commitc994eb6e375d47c6ad065ded4ec66936a3047043 (patch)
treec0137faa7dc090971fe8c24aa2b8a6352ae968e4
parentdf6884bfa4b39f41dc2165bd380e32a18eaad34a (diff)
downloadXMonadContrib-c994eb6e375d47c6ad065ded4ec66936a3047043.tar.gz
XMonadContrib-c994eb6e375d47c6ad065ded4ec66936a3047043.tar.xz
XMonadContrib-c994eb6e375d47c6ad065ded4ec66936a3047043.zip
XMonad.Prompt.Pass: Handle hierachical password stores
Ignore-this: 2f0a02613780067d324b04a8cdb9c0ed pass stores its passwords in directories, so the contents of the directory store needs to be enumerated recursively. Alexander Sulfrian provided this patch on the mailinglist, which I tested (it works) and cleaned up slightly. darcs-hash:20150218091816-23c07-6951b0fd1dea96873ec7f7968e5775db8f4520be.gz
-rw-r--r--XMonad/Prompt/Pass.hs17
1 files changed, 13 insertions, 4 deletions
diff --git a/XMonad/Prompt/Pass.hs b/XMonad/Prompt/Pass.hs
index db4ce2d..099a1a6 100644
--- a/XMonad/Prompt/Pass.hs
+++ b/XMonad/Prompt/Pass.hs
@@ -50,8 +50,9 @@ import XMonad.Prompt ( XPrompt
, mkXPrompt
, mkComplFunFromList)
import System.Directory (getDirectoryContents, getHomeDirectory)
-import System.FilePath (takeBaseName, combine)
+import System.FilePath (takeBaseName, takeExtension, dropExtension, combine)
import System.Posix.Env (getEnv)
+import XMonad.Util.Run (runProcessWithInput)
-- $usages
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
@@ -137,6 +138,14 @@ removePassword :: String -> X ()
removePassword passLabel = spawn $ "pass rm --force " ++ passLabel
-- | Retrieve the list of passwords from the password storage 'passwordStoreDir
---
-getPasswords :: String -> IO [String]
-getPasswords passwordStoreDir = liftM (map takeBaseName) $ getDirectoryContents passwordStoreDir
+getPasswords passwordStoreDir = do
+ files <- runProcessWithInput "find" [
+ passwordStoreDir,
+ "-type", "f",
+ "-name", "*.gpg",
+ "-printf", "%P\n"] []
+ return $ map removeGpgExtension $ lines files
+
+removeGpgExtension :: String -> String
+removeGpgExtension file | takeExtension file == ".gpg" = dropExtension file
+ | otherwise = file