stockholm/lass/5pkgs/xmonad-lass.nix

184 lines
6.5 KiB
Nix
Raw Normal View History

2017-09-19 09:45:33 +00:00
{ config, pkgs, ... }:
2016-06-21 13:43:45 +00:00
pkgs.writeHaskell "xmonad-lass" {
executables.xmonad = {
extra-depends = [
"containers"
2017-12-03 22:18:22 +00:00
"extra"
2016-06-21 13:43:45 +00:00
"unix"
"X11"
"xmonad"
"xmonad-contrib"
"xmonad-stockholm"
];
text = /* haskell */ ''
2015-11-13 00:07:54 +00:00
{-# LANGUAGE DeriveDataTypeable #-} -- for XS
{-# LANGUAGE FlexibleContexts #-} -- for xmonad'
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
2016-04-25 13:25:47 +00:00
import XMonad
2015-11-13 00:07:54 +00:00
2016-04-25 13:25:47 +00:00
import qualified XMonad.StackSet as W
2017-12-03 22:18:22 +00:00
import Control.Monad.Extra (whenJustM)
2016-04-25 13:25:47 +00:00
import Data.List (isInfixOf)
2018-02-13 16:38:19 +00:00
import Data.Monoid (Endo)
2017-12-03 22:18:22 +00:00
import System.Environment (getArgs, lookupEnv)
import System.Posix.Process (executeFile)
2016-04-25 13:25:47 +00:00
import XMonad.Actions.CopyWindow (copy, kill1)
2015-11-13 00:07:54 +00:00
import XMonad.Actions.CycleWS (toggleWS)
2016-04-25 13:25:47 +00:00
import XMonad.Actions.DynamicWorkspaces ( addWorkspacePrompt, renameWorkspace, removeEmptyWorkspace)
import XMonad.Actions.DynamicWorkspaces (withWorkspace)
import XMonad.Actions.GridSelect (GSConfig(..), gridselectWorkspace, navNSearch)
2017-12-13 17:31:55 +00:00
import XMonad.Hooks.EwmhDesktops (ewmh)
2016-04-25 13:25:47 +00:00
import XMonad.Hooks.FloatNext (floatNext)
import XMonad.Hooks.FloatNext (floatNextHook)
import XMonad.Hooks.ManageDocks (avoidStruts, ToggleStruts(ToggleStruts))
import XMonad.Hooks.Place (placeHook, smart)
import XMonad.Hooks.UrgencyHook (focusUrgent)
2018-02-13 16:37:48 +00:00
import XMonad.Hooks.UrgencyHook (withUrgencyHook, UrgencyHook(..))
2015-11-13 00:07:54 +00:00
import XMonad.Layout.FixedColumn (FixedColumn(..))
2016-04-25 14:31:08 +00:00
import XMonad.Layout.Minimize (minimize, minimizeWindow, MinimizeMsg(RestoreNextMinimizedWin))
2016-04-25 15:24:54 +00:00
import XMonad.Layout.NoBorders (smartBorders)
2017-12-13 17:32:38 +00:00
import XMonad.Layout.SimplestFloat (simplestFloat)
2017-09-19 09:45:33 +00:00
import XMonad.Prompt (autoComplete, font, searchPredicate, XPConfig)
2016-04-25 13:25:47 +00:00
import XMonad.Prompt.Window (windowPromptGoto, windowPromptBringCopy)
2015-11-13 00:07:54 +00:00
import XMonad.Util.EZConfig (additionalKeysP)
2018-02-13 16:37:48 +00:00
import XMonad.Util.NamedWindows (getName)
import XMonad.Util.Run (safeSpawn)
2015-11-13 00:07:54 +00:00
import XMonad.Stockholm.Shutdown
2018-02-13 16:37:48 +00:00
data LibNotifyUrgencyHook = LibNotifyUrgencyHook deriving (Read, Show)
instance UrgencyHook LibNotifyUrgencyHook where
urgencyHook LibNotifyUrgencyHook w = do
name <- getName w
Just idx <- fmap (W.findTag w) $ gets windowset
safeSpawn "${pkgs.libnotify}/bin/notify-send" [show name, "workspace " ++ idx]
2017-10-09 11:25:28 +00:00
myTerm :: FilePath
2017-12-03 22:18:22 +00:00
myTerm = "${pkgs.rxvt_unicode_with-plugins}/bin/urxvtc"
2015-11-13 00:07:54 +00:00
myFont :: String
2017-10-09 11:02:14 +00:00
myFont = "${config.lass.fonts.regular}"
2015-11-13 00:07:54 +00:00
main :: IO ()
main = getArgs >>= \case
2017-12-03 22:18:22 +00:00
["--shutdown"] -> sendShutdownEvent
_ -> main'
2015-11-13 00:07:54 +00:00
2017-12-03 22:18:22 +00:00
main' :: IO ()
main' = do
2017-12-13 17:31:55 +00:00
xmonad $ ewmh
2018-02-13 16:37:48 +00:00
$ withUrgencyHook LibNotifyUrgencyHook
$ def
2017-10-09 11:25:28 +00:00
{ terminal = myTerm
2017-10-05 14:17:12 +00:00
, modMask = mod4Mask
, layoutHook = smartBorders $ myLayoutHook
2017-12-31 01:48:02 +00:00
, manageHook = placeHook (smart (1,0)) <+> floatNextHook <+> floatHooks
2017-12-03 22:18:22 +00:00
, startupHook =
whenJustM (liftIO (lookupEnv "XMONAD_STARTUP_HOOK"))
(\path -> forkFile path [] Nothing)
2015-11-13 00:07:54 +00:00
, normalBorderColor = "#1c1c1c"
2017-12-03 22:18:22 +00:00
, focusedBorderColor = "#ff0000"
2017-10-05 14:17:12 +00:00
, handleEventHook = handleShutdownEvent
, workspaces = [ "dashboard", "sys", "wp" ]
2015-11-13 00:07:54 +00:00
} `additionalKeysP` myKeyMap
myLayoutHook = defLayout
where
2017-12-13 17:32:38 +00:00
defLayout = minimize $ ((avoidStruts $ Tall 1 (3/100) (1/2) ||| Full ||| Mirror (Tall 1 (3/100) (1/2))) ||| FixedColumn 2 80 80 1 ||| simplestFloat)
2015-11-13 00:07:54 +00:00
2018-02-13 16:38:19 +00:00
floatHooks :: Query (Endo WindowSet)
2017-12-31 01:48:02 +00:00
floatHooks = composeAll . concat $
[ [ title =? t --> doFloat | t <- myTitleFloats]
, [ className =? c --> doFloat | c <- myClassFloats ] ]
where
2018-02-13 16:38:19 +00:00
myTitleFloats = []
2017-12-31 01:48:02 +00:00
myClassFloats = ["Pinentry"] -- for gpg passphrase entry
2016-04-25 13:25:47 +00:00
myKeyMap :: [([Char], X ())]
2015-11-13 00:07:54 +00:00
myKeyMap =
2017-10-19 16:42:09 +00:00
[ ("M4-<F11>", spawn "${config.lass.screenlock.command}")
, ("M4-C-p", spawn "${pkgs.scrot}/bin/scrot ~/public_html/scrot.png")
2016-06-30 15:24:50 +00:00
, ("M4-p", spawn "${pkgs.pass}/bin/passmenu --type")
2017-08-21 10:49:29 +00:00
, ("M4-o", spawn "${pkgs.brain}/bin/brainmenu --type")
2017-09-19 09:46:29 +00:00
, ("M4-i", spawn "${pkgs.dpass}/bin/dpassmenu --type")
2017-12-13 17:37:13 +00:00
, ("<XF86AudioMute>", spawn "${pkgs.pulseaudioLight.out}/bin/pactl -- set-sink-mute @DEFAULT_SINK@ toggle")
, ("<XF86AudioRaiseVolume>", spawn "${pkgs.pulseaudioLight.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ +4%")
, ("<XF86AudioLowerVolume>", spawn "${pkgs.pulseaudioLight.out}/bin/pactl -- set-sink-volume @DEFAULT_SINK@ -4%")
2017-01-16 16:29:41 +00:00
, ("<XF86MonBrightnessDown>", spawn "${pkgs.xorg.xbacklight}/bin/xbacklight -time 0 -dec 1%")
, ("<XF86MonBrightnessUp>", spawn "${pkgs.xorg.xbacklight}/bin/xbacklight -time 0 -inc 1")
2016-04-25 13:25:47 +00:00
, ("<XF86Launch1>", gridselectWorkspace gridConfig W.view)
2016-11-10 21:34:59 +00:00
, ("M4-C-k", spawn "${pkgs.xorg.xkill}/bin/xkill")
2015-11-13 00:07:54 +00:00
, ("M4-a", focusUrgent)
2017-09-19 09:45:33 +00:00
, ("M4-S-r", renameWorkspace myXPConfig)
, ("M4-S-a", addWorkspacePrompt myXPConfig)
2015-11-13 00:07:54 +00:00
, ("M4-S-<Backspace>", removeEmptyWorkspace)
, ("M4-S-c", kill1)
, ("M4-<Esc>", toggleWS)
2017-10-09 11:25:28 +00:00
, ("M4-S-<Enter>", spawn myTerm)
, ("M4-x", floatNext True >> spawn myTerm)
2017-09-20 16:16:56 +00:00
, ("M4-c", floatNext True >> spawn "${pkgs.termite}/bin/termite")
2015-11-13 00:07:54 +00:00
, ("M4-f", floatNext True)
, ("M4-b", sendMessage ToggleStruts)
2017-10-05 03:02:37 +00:00
, ("M4-v", withWorkspace autoXPConfig (windows . W.greedyView))
2016-04-25 13:25:47 +00:00
, ("M4-S-v", withWorkspace autoXPConfig (windows . W.shift))
, ("M4-C-v", withWorkspace autoXPConfig (windows . copy))
2015-11-13 00:07:54 +00:00
2016-04-25 14:31:08 +00:00
, ("M4-m", withFocused minimizeWindow)
, ("M4-S-m", sendMessage RestoreNextMinimizedWin)
2016-04-25 13:25:47 +00:00
, ("M4-q", windowPromptGoto infixAutoXPConfig)
, ("M4-C-q", windowPromptBringCopy infixAutoXPConfig)
2015-11-13 00:07:54 +00:00
, ("M4-S-q", return ())
2017-01-10 15:18:00 +00:00
2017-10-05 03:03:10 +00:00
, ("M4-d", floatNext True >> spawn "${pkgs.copyq}/bin/copyq show")
2017-10-05 03:03:10 +00:00
, ("M4-<F5>", spawn "${pkgs.xorg.xbacklight}/bin/xbacklight -set 1")
, ("M4-<F6>", spawn "${pkgs.xorg.xbacklight}/bin/xbacklight -set 10")
, ("M4-<F7>", spawn "${pkgs.xorg.xbacklight}/bin/xbacklight -set 33")
, ("M4-<F8>", spawn "${pkgs.xorg.xbacklight}/bin/xbacklight -set 100")
2017-10-18 17:52:00 +00:00
, ("<Pause>", spawn "${pkgs.xcalib}/bin/xcalib -invert -alter")
2015-11-13 00:07:54 +00:00
]
forkFile :: FilePath -> [String] -> Maybe [(String, String)] -> X ()
forkFile path args env =
xfork (executeFile path False args env) >> return ()
2017-09-19 09:45:33 +00:00
myXPConfig :: XPConfig
myXPConfig = def
{ font = myFont
}
2016-04-25 13:25:47 +00:00
autoXPConfig :: XPConfig
2017-09-19 09:45:33 +00:00
autoXPConfig = myXPConfig
2015-11-13 00:07:54 +00:00
{ autoComplete = Just 5000
}
2016-04-25 13:25:47 +00:00
infixAutoXPConfig :: XPConfig
infixAutoXPConfig = autoXPConfig
{ searchPredicate = isInfixOf
2015-11-13 00:07:54 +00:00
}
2016-04-25 13:25:47 +00:00
gridConfig :: GSConfig WorkspaceId
gridConfig = def
{ gs_cellwidth = 100
, gs_cellheight = 30
2016-04-25 13:25:47 +00:00
, gs_cellpadding = 2
2015-11-13 00:07:54 +00:00
, gs_navigate = navNSearch
2016-04-25 13:25:47 +00:00
, gs_font = myFont
2015-11-13 00:07:54 +00:00
}
2016-06-21 13:43:45 +00:00
'';
};
}