diff options
Diffstat (limited to 'tv')
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/Build.hs | 24 | ||||
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs | 18 | ||||
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/main.hs | 47 | ||||
-rw-r--r-- | tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal | 3 |
4 files changed, 29 insertions, 63 deletions
diff --git a/tv/5pkgs/haskell/xmonad-tv/src/Build.hs b/tv/5pkgs/haskell/xmonad-tv/src/Build.hs deleted file mode 100644 index 553a129b1..000000000 --- a/tv/5pkgs/haskell/xmonad-tv/src/Build.hs +++ /dev/null @@ -1,24 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TypeApplications #-} - -module Build where - -import XMonad (Dimension) -import THEnv.JSON (getCompileEnvJSONExp) - - -myFont :: String -myFont = - "-schumacher-*-*-*-*-*-*-*-*-*-*-*-iso10646-*" - -myScreenWidth :: Dimension -myScreenWidth = - $(getCompileEnvJSONExp (id @Dimension) "XMONAD_BUILD_SCREEN_WIDTH") - -myTermFontWidth :: Dimension -myTermFontWidth = - $(getCompileEnvJSONExp (id @Dimension) "XMONAD_BUILD_TERM_FONT_WIDTH") - -myTermPadding :: Dimension -myTermPadding = - 2 diff --git a/tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs b/tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs deleted file mode 100644 index 2a3a0e523..000000000 --- a/tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs +++ /dev/null @@ -1,18 +0,0 @@ -{-# LANGUAGE ScopedTypeVariables #-} - -module THEnv.JSON where - -import Data.Aeson (eitherDecode,FromJSON) -import Data.ByteString.Lazy.Char8 (pack) -import Language.Haskell.TH.Syntax (Exp,Lift(lift),Q) -import THEnv (getCompileEnv) -import Control.Monad - -getCompileEnvJSON :: (FromJSON a) => String -> Q a -getCompileEnvJSON name = - either error (id :: a -> a) . eitherDecode . pack <$> getCompileEnv name - -getCompileEnvJSONExp :: - forall proxy a. (FromJSON a, Lift a) => proxy a -> String -> Q Exp -getCompileEnvJSONExp _ = - (lift :: a -> Q Exp) <=< getCompileEnvJSON diff --git a/tv/5pkgs/haskell/xmonad-tv/src/main.hs b/tv/5pkgs/haskell/xmonad-tv/src/main.hs index d4c9c6adf..a5b3489bc 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/main.hs +++ b/tv/5pkgs/haskell/xmonad-tv/src/main.hs @@ -7,7 +7,10 @@ import System.Exit (exitFailure) import Control.Exception import Control.Monad.Extra (whenJustM) +import qualified Data.Aeson +import qualified Data.ByteString.Char8 import qualified Data.List +import qualified Data.Maybe import Graphics.X11.ExtraTypes.XF86 import Text.Read (readEither) import XMonad @@ -40,8 +43,6 @@ import XMonad.Actions.PerWorkspaceKeys (chooseAction) import Shutdown (shutdown, newShutdownEventHandler) -import Build (myFont, myScreenWidth, myTermFontWidth, myTermPadding) - main :: IO () main = getArgs >>= \case @@ -53,9 +54,19 @@ main = getArgs >>= \case (=??) :: Query a -> (a -> Bool) -> Query Bool (=??) x p = fmap p x +readEnv :: Data.Aeson.FromJSON b => String -> IO b +readEnv name = + Data.Maybe.fromJust + . Data.Aeson.decodeStrict' + . Data.ByteString.Char8.pack + <$> getEnv name mainNoArgs :: IO () mainNoArgs = do + myScreenWidth <- readEnv "XMONAD_SCREEN_WIDTH" :: IO Dimension + myTermFont <- getEnv "XMONAD_TERM_FONT" + myTermFontWidth <- readEnv "XMONAD_TERM_FONT_WIDTH" :: IO Dimension + myTermPadding <- readEnv "XMONAD_TERM_PADDING" :: IO Dimension workspaces0 <- getWorkspaces0 handleShutdownEvent <- newShutdownEventHandler let @@ -72,7 +83,7 @@ mainNoArgs = do $ def { terminal = {-pkg:rxvt_unicode-}"urxvtc" , modMask = mod4Mask - , keys = myKeys + , keys = myKeys myTermFont , workspaces = workspaces0 , layoutHook = smartBorders $ @@ -133,8 +144,8 @@ spawnRootTerm = Nothing -myKeys :: XConfig Layout -> Map (KeyMask, KeySym) (X ()) -myKeys conf = Map.fromList $ +myKeys :: String -> XConfig Layout -> Map (KeyMask, KeySym) (X ()) +myKeys font conf = Map.fromList $ [ ((_4 , xK_Escape ), forkFile {-pkg-}"slock" [] Nothing) , ((_4S , xK_c ), kill) @@ -209,17 +220,15 @@ myKeys conf = Map.fromList $ resetLayout = setLayout $ XMonad.layoutHook conf promptXPConfig = - def { XMonad.Prompt.font = myFont } - - -xdeny :: X () -xdeny = - forkFile - {-pkg-}"xterm" - [ "-fn", myFont - , "-geometry", "300x100" - , "-name", "AlertFloat" - , "-bg", "#E4002B" - , "-e", "sleep", "0.05" - ] - Nothing + def { XMonad.Prompt.font = font } + + xdeny = + forkFile + {-pkg-}"xterm" + [ "-fn", font + , "-geometry", "300x100" + , "-name", "AlertFloat" + , "-bg", "#E4002B" + , "-e", "sleep", "0.05" + ] + Nothing diff --git a/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal b/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal index a3ddcb039..62faf2f00 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal +++ b/tv/5pkgs/haskell/xmonad-tv/src/xmonad-tv.cabal @@ -23,7 +23,6 @@ executable xmonad xmonad, xmonad-contrib other-modules: - Shutdown, - THEnv.JSON + Shutdown default-language: Haskell2010 ghc-options: -O2 -Wall -threaded |