tv xmonad: read screen/font width from build env
This commit is contained in:
parent
0cbb18c16e
commit
291bc460d5
@ -6,6 +6,12 @@ let
|
|||||||
configDir = "/var/empty";
|
configDir = "/var/empty";
|
||||||
dataDir = "/run/xdg/${cfg.user.name}/xmonad";
|
dataDir = "/run/xdg/${cfg.user.name}/xmonad";
|
||||||
user = config.krebs.build.user;
|
user = config.krebs.build.user;
|
||||||
|
xmonad.pkg = pkgs.haskellPackages.xmonad-tv.overrideAttrs (_: {
|
||||||
|
XMONAD_BUILD_SCREEN_WIDTH = 1366;
|
||||||
|
XMONAD_BUILD_TERM_FONT_WIDTH = 6;
|
||||||
|
XMONAD_BUILD_TERM_FONT = "-*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-1";
|
||||||
|
XMONAD_BUILD_TERM_PADDING = 2;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
|
||||||
@ -51,7 +57,7 @@ in {
|
|||||||
systemd.services.display-manager.enable = false;
|
systemd.services.display-manager.enable = false;
|
||||||
|
|
||||||
systemd.services.xmonad = let
|
systemd.services.xmonad = let
|
||||||
xmonad = "${pkgs.haskellPackages.xmonad-tv}/bin/xmonad";
|
xmonad = "${cfg.xmonad.pkg}/bin/xmonad";
|
||||||
xmonad-start = pkgs.writeDash "xmonad-start" ''
|
xmonad-start = pkgs.writeDash "xmonad-start" ''
|
||||||
${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CACHE_DIR"
|
${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CACHE_DIR"
|
||||||
${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CONFIG_DIR"
|
${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CONFIG_DIR"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{ mkDerivation, base, containers, directory, extra, stdenv, unix
|
{ mkDerivation, aeson, base, bytestring, containers, directory
|
||||||
, X11, xmonad, xmonad-contrib, xmonad-stockholm
|
, extra, stdenv, template-haskell, th-env, unix, X11, xmonad
|
||||||
|
, xmonad-contrib, xmonad-stockholm
|
||||||
}:
|
}:
|
||||||
mkDerivation {
|
mkDerivation {
|
||||||
pname = "xmonad-tv";
|
pname = "xmonad-tv";
|
||||||
@ -8,8 +9,8 @@ mkDerivation {
|
|||||||
isLibrary = false;
|
isLibrary = false;
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
executableHaskellDepends = [
|
executableHaskellDepends = [
|
||||||
base containers directory extra unix X11 xmonad xmonad-contrib
|
aeson base bytestring containers directory extra template-haskell
|
||||||
xmonad-stockholm
|
th-env unix X11 xmonad xmonad-contrib xmonad-stockholm
|
||||||
];
|
];
|
||||||
license = stdenv.lib.licenses.mit;
|
license = stdenv.lib.licenses.mit;
|
||||||
}
|
}
|
||||||
|
18
tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs
Normal file
18
tv/5pkgs/haskell/xmonad-tv/src/THEnv/JSON.hs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{-# 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
|
@ -1,4 +1,6 @@
|
|||||||
{-# LANGUAGE LambdaCase #-}
|
{-# LANGUAGE LambdaCase #-}
|
||||||
|
{-# LANGUAGE TemplateHaskell #-}
|
||||||
|
{-# LANGUAGE TypeApplications #-}
|
||||||
|
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
@ -32,10 +34,23 @@ import XMonad.Stockholm.Pager
|
|||||||
import XMonad.Stockholm.Shutdown
|
import XMonad.Stockholm.Shutdown
|
||||||
import qualified Paths
|
import qualified Paths
|
||||||
|
|
||||||
|
import THEnv.JSON (getCompileEnvJSONExp)
|
||||||
|
|
||||||
|
|
||||||
myFont :: String
|
myFont :: String
|
||||||
myFont = "-schumacher-*-*-*-*-*-*-*-*-*-*-*-iso10646-*"
|
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
|
||||||
|
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = getArgs >>= \case
|
main = getArgs >>= \case
|
||||||
@ -46,7 +61,6 @@ main = getArgs >>= \case
|
|||||||
|
|
||||||
mainNoArgs :: IO ()
|
mainNoArgs :: IO ()
|
||||||
mainNoArgs = do
|
mainNoArgs = do
|
||||||
let width = 1366
|
|
||||||
workspaces0 <- getWorkspaces0
|
workspaces0 <- getWorkspaces0
|
||||||
handleShutdownEvent <- newShutdownEventHandler
|
handleShutdownEvent <- newShutdownEventHandler
|
||||||
launch
|
launch
|
||||||
@ -60,8 +74,9 @@ mainNoArgs = do
|
|||||||
smartBorders $
|
smartBorders $
|
||||||
ResizableTall
|
ResizableTall
|
||||||
1
|
1
|
||||||
(10 * 6 / width)
|
(fromIntegral (10 * myTermFontWidth) / fromIntegral myScreenWidth)
|
||||||
((80 * 6 + 2 * (1+1+1))/width) []
|
(fromIntegral (80 * myTermFontWidth + 2 * (myTermPadding + borderWidth def)) / fromIntegral myScreenWidth)
|
||||||
|
[]
|
||||||
|||
|
|||
|
||||||
Full
|
Full
|
||||||
, manageHook =
|
, manageHook =
|
||||||
|
@ -9,10 +9,14 @@ cabal-version: >=1.10
|
|||||||
executable xmonad
|
executable xmonad
|
||||||
main-is: main.hs
|
main-is: main.hs
|
||||||
build-depends:
|
build-depends:
|
||||||
|
aeson,
|
||||||
base,
|
base,
|
||||||
|
bytestring,
|
||||||
containers,
|
containers,
|
||||||
directory,
|
directory,
|
||||||
extra,
|
extra,
|
||||||
|
template-haskell,
|
||||||
|
th-env,
|
||||||
unix,
|
unix,
|
||||||
X11,
|
X11,
|
||||||
xmonad,
|
xmonad,
|
||||||
@ -20,6 +24,7 @@ executable xmonad
|
|||||||
xmonad-stockholm
|
xmonad-stockholm
|
||||||
other-modules:
|
other-modules:
|
||||||
Helpers.Path,
|
Helpers.Path,
|
||||||
Paths
|
Paths,
|
||||||
|
THEnv.JSON
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
ghc-options: -O2 -Wall -threaded
|
ghc-options: -O2 -Wall -threaded
|
||||||
|
Loading…
Reference in New Issue
Block a user