mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-05 06:31:53 -07:00
XMonad.Prompt.Pass: Use searchPredicate from XPConfig
XMonad.Prompt allows the user to specify a search predicate in XPConfig. However, previously XMonad.Prompt.Pass did not apply this predicate. This now applies the predicate in similar manner as XMonad.Prompt.Shell.
This commit is contained in:
@@ -48,7 +48,7 @@ import XMonad.Prompt ( XPrompt
|
|||||||
, getNextCompletion
|
, getNextCompletion
|
||||||
, XPConfig
|
, XPConfig
|
||||||
, mkXPrompt
|
, mkXPrompt
|
||||||
, mkComplFunFromList)
|
, searchPredicate)
|
||||||
import System.Directory (getHomeDirectory)
|
import System.Directory (getHomeDirectory)
|
||||||
import System.FilePath (takeExtension, dropExtension, combine)
|
import System.FilePath (takeExtension, dropExtension, combine)
|
||||||
import System.Posix.Env (getEnv)
|
import System.Posix.Env (getEnv)
|
||||||
@@ -72,6 +72,11 @@ import XMonad.Util.Run (runProcessWithInput)
|
|||||||
-- - how to setup the password storage, see <http://git.zx2c4.com/password-store/about/>
|
-- - how to setup the password storage, see <http://git.zx2c4.com/password-store/about/>
|
||||||
--
|
--
|
||||||
|
|
||||||
|
type Predicate = String -> String -> Bool
|
||||||
|
|
||||||
|
getPassCompl :: [String] -> Predicate -> String -> IO [String]
|
||||||
|
getPassCompl compls p s = do return $ filter (p s) compls
|
||||||
|
|
||||||
type PromptLabel = String
|
type PromptLabel = String
|
||||||
|
|
||||||
data Pass = Pass PromptLabel
|
data Pass = Pass PromptLabel
|
||||||
@@ -101,7 +106,7 @@ passwordStoreFolder =
|
|||||||
mkPassPrompt :: PromptLabel -> (String -> X ()) -> XPConfig -> X ()
|
mkPassPrompt :: PromptLabel -> (String -> X ()) -> XPConfig -> X ()
|
||||||
mkPassPrompt promptLabel passwordFunction xpconfig = do
|
mkPassPrompt promptLabel passwordFunction xpconfig = do
|
||||||
passwords <- io (passwordStoreFolder >>= getPasswords)
|
passwords <- io (passwordStoreFolder >>= getPasswords)
|
||||||
mkXPrompt (Pass promptLabel) xpconfig (mkComplFunFromList passwords) passwordFunction
|
mkXPrompt (Pass promptLabel) xpconfig (getPassCompl passwords $ searchPredicate xpconfig) passwordFunction
|
||||||
|
|
||||||
-- | A prompt to retrieve a password from a given entry.
|
-- | A prompt to retrieve a password from a given entry.
|
||||||
--
|
--
|
||||||
|
Reference in New Issue
Block a user