xmonad: add memo floating and navigation keys

This commit is contained in:
Ingolf Wagner 2020-01-25 22:11:41 +13:00
parent 3bc5ba3365
commit 1fae5c5366
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
3 changed files with 77 additions and 28 deletions

View file

@ -37,6 +37,7 @@ in {
home.file.".xmonad/lib/FloatKeys.hs".source = ./xmonad/FloatKeys.hs;
home.file.".xmonad/lib/TabbedFix.hs".source = ./xmonad/TabbedFix.hs;
home.file.".xmonad/lib/BoringWindows.hs".source = ./xmonad/BoringWindows.hs;
home.file.".xmonad/lib/Memo.hs".source = ./xmonad/Memo.hs;
home.file.".xmonad/lib/SubLayouts.hs".source = ./xmonad/SubLayouts.hs;
home.file.".xmonad/xmonad.cabal".source = ./xmonad/palos-xmonad.cabal;

View file

@ -10,6 +10,7 @@ import qualified Data.Map as M
import Data.Monoid (All, Endo)
import Data.Ratio ((%))
import FloatKeys (keysResizeWindow)
import Memo (nextRectangle)
import NixCommands
import qualified SolarizedLight as Solarized
import System.Exit
@ -23,6 +24,8 @@ import XMonad.Actions.DynamicProjects (Project (..),
import XMonad.Actions.DynamicWorkspaces (addHiddenWorkspace, removeEmptyWorkspaceAfterExcept,
renameWorkspace,
withWorkspace)
import XMonad.Actions.Navigation2D (additionalNav2DKeysP,
windowGo, windowSwap)
import XMonad.Actions.UpdatePointer (updatePointer)
import XMonad.Actions.Warp (warpToScreen)
import XMonad.Hooks.DynamicLog (dynamicLog)
@ -45,6 +48,8 @@ import XMonad.Util.Scratchpad (scratchpadManageHook,
scratchpadSpawnAction)
import XMonad.Util.SpawnOnce (spawnOnce)
------------------------------------------------------------------------
--
-- Layouts
@ -52,7 +57,7 @@ import XMonad.Util.SpawnOnce (spawnOnce)
------------------------------------------------------------------------
selectionColor :: String
selectionColor = Solarized.violet
selectionColor = Solarized.magenta
nonSelectionColor :: String
nonSelectionColor = Solarized.base02
@ -63,7 +68,7 @@ myLayout = (windowConfiguration $ smartBorders $ boringWindows resizeableTall)
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
ratio = 12 / 20
ratio = 1 / 2
-- Percent of screen to increment by when resizing panes
delta = 3 / 100
@ -296,7 +301,15 @@ myAdditionaKeys
(do sendMessage MirrorShrink
sendMessage Reset))
-- Toggle window tiling/floating
, ("t", withFocused $ toggleFloating (W.RationalRect 0.65 0.65 0.35 0.35))
, ("t", do
next <- nextRectangle
withFocused $ toggleFloating next)
, ("n", withFocused $ floatTileCommand
(do
position <- nextRectangle
withFocused (windows . (`W.float` position)))
(return ())
)
-- Increment the number of windows in the master area
, (",", sendMessage (IncMasterN 1))
-- Deincrement the number of windows in the master area
@ -462,19 +475,20 @@ updateBoring = do focusUp
-- No need to modify this.
--
defaults =
additionalNav2DKeysP
("<Up>", "<Left>", "<Down>", "<Right>")
[("M-", windowGo), ("M-S-", windowSwap)]
False
def
{ terminal = myTerm
-- Whether focus follows the mouse pointer.
, focusFollowsMouse = True
-- Whether clicking on a window to focus also passes the click to the window
, clickJustFocuses = False
-- color configuration
, normalBorderColor = nonSelectionColor
, focusedBorderColor = selectionColor
, borderWidth = 1
-- modMask lets you specify which modkey you want to use.
-- mod1Mask ("left alt").
-- mod3Mask ("right alt")
@ -484,20 +498,17 @@ defaults =
-- key bindings
, keys = myKeys
, mouseBindings = mouse
-- , layoutHook = focusTracking $ historyLayout myLayout
, layoutHook = focusTracking myLayout
-- , logHook = myLogHook <> runAllPending
, logHook = myLogHook
, startupHook = startUp
, manageHook = myManageHook
, handleEventHook = myEventHook
} `additionalKeysP`
myAdditionaKeys
autoXPConfig :: XPConfig
autoXPConfig = myXPConfig {autoComplete = Just 5000}

View file

@ -0,0 +1,37 @@
{-# LANGUAGE DeriveDataTypeable #-}
{-| A hacky module to cycle through a list of
rectangles, I'm using this to place a floating window somehwere
when it is in my way -}
module Memo where
import XMonad.Config.Prime
import qualified XMonad.StackSet as W
import qualified XMonad.Util.ExtensibleState as ES
newtype MemoStorage =
MemoStorage [W.RationalRect]
deriving (Typeable)
-- (RationalRect x y height width)
instance ExtensionClass MemoStorage where
initialValue =
MemoStorage
(cycle
[ (W.RationalRect 0.0 0.0 0.4 0.4) -- oben links
, (W.RationalRect 0.6 0.6 0.4 0.4) -- unten rechts
, (W.RationalRect 0.6 0.0 0.4 0.4) -- oben rechts
, (W.RationalRect 0.0 0.6 0.4 0.4) -- unten links
, (W.RationalRect 0.25 0.00 0.4 0.4) -- oben mitte
, (W.RationalRect 0.25 0.60 0.4 0.4) -- unten mitte
, (W.RationalRect 0.00 0.25 0.4 0.4) -- links mitte
, (W.RationalRect 0.60 0.25 0.4 0.4) -- rechts mitte
])
nextRectangle :: X W.RationalRect
nextRectangle = do
MemoStorage next <- ES.get :: X MemoStorage
ES.modify (\(MemoStorage (_:xs)) -> MemoStorage xs)
return (head next)