[xmonad] [xmonad-contrib] XMonad.Prompt.Pass patch
Alexander Sulfrian
alexander at sulfrian.net
Mon Jan 5 14:22:30 UTC 2015
On Thu, 2014-12-18 at 23:25 +0100, Joachim Breitner wrote:
> Dear ardumont,
Hi,
> I started using pass and was about to implement a prompt on my own when
> I noticed that you already did something in that direction. But from
> reading the code, I have a some worries:
>
> I’d expect the
> getPasswords :: String -> IO [String]
> getPasswords passwordStoreDir = liftM (map takeBaseName) $ getDirectoryContents passwordStoreDir
> to break if the passwords are stored in subdirectories. I believe you
> need to recursively traverse the directory.
>
> It would be cleaner if you could simply ask pass for the list of
> passwords, but that does not seem to be possible. Maybe you should
> contact the author and suggest a new parameter to "pass list" that would
> change the output to be a simple list, instead of the tree output.
I use something like this to get a list of all passwords:
getPasswords :: String -> IO [String]
getPasswords passwordStoreDir = do
files <- runProcessWithInput "find" [
passwordStoreDir,
"-type", "f",
"-name", "*.gpg",
"-printf", "%P\n"] []
return $ map removeGpgExtension $ lines files
removeGpgExtension :: String -> String
removeGpgExtension file =
if isSuffixOf ".gpg" file then
reverse $ drop 4 $ reverse file
else
file
It is not relay nice, but it works.
> Also, code like
> selectPassword passLabel = spawn $ "pass --clip " ++ passLabel
> could be a problem if the password label contains shell characters.
> You probably want to use safeSpawn from XMonad.Util.Run.
>
> Greetings,
> Joachim
Alex
More information about the xmonad
mailing list