From d66f9ffaa8cdffe308379a45d52cad64ec82a1b4 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Fri, 25 Jun 2021 23:42:29 -0400 Subject: [PATCH] ADD pinentry-rofi skeleton --- app/pinentry-rofi.hs | 60 ++++++++++++++++++++++++++++++++++++++++++++ package.yaml | 9 +++++++ 2 files changed, 69 insertions(+) create mode 100644 app/pinentry-rofi.hs diff --git a/app/pinentry-rofi.hs b/app/pinentry-rofi.hs new file mode 100644 index 0000000..466ce01 --- /dev/null +++ b/app/pinentry-rofi.hs @@ -0,0 +1,60 @@ +-------------------------------------------------------------------------------- +-- | 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" diff --git a/package.yaml b/package.yaml index 11af86c..e555167 100644 --- a/package.yaml +++ b/package.yaml @@ -51,6 +51,15 @@ library: - Rofi.Command executables: + pinentry-rofi: + main: pinentry-rofi.hs + source-dirs: app + ghc-options: + - -Wall + - -Werror + - -threaded + dependencies: + - rofi-extras rofi-autorandr: main: rofi-autorandr.hs source-dirs: app