Skip to content

Instantly share code, notes, and snippets.

@the-kenny
Last active April 17, 2018 22:06
Embed
What would you like to do?
XMonad pass Completion
import System.Environment
import System.FilePath.Posix
import System.FilePath.Find
import XMonad.Prompt
import System.Directory
data Pass = Pass
instance XPrompt Pass where
showXPrompt Pass = "Pass: "
commandToComplete _ c = c
nextCompletion _ = getNextCompletion
passPrompt :: XPConfig -> X ()
passPrompt c = do
li <- io getPasswords
mkXPrompt Pass c (mkComplFunFromList li) selectPassword
selectPassword :: String -> X ()
selectPassword s = spawn $ "pass -c " ++ s
getPasswords :: IO [String]
getPasswords = do
home <- getEnv "HOME"
let passwordStore = home </> ".password-store"
entries <- find System.FilePath.Find.always (fileName ~~? "*.gpg") $
passwordStore
return $ map ((makeRelative passwordStore) . dropExtension) entries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment