From 6a0dc1685c47f1caecce26a9c3fabdc230ec0d13 Mon Sep 17 00:00:00 2001 From: Ryan Trinkle Date: Sat, 10 Aug 2019 10:25:34 -0400 Subject: [PATCH] Add XMonad.Prompt.Pass.passGenerateAndCopy --- CHANGES.md | 4 ++++ XMonad/Prompt/Pass.hs | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 23a7f772..6af9f79d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -56,6 +56,10 @@ pass-otp (https://github.com/tadfisher/pass-otp) has been setup in the running machine. + Added 'passGenerateAndCopyPrompt', which both generates a new password and + copies it to the clipboard. These two actions are commonly desirable to + take together, e.g. when establishing a new account. + Made password prompts traverse symlinks when gathering password names for autocomplete. diff --git a/XMonad/Prompt/Pass.hs b/XMonad/Prompt/Pass.hs index a1b42ad5..fa349d38 100644 --- a/XMonad/Prompt/Pass.hs +++ b/XMonad/Prompt/Pass.hs @@ -46,6 +46,7 @@ module XMonad.Prompt.Pass ( passPrompt , passOTPPrompt , passGeneratePrompt + , passGenerateAndCopyPrompt , passRemovePrompt , passEditPrompt , passTypePrompt @@ -138,6 +139,13 @@ passOTPPrompt = mkPassPrompt "Select OTP" selectOTP passGeneratePrompt :: XPConfig -> X () passGeneratePrompt = mkPassPrompt "Generate password" generatePassword +-- | A prompt to generate a password for a given entry and immediately copy it +-- to the clipboard. This can be used to override an already stored entry. +-- (Beware that no confirmation is asked) +-- +passGenerateAndCopyPrompt :: XPConfig -> X () +passGenerateAndCopyPrompt = mkPassPrompt "Generate and copy password" generateAndCopyPassword + -- | A prompt to remove a password for a given entry. -- (Beware that no confirmation is asked) -- @@ -172,6 +180,13 @@ selectOTP passLabel = spawn $ "pass otp --clip \"" ++ escapeQuote passLabel ++ " generatePassword :: String -> X () generatePassword passLabel = spawn $ "pass generate --force \"" ++ escapeQuote passLabel ++ "\" 30" +-- | Generate a 30 characters password for a given entry. +-- If the entry already exists, it is updated with a new password. +-- After generating the password, it is copied to the clipboard. +-- +generateAndCopyPassword :: String -> X () +generateAndCopyPassword passLabel = spawn $ "pass generate --force -c \"" ++ escapeQuote passLabel ++ "\" 30" + -- | Remove a password stored for a given entry. -- removePassword :: String -> X ()