Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turtle.Prelude.proc and Turtle.Prelude.shell don't pass keyboard input to ncurses programs. #275

Open
crocket opened this issue Dec 23, 2017 · 1 comment

Comments

@crocket
Copy link

crocket commented Dec 23, 2017

I needed to press space bar on an ncurses program, but proc and shell couldn't do it.

I had to replace them with import System.Process (spawnProcess, waitForProcess).

Below is how I use spawnProcess and waitForProcess.

{-# LANGUAGE OverloadedStrings #-}
module TermdownAlarm where

import System.Process (spawnProcess, waitForProcess)
import Control.Monad (void)
import Data.Text (Text, unpack)
import Turtle (proc, empty)
import System.Exit (ExitCode(..))

termdownAlarm :: Text -> Text -> Text -> IO ()
termdownAlarm title duration file = do
  exitCode <- spawnProcess "termdown"
    [ "--alt-format", "--no-figlet"
    , "--critical", "10", "--no-window-title", "--title"
    , unpack title, unpack duration ] >>= waitForProcess
  case exitCode of
    ExitFailure _ -> return ()
    ExitSuccess ->
      void $ proc "mpv" ["--really-quiet", "--volume=100", file] empty

I can press space bar to pause and resume timer in termdown which is an ncurses program.

@Gabriella439
Copy link
Owner

Yeah, I don't think you will be able to do this using the existing turtle utilities because they line-buffer input. You would need to use the underlying process library (like you did) for more fine-grained control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants