Browse Source

Upgrade xmonad-contrib, new layout, new bindings

master
Peter J. Jones 2 months ago
parent
commit
9aa2632226
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49

+ 2
- 2
nix/xmonad-contrib.json View File

@@ -1,7 +1,7 @@
{
"url": "https://code.devalot.com/mirrors/xmonad-contrib.git",
"rev": "4ad6ecf892470a5202bf16784eeab4e365f7a90e",
"rev": "22539d630f8af676709472cdfe6c28b7dc13ae00",
"date": "2019-04-10T22:07:22-05:00",
"sha256": "1inmvg50lvc06awrg8i86bqhqgzrph0vm9p6n0sg97z0zyg9xax5",
"sha256": "13svgdhxpwzv8w019zh5xfllgpab233g6nvydvnv8kzwb3m6jfra",
"fetchSubmodules": false
}

+ 3
- 3
nix/xmonad.json View File

@@ -1,7 +1,7 @@
{
"url": "https://code.devalot.com/mirrors/xmonad.git",
"rev": "bb13853929f8f6fc59b526bcc10631e1bac309ad",
"date": "2018-09-30T13:34:01+02:00",
"sha256": "1f2w0vkv4i40sa52d0bxdhmn9zsikzymm91xwdi4m64nqwip1i97",
"rev": "b65728032d6d533732b1a570a2a901264ef62f00",
"date": "2019-11-17T12:08:20+05:30",
"sha256": "0q1ks7dnw3a08bflhhhcmf99isdpbjyxqz79ysx9k57mpm9800yc",
"fetchSubmodules": false
}

+ 1
- 2
src/XMonad/Local/Action.hs View File

@@ -36,8 +36,7 @@ import qualified XMonad.StackSet as W
manageHook :: ManageHook
manageHook = composeOne
[ -- Windows to ignore:
isInProperty "_NET_WM_STATE" "_NET_WM_STATE_SKIP_TASKBAR"
-?> (doCenterFloat >> doIgnore)
isInProperty "_NET_WM_STATE" "_NET_WM_STATE_SKIP_TASKBAR" -?> doIgnore

-- Start by tagging new windows:
, className =? "Chromium-browser" `addTagAndContinue` "browser"

+ 61
- 46
src/XMonad/Local/Keys.hs View File

@@ -13,7 +13,6 @@ module XMonad.Local.Keys (keys, rawKeys) where
--------------------------------------------------------------------------------
-- General Haskell Packages.
import qualified Data.Map as M
import Data.Maybe (fromMaybe)
import Graphics.X11.Xlib
import System.Directory
import System.FilePath ((</>))
@@ -44,8 +43,9 @@ import XMonad.Layout.Spacing
import XMonad.Layout.ZoomRow (zoomIn, zoomOut, zoomReset)
import XMonad.Prompt
import XMonad.Prompt.Shell (shellPrompt)
import XMonad.Prompt.Window (WindowPrompt(..), windowPrompt, windowMultiPrompt, allWindows, wsWindows)
import XMonad.Prompt.Window (WindowPrompt(..), windowMultiPrompt, allWindows, wsWindows)
import XMonad.Util.EZConfig (mkKeymap)
import qualified XMonad.Util.ExtensibleState as XState
import XMonad.Util.NamedScratchpad (namedScratchpadAction)

--------------------------------------------------------------------------------
@@ -89,9 +89,10 @@ withUpdatePointer = map addAction
--------------------------------------------------------------------------------
-- Specifically manage my prefix key (C-z), and for controlling XMonad.
baseKeys :: XConfig Layout -> [(String, X ())]
baseKeys _ =
baseKeys c =
[ ("M-x r", restartIntoDebugging)
, ("M-x <Space>", messageMenu Local.promptConfig)
, ("M-x <Space>", messageMenu c Local.promptConfig)
, ("M-.", repeatLastXMessage)
]

--------------------------------------------------------------------------------
@@ -104,9 +105,7 @@ windowKeys _ =
, ("M-w k", windows W.focusUp)
, ("M-w j", windows W.focusDown)
, ("M-u", focusUrgent)
, ("M-o", windowPromptGoto')
, ("M-C-o", windowPromptGoto)
, ("M-w c", windowPrompt Local.promptConfig BringCopy allWindows)
, ("M-o", windowPromptGoto)
, ("M-j", windowGo D False)
, ("M-k", windowGo U False)
, ("M-l", windowGo R False)
@@ -141,7 +140,7 @@ windowKeys _ =
-- Navigate windows by using tags.
windowTagKeys :: XConfig Layout -> [(String, X ())]
windowTagKeys _ =
[ ("M-/", tagPrompt Local.promptConfig)
[ ("M-/", tagPrompt Local.promptConfig >> sendMessage (IncLayoutN 0))
, ("M-a", primaryJumpTagUp)
, ("M-C-a", secondaryJumpTagUp)
, ("M-t a", addFocusTag)
@@ -178,8 +177,8 @@ windowTagKeys _ =
-- Keys for manipulating workspaces.
workspaceKeys :: XConfig Layout -> [(String, X ())]
workspaceKeys _ =
[ ("M-'", viewPrevWS)
, ("M-<Space>", switchProjectPrompt Local.promptConfig)
[ ("M-<Space>", switchProjectPrompt Local.promptConfig)
, ("M-'", viewPrevWS)
, ("M-f", lookupProject "mail" >>= mapM_ switchProject)
, ("M-g", lookupProject "browsers" >>= mapM_ switchProject)
]
@@ -193,27 +192,8 @@ layoutKeys c =
, ("M-S-1", withFocused (sendMessage . maximizeRestore))
, ("M-S-8", toggleLayout "Focus")
, ("M-M1-8", toggleLayout "Single")
, ("M-w s t", toggleWindowSpacingEnabled)
, ("M-w s 0", setScreenSpacing $ uniborder 0)
, ("M-w s 1", setScreenSpacing $ uniborder 10)
, ("M-w s 2", setScreenSpacing $ uniborder 20)
, ("M-w s 3", setScreenSpacing $ uniborder 30)
, ("M-w s 4", setScreenSpacing $ uniborder 40)
, ("M-w s 5", setScreenSpacing $ uniborder 5)
, ("M-C-S-=", incWindowSpacing 1)
, ("M-C--", decWindowSpacing 1)
, ("M-M1-C-S-=", incScreenSpacing 2)
, ("M-M1-C--", decScreenSpacing 2)
, ("M-z S-=", sendMessage zoomIn)
, ("M-z -", sendMessage zoomOut)
, ("M-z <Esc>", sendMessage zoomReset)
, ("M-w M-s", sendMessage ToggleStruts)
]

where
uniborder :: Integer -> Border
uniborder n = Border n n n n

--------------------------------------------------------------------------------
-- Keys to manipulate screens (actual physical monitors).
screenKeys :: XConfig Layout -> [(String, X ())]
@@ -259,33 +239,68 @@ restartIntoDebugging = do
--------------------------------------------------------------------------------
windowPromptGoto :: X ()
windowPromptGoto = windowMultiPrompt Local.promptConfig modes
where modes = [(Goto, allWindows), (Goto, wsWindows)]

--------------------------------------------------------------------------------
windowPromptGoto' :: X ()
windowPromptGoto' = windowMultiPrompt Local.promptConfig modes
where modes = [(Goto, wsWindows), (Goto, allWindows)]
where modes = [ (Goto, allWindows)
, (Goto, wsWindows)
, (BringCopy, allWindows)
, (Bring, allWindows)
]

--------------------------------------------------------------------------------
-- | A menu of less frequently used actions:
data MessageMenu = MessageMenu

instance XPrompt MessageMenu where
showXPrompt MessageMenu = "X Action: "
showXPrompt MessageMenu = "XMonad Action: "

messageMenu :: XPConfig -> X ()
messageMenu conf =
mkXPrompt MessageMenu conf (Local.aListCompFunc conf actions) go
messageMenu :: XConfig Layout -> XPConfig -> X ()
messageMenu xc conf =
mkXPrompt MessageMenu conf' (Local.aListCompFunc conf' actions) go

where
go :: String -> X ()
go selected = fromMaybe (return ()) $ lookup selected actions
go selected = maybe (return ()) recordXMessage $ lookup selected actions

conf' :: XPConfig
conf' = conf { alwaysHighlight = True }

actions :: [ (String, X ()) ]
actions = [ ("IncLayoutN", sendMessage (IncLayoutN 1))
, ("DecLayoutN", sendMessage (IncLayoutN (-1)))
, ("IncMasterN", sendMessage (IncMasterN 1))
, ("DecMasterN", sendMessage (IncMasterN (-1)))
, ("ToggleStruts", sendMessage ToggleStruts)
, ("ToggleSpacing", toggleWindowSpacingEnabled)
actions = [ ("IncLayoutN", sendMessage (IncLayoutN 1))
, ("DecLayoutN", sendMessage (IncLayoutN (-1)))
, ("Next Layout", sendMessage NextLayout)
, ("IncMasterN", sendMessage (IncMasterN 1))
, ("DecMasterN", sendMessage (IncMasterN (-1)))
, ("ToggleStruts", sendMessage ToggleStruts)
, ("ToggleSpacing", toggleWindowSpacingEnabled)
, ("Tile Window", withFocused $ windows . W.sink)
, ("Screen Spacing 0", setScreenSpacing (Border 0 0 0 0))
, ("Screen Spacing +5", incWindowSpacing 5)
, ("Screen Spacing -5", decWindowSpacing 5)
, ("Window Spacing +5", incWindowSpacing 5)
, ("Window Spacing -5", decWindowSpacing 5)
, ("ZoomIn", sendMessage zoomIn)
, ("ZoomOut", sendMessage zoomOut)
, ("ZoomReset", sendMessage zoomReset)
, ("Reset Layout", setLayout (layoutHook xc))
]

--------------------------------------------------------------------------------
-- | Remember certain actions taken so they can be repeated.
newtype LastXMessage = LastXMessage
{ getLastMessage :: X () }

instance ExtensionClass LastXMessage where
initialValue = LastXMessage (return ())

--------------------------------------------------------------------------------
-- | Record the given message as the last used message, then execute it.
recordXMessage :: X () -> X ()
recordXMessage message = do
XState.put (LastXMessage message)
message

--------------------------------------------------------------------------------
-- | Execute the last recorded message.
repeatLastXMessage :: X ()
repeatLastXMessage = do
message <- getLastMessage <$> XState.get
message

+ 22
- 16
src/XMonad/Local/Layout.hs View File

@@ -76,6 +76,7 @@ layoutHook =
single = layoutAll (relBox (1/4) (1/30) (3/4) (29/30)) Simplest
auto = ifMax 1 (noBorders cgrid) $ ifMax 2 twoPane threeCols
mail = ifMax 1 (noBorders small) $ ifMax 2 small threeCols
devMirror = reflectHoriz dev

-- A layout where windows you want to focus on are specified using
-- @WindowProperties@. Windows matching the given properties will
@@ -106,25 +107,26 @@ layoutHook =
dev =
let leftBox = relBox 0 0 (1/3) 1
rightBox = relBox (1/3) 0 1 1
prop = ClassName "Firefox"
prop = Or (ClassName "Firefox") (Tagged "side")
in layoutP prop leftBox Nothing grid $
layoutAll rightBox tall

allLays =
renamed [Replace "Auto"] auto |||
renamed [Replace "1080p"] ten80 |||
renamed [Replace "2C"] twoCols |||
renamed [Replace "2P"] twoPane |||
renamed [Replace "3C"] threeCols |||
renamed [Replace "Big"] big |||
renamed [Replace "Chat"] chat |||
renamed [Replace "Dev"] dev |||
renamed [Replace "Focus"] focusTag |||
renamed [Replace "Grid"] grid |||
renamed [Replace "Mail"] mail |||
renamed [Replace "Single"] single |||
renamed [Replace "Tall"] tall |||
renamed [Replace "Full"] full
renamed [Replace "Auto"] auto |||
renamed [Replace "1080p"] ten80 |||
renamed [Replace "2C"] twoCols |||
renamed [Replace "2P"] twoPane |||
renamed [Replace "3C"] threeCols |||
renamed [Replace "Big"] big |||
renamed [Replace "Chat"] chat |||
renamed [Replace "Dev"] dev |||
renamed [Replace "Dev Mirror"] devMirror |||
renamed [Replace "Focus"] focusTag |||
renamed [Replace "Grid"] grid |||
renamed [Replace "Mail"] mail |||
renamed [Replace "Single"] single |||
renamed [Replace "Tall"] tall |||
renamed [Replace "Full"] full

--------------------------------------------------------------------------------
-- | A data type for the @XPrompt@ class.
@@ -137,7 +139,7 @@ instance XPrompt LayoutByName where
-- | Use @Prompt@ to choose a layout.
selectLayoutByName :: XPConfig -> X ()
selectLayoutByName conf =
mkXPrompt LayoutByName conf (aListCompFunc conf layoutNames) go
mkXPrompt LayoutByName conf' (aListCompFunc conf' layoutNames) go

where
go :: String -> X ()
@@ -146,6 +148,9 @@ selectLayoutByName conf =
Nothing -> return ()
Just name -> sendMessage (JumpToLayout name)

conf' :: XPConfig
conf' = conf { alwaysHighlight = True }

layoutNames :: [(String, String)]
layoutNames =
[ ("Auto", "Auto")
@@ -153,6 +158,7 @@ selectLayoutByName conf =
, ("Big", "Big")
, ("Chat", "Chat")
, ("Dev", "Dev")
, ("Dev Mirror", "Dev Mirror")
, ("Focus", "Focus")
, ("Full", "Full")
, ("Grid", "Grid")

+ 6
- 4
src/XMonad/Local/Music.hs View File

@@ -58,20 +58,22 @@ radioStationPlaylist = do

--------------------------------------------------------------------------------
radioPrompt :: XPConfig -> X ()
radioPrompt c = do
radioPrompt conf = do
playlist' <- io $ radioStationPlaylist `catch` econst (Left "fail")

case playlist' of
Left _ -> return ()
Right playlist -> go playlist


where
go :: Playlist -> X ()
go playlist = mkXPrompt RadioStream c (comp playlist) (playStream playlist)
go playlist = mkXPrompt RadioStream conf' (comp playlist) (playStream playlist)

conf' :: XPConfig
conf' = conf { alwaysHighlight = True }

comp :: Playlist -> ComplFunction
comp = listCompFunc c . titles
comp = listCompFunc conf' . titles

titles :: Playlist -> [String]
titles = mapMaybe (fmap Text.unpack . trackTitle)

+ 1
- 1
src/XMonad/Local/Prompt.hs View File

@@ -28,7 +28,7 @@ promptConfig :: XPConfig
promptConfig = def
{ position = CenteredAt (1/3) (1/2)
, height = 50
, font = "xft:Office Code Pro:size=14"
, font = "xft:Fira Code:size=14"
, bgColor = "#262e3d"
, fgColor = "#eeeeee"
, fgHLight = "#ffffff"

+ 16
- 0
src/XMonad/Local/Workspaces.hs View File

@@ -91,6 +91,22 @@ projects =
spawn "e -cs rfa"
spawn terminal
}

, Project { projectName = "sthenauth"
, projectDirectory = "~/src/haskell/sthenauth"
, projectStartHook = Just $ do
sendMessage (JumpToLayout "Dev")
spawn "e -cs sthenauth"
spawn terminal
}

, Project { projectName = "iolaus"
, projectDirectory = "~/src/haskell/iolaus"
, projectStartHook = Just $ do
sendMessage (JumpToLayout "Dev")
spawn "e -cs iolaus"
spawn terminal
}
]

--------------------------------------------------------------------------------

+ 1
- 1
xmonadrc.cabal View File

@@ -41,7 +41,7 @@ common dependencies
, setlocale >= 1.0 && < 1.1
, text >= 0.11 && < 1.3
, xmonad == 0.15
, xmonad-contrib == 0.15
, xmonad-contrib == 0.16

------------------------------------------------------------------------------
library

Loading…
Cancel
Save