From f7cd94645921dae0b17e8666fcfa3e9b84f8111d Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Thu, 31 Dec 2020 06:22:10 +0000 Subject: Put xmonad config in separate file xmonad.hs is now its own standalone file, which is nice for syntax highlighting. The new version uses string substitution from nixpkgs' standard library. --- xmonad.hs | 28 ++++++++++++++++++++++++++++ xmonad.nix | 43 ++++++++++--------------------------------- 2 files changed, 38 insertions(+), 33 deletions(-) create mode 100644 xmonad.hs diff --git a/xmonad.hs b/xmonad.hs new file mode 100644 index 0000000..2f3525d --- /dev/null +++ b/xmonad.hs @@ -0,0 +1,28 @@ +import XMonad +import XMonad.Actions.Volume +import XMonad.Actions.PhysicalScreens +import XMonad.Util.Dzen +import XMonad.Hooks.EwmhDesktops +import XMonad.Util.EZConfig + +import Data.Default + +mymod = mod4Mask +myKeys = + [ ((mymod, xK_p), spawn "@dmenu@") + , ((mymod, xK_i), lowerVolume 5 >>= alert) + , ((mymod, xK_o), raiseVolume 5 >>= alert) + ] + ++ + [((mymod .|. mask, key), f sc) + | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..] + , (f, mask) <- [(viewScreen def, 0), (sendToScreen def, shiftMask)]] + +alert = dzenConfig (timeout 3 >=> onCurr xScreen) . show . round + +main = xmonad $ ewmh $ def + { terminal = "@terminal@" + , modMask = mymod + , borderWidth = 0 + , focusFollowsMouse = False + } `additionalKeys` myKeys diff --git a/xmonad.nix b/xmonad.nix index 7647094..41a9e51 100644 --- a/xmonad.nix +++ b/xmonad.nix @@ -5,39 +5,16 @@ enable = true; enableContribAndExtras = true; - # would be nice to have this as an actual haskell file, so I - # could get syntax highlighting, but I also need to make sure - # external programs are included as runtime dependencies - config = pkgs.writeText "xmonad.hs" '' - import XMonad - import XMonad.Actions.Volume - import XMonad.Actions.PhysicalScreens - import XMonad.Util.Dzen - import XMonad.Hooks.EwmhDesktops - import XMonad.Util.EZConfig - - import Data.Default - - mymod = mod4Mask - myKeys = - [ ((mymod, xK_p), spawn "${pkgs.rofi}/bin/rofi -show run") - , ((mymod, xK_i), lowerVolume 5 >>= alert) - , ((mymod, xK_o), raiseVolume 5 >>= alert) - ] - ++ - [((mymod .|. mask, key), f sc) - | (key, sc) <- zip [xK_w, xK_e, xK_r] [0..] - , (f, mask) <- [(viewScreen def, 0), (sendToScreen def, shiftMask)]] - - alert = dzenConfig (timeout 3 >=> onCurr xScreen) . show . round - - main = xmonad $ ewmh $ def - { terminal = "${pkgs.rxvt-unicode}/bin/urxvt" - , modMask = mymod - , borderWidth = 0 - , focusFollowsMouse = False - } `additionalKeys` myKeys - ''; + config = pkgs.stdenv.mkDerivation { + name = "xmonad-config"; + src = ./xmonad.hs; + dontUnpack = true; + terminal = "${pkgs.rxvt-unicode}/bin/urxvt"; + dmenu = "${pkgs.rofi}/bin/rofi -combi-modi window,run -show combi -modi combi"; + installPhase = '' + substituteAll "$src" "$out" + ''; + }; }; xsession.enable = true; -- cgit v1.2.1