main :: IO ()
main = runSys' <| do

   term <- defaultTerminal
   args <- liftIO getArgs
   
   case args of
      (devpath:_) -> do
         let flgs = BitSet.fromList [HandleReadWrite,HandleNonBlocking]
         hdl <- open Nothing devpath flgs BitSet.empty
                  |> evalCatchFlowT (\err -> error ( "Unable to open device: " ++ show err))

         eventChannel  <- newEventReader hdl

         onEvent eventChannel <| \ev -> do
            let ev' = makeInputEvent ev
            case inputEventType ev' of
               InputKeyEvent action key
                  | action /= KeyRepeat -> writeStrLn term (show key ++ ": " ++ show action)
               _                        -> return ()


         threadDelaySec 20

      _ -> writeStrLn term ("Usage: sudo haskus-keys /dev/input/event0")
main :: IO ()
main = runSys' <| do

   term <- defaultTerminal
   args <- liftIO getArgs
   
   case args of
      (devpath:_) -> do
         let flgs = BitSet.fromList [HandleReadWrite,HandleNonBlocking]
         hdl <- open Nothing devpath flgs BitSet.empty
                  |> evalCatchFlowT (\err -> error ( "Unable to open device: " ++ show err))

         eventChannel  <- newEventReader hdl

         onEvent eventChannel <| \ev -> do
            let ev' = makeInputEvent ev
            case inputEventType ev' of
               InputKeyEvent action key
                  | action /= KeyRepeat -> writeStrLn term (show key ++ ": " ++ show action)
               _                        -> return ()


         threadDelaySec 20

      _ -> writeStrLn term ("Usage: sudo haskus-keys /dev/input/event0")
main = runSys' <| do

   term <- defaultTerminal
   args <- liftIO getArgs
   
   case args of
      (devpath:_) -> do
         let flgs = BitSet.fromList [HandleReadWrite,HandleNonBlocking]
         hdl <- open Nothing devpath flgs BitSet.empty
                  |> evalCatchFlowT (\err -> error ( "Unable to open device: " ++ show err))

         eventChannel  <- newEventReader hdl

         onEvent eventChannel <| \ev -> do
            let ev' = makeInputEvent ev
            case inputEventType ev' of
               InputKeyEvent action key
                  | action /= KeyRepeat -> writeStrLn term (show key ++ ": " ++ show action)
               _                        -> return ()


         threadDelaySec 20

      _ -> writeStrLn term ("Usage: sudo haskus-keys /dev/input/event0")