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
89d5a5b
commit 0f97edd
Showing
12 changed files
with
390 additions
and
190 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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{-| | ||
Module : KLisp | ||
Description : The module responsible for parsing the configuration file | ||
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 KLisp | ||
( loadConfig ) | ||
where | ||
|
||
import KPrelude | ||
|
||
import KMonad.Daemon | ||
|
||
import KLisp.Parser | ||
import KLisp.Joiner | ||
import KLisp.Types | ||
|
||
-- | Parse a configuration file into a 'DaemonCfg' record | ||
loadConfig :: HasLogFunc e => FilePath -> RIO e DaemonCfg | ||
loadConfig pth = do | ||
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 $ DaemonCfg | ||
{ _keySinkDev = snk | ||
, _keySourceDev = src | ||
, _keymapCfg = _km cfg | ||
, _firstLayer = _fstL cfg | ||
, _port = _prt 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
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,3 +1,14 @@ | ||
{-| | ||
Module : KLisp.Types | ||
Description : The basic types of configuration parsing. | ||
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 KLisp.Types | ||
( -- * $bsc | ||
Parser | ||
|
@@ -39,8 +50,6 @@ import KMonad.Daemon.KeyHandler (Keymap) | |
import Text.Megaparsec | ||
import Text.Megaparsec.Char | ||
|
||
import qualified RIO.HashMap as M | ||
|
||
-------------------------------------------------------------------------------- | ||
-- $bsc | ||
-- | ||
|
@@ -85,7 +94,7 @@ data DefCfg = DefCfg | |
, _snk :: LogFunc -> IO (Acquire KeySink) | ||
, _km :: Keymap Button | ||
, _fstL :: Text | ||
, _port :: () | ||
, _prt :: () | ||
} | ||
|
||
|
||
|
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
Oops, something went wrong.