diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2017-02-25 16:56:48 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2017-02-25 16:57:30 -0700 |
commit | 46c595fd9a8ace2c5d00facf192e4f64ea3ac3c8 (patch) | |
tree | 640fd184c4bedaa2b2c54ff2b040b8b16e8d3d33 | |
parent | 2e280d3001080cb3fc508485933a0eb798d29148 (diff) | |
download | sscan-46c595fd9a8ace2c5d00facf192e4f64ea3ac3c8.tar.gz |
add OutputFormat and set initial output dir
-rw-r--r-- | Main.hs | 7 | ||||
-rw-r--r-- | Presets.hs | 2 | ||||
-rw-r--r-- | Types/State.hs | 6 | ||||
-rw-r--r-- | sscan.cabal | 2 |
4 files changed, 15 insertions, 2 deletions
@@ -5,6 +5,8 @@ import Data.Monoid import qualified Data.Text as T import qualified Graphics.Vty as V import Lens.Micro ((&), (.~), (^.)) +import System.Directory (getHomeDirectory) +import System.FilePath ((</>)) import Brick.AttrMap import Brick.Main @@ -39,6 +41,7 @@ drawUI st = [ui] , ("colour data", show $ st^.stColour) , ("page size", show $ st^.stPaper) , ("DPI", show $ st^.stDPI) + , ("output dir", st^.stOutdir) ] presetsBox = vBox $ (\(Preset k desc _) -> @@ -76,6 +79,7 @@ theApp = } main = do + home <- getHomeDirectory papersize <- init <$> readFile "/etc/papersize" let paper = if papersize == "letter" then Letter else A4 initialState = St @@ -85,6 +89,7 @@ main = do , _stPaper = paper , _stDefaultPaper = paper , _stDPI = 300 - , _stOutdir = "" + , _stOutFormat = PDF + , _stOutdir = home </> "tmp" } void $ defaultMain theApp initialState @@ -20,7 +20,7 @@ handwrittenNotes = \st -> st { _stOCR = False , _stColour = Greyscale , _stDPI = 75 - , _stPaper = st^.stDefaultPaper + , _stPaper = st^.stDefaultPaper } typewrittenDocs = \st -> st diff --git a/Types/State.hs b/Types/State.hs index c8948a0..f8b8bc5 100644 --- a/Types/State.hs +++ b/Types/State.hs @@ -27,6 +27,9 @@ cyclePaper Auto = A4 -- | DPI to scan type DPI = Int +-- | Output format +data OutputFormat = PDF | PNG + -- | Application state data St = St { _stScanningSession :: Maybe FilePath -- ^ if a session is in @@ -37,7 +40,10 @@ data St = , _stPaper :: Paper -- ^ currently selected paper size , _stDefaultPaper :: Paper -- ^ locale's default paper size , _stDPI :: DPI + , _stOutFormat :: OutputFormat , _stOutdir :: FilePath -- ^ where to save final PDFs } +-- other device-specific scanimage options we could support: --swdespeck; --color-filter; --depth + makeLenses ''St diff --git a/sscan.cabal b/sscan.cabal index 1a29574..ae19a1a 100644 --- a/sscan.cabal +++ b/sscan.cabal @@ -19,6 +19,8 @@ executable sscan -- other-extensions: build-depends: base >=4.9 && <4.10 , brick >=0.17 && <0.18 + , directory >= 1.2.6.2 + , filepath >= 1.4.1.0 , microlens >= 0.4.7.0 , microlens-th >= 0.4.1.1 , text >= 1.2.2.1 |