forked from kmonad/kmonad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4af863e
commit f70c5d2
Showing
9 changed files
with
185 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,6 @@ Maintainer : [email protected] | |
Stability : experimental | ||
Portability : non-portable (MPTC with FD, FFI to Linux-only c-code) | ||
The entry-point to KMonad that simply imports the relevant modules and strings | ||
them together. For the actual implementation details see "KMonad.Api.App" | ||
-} | ||
module Main | ||
( -- * The entry-point to KMonad | ||
|
@@ -19,7 +16,8 @@ module Main | |
where | ||
|
||
import KPrelude | ||
import KMonad.Runner (kmonad) | ||
import KMonad.Args.Cmd | ||
import KMonad.App | ||
|
||
main :: IO () | ||
main = kmonad | ||
main = getCmd >>= print |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,3 @@ | ||
module KMonad | ||
( module X | ||
) | ||
() | ||
where | ||
|
||
import KMonad.Action as X | ||
import KMonad.Button as X | ||
import KMonad.Daemon as X | ||
import KMonad.Event as X | ||
import KMonad.Keyboard as X | ||
import KMonad.Runner as X | ||
import KMonad.Util as X |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{-| | ||
Module : KMonad.Args | ||
Description : How to parse arguments and config files into an AppCfg | ||
Copyright : (c) David Janssen, 2019 | ||
License : MIT | ||
Maintainer : [email protected] | ||
Stability : experimental | ||
Portability : non-portable (MPTC with FD, FFI to Linux-only c-code) | ||
-} | ||
module KMonad.Args | ||
(loadConfig) | ||
where | ||
|
||
import KPrelude | ||
import KMonad.App | ||
|
||
|
||
-- | Parse a configuration file into a 'DaemonCfg' record | ||
loadConfig :: HasLogFunc e => FilePath -> RIO e AppCfg | ||
loadConfig pth = do | ||
undefined | ||
-- lf <- view logFuncL | ||
-- tks <- loadTokens pth -- This can throw a parse-error | ||
-- cfg <- joinConfigIO tks -- This can throw a JoinError | ||
|
||
-- -- Try loading the sink and src | ||
-- snk <- liftIO . _snk cfg $ lf | ||
-- src <- liftIO . _src cfg $ lf | ||
|
||
-- -- Assemble the DaemonCfg record | ||
-- pure $ AppCfg | ||
-- { _keySinkDev = snk | ||
-- , _keySourceDev = src | ||
-- , _keymapCfg = _km cfg | ||
-- , _firstLayer = _fstL cfg | ||
-- } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{-| | ||
Module : KMonad.Args.Cmd | ||
Description : Parse command-line options into a 'Cmd' for KMonad to execute | ||
Copyright : (c) David Janssen, 2019 | ||
License : MIT | ||
Maintainer : [email protected] | ||
Stability : experimental | ||
Portability : non-portable (MPTC with FD, FFI to Linux-only c-code) | ||
-} | ||
module KMonad.Args.Cmd | ||
( Cmd(..) | ||
, HasCmd(..) | ||
, getCmd | ||
) | ||
where | ||
|
||
import KPrelude | ||
|
||
import Options.Applicative | ||
|
||
|
||
|
||
-------------------------------------------------------------------------------- | ||
-- $cmd | ||
-- | ||
-- The different things KMonad can be instructed to do. | ||
|
||
-- | Record of the different KMonad settings | ||
data Cmd = Cmd | ||
{ _cfgFile :: FilePath -- ^ Which file to read the config from | ||
, _dryRun :: Bool -- ^ Flag to indicate we are only test-parsing | ||
, _logLvl :: LogLevel -- ^ Level of logging to use | ||
} | ||
deriving Show | ||
makeClassy ''Cmd | ||
|
||
-- | Parse 'RunCfg' from the evocation of this program | ||
getCmd :: IO Cmd | ||
getCmd = customExecParser (prefs showHelpOnEmpty) $ info (cmdP <**> helper) | ||
( fullDesc | ||
<> progDesc "Start KMonad" | ||
<> header "kmonad - an onion of buttons." | ||
) | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
-- $prs | ||
-- | ||
-- The different command-line parsers | ||
|
||
-- | Parse the full command | ||
cmdP :: Parser Cmd | ||
cmdP = Cmd <$> fileP <*> dryrunP <*> levelP | ||
|
||
-- | Parse a filename that points us at the config-file | ||
fileP :: Parser FilePath | ||
fileP = strArgument | ||
( metavar "FILE" | ||
<> help "The configuration file") | ||
|
||
-- | Parse a flag that allows us to switch to parse-only mode | ||
dryrunP :: Parser Bool | ||
dryrunP = switch | ||
( long "dry-run" | ||
<> short 'd' | ||
<> help "If used, do not start KMonad, only try parsing the config file" | ||
) | ||
|
||
-- | Parse the log-level as either a level option or a verbose flag | ||
levelP :: Parser LogLevel | ||
levelP = option f | ||
( long "log-level" | ||
<> short 'l' | ||
<> metavar "Log level" | ||
<> value LevelWarn | ||
<> help "How much info to print out (debug, info, warn, error)" ) | ||
where | ||
f = maybeReader $ flip lookup [ ("debug", LevelDebug), ("warn", LevelWarn) | ||
, ("info", LevelInfo), ("error", LevelError) ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
resolver: lts-14.7 | ||
resolver: lts-15.12 | ||
packages: | ||
- . | ||
extra-deps: | ||
|