rofi-extras/app/pinentry-rofi.hs

61 lines
1.6 KiB
Haskell
Raw Normal View History

2021-06-25 23:42:29 -04:00
--------------------------------------------------------------------------------
-- | rofi-pinentry - a simply pinentry proxy for bitwarden
--
-- Rather than prompt the user like all the other pinentry programs, call the
-- bitwarden deamon and prompt for a password there
module Main where
import System.Exit
main :: IO ()
main = do
putStrLn "Hello loser"
pinentryLoop
pinentryLoop :: IO ()
pinentryLoop = do
c <- getLine
processLine $ words c
pinentryLoop
processLine :: [String] -> IO ()
processLine [] = noop
processLine ["BYE"] = exitSuccess
processLine ["GETPIN"] = getPin
-- TODO this might be important
processLine ["OPTION", o] = processOption o
-- TODO this might be important
processLine ["GETINFO", _] = noop
-- these all take one arg and should do nothing here
processLine ["SETDESC", _] = noop
processLine ["SETOK", _] = noop
processLine ["SETNOTOK", _] = noop
processLine ["SETCANCEL", _] = noop
processLine ["SETPROMPT", _] = noop
processLine ["SETERROR", _] = noop
-- CONFIRM can take a flag
processLine ["CONFIRM"] = noop
processLine ["CONFIRM", "--one-button", _] = noop
processLine ss = unknownCommand $ unwords ss
unknownCommand :: String -> IO ()
unknownCommand c = putStrLn $ "ERR 275 Unknown command " ++ c
getPin :: IO ()
getPin = undefined
processOption :: String -> IO ()
processOption = undefined
noop :: IO ()
noop = ok
ok :: IO ()
ok = putStrLn "OK"