Browse Source

Switching from BSPWM to XMonad, needed to make some adjustments

master
Peter J. Jones 6 months ago
parent
commit
14e6ae4045
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49
6 changed files with 203 additions and 301 deletions
  1. 77
    0
      scripts/run-in-xephyr.sh
  2. 61
    170
      src/XMonad/Local/Keys.hs
  3. 49
    41
      src/XMonad/Local/Layout.hs
  4. 3
    3
      src/XMonad/Local/Theme.hs
  5. 10
    82
      src/XMonad/Local/Workspaces.hs
  6. 3
    5
      xmonadrc.hs

+ 77
- 0
scripts/run-in-xephyr.sh View File

@@ -0,0 +1,77 @@
#!/bin/sh -eu

################################################################################
usage () {
cat <<EOF
Usage: run-in-xephyr.sh [options]

-d NxN Set the screen size to NxN
-h This message
-n NUM Set the internal DISPLAY to NUM
-s NUM Set the number of screens to NUM
EOF
}

################################################################################
SCREENS=1
SCREEN_SIZE="800x600"
DISPLAY_NUMBER=5

################################################################################
while getopts "d:hn:s:" o; do
case "${o}" in
d) SCREEN_SIZE=$OPTARG
;;

h) usage
exit
;;

n) DISPLAY_NUMBER=$OPTARG
;;

s) SCREENS=$OPTARG
;;

*) echo; usage
exit 1
;;
esac
done

shift $((OPTIND-1))

################################################################################
XMONAD_CONFIG_DIR=$(pwd)/state/config
XMONAD_CACHE_DIR=$(pwd)/state/cache
XMONAD_DATA_DIR=$(pwd)/state/data
export XMONAD_CONFIG_DIR XMONAD_CACHE_DIR XMONAD_DATA_DIR

mkdir -p "$XMONAD_CONFIG_DIR" "$XMONAD_CACHE_DIR" "$XMONAD_DATA_DIR"
echo "xmonad will store state files in $(pwd)/state"

################################################################################
SCREEN_COUNTER=0
SCREEN_OPTS=""
X_OFFSET_CURRENT="0"
X_OFFSET_ADD=$(echo "$SCREEN_SIZE" | cut -dx -f1)

while expr "$SCREEN_COUNTER" "<" "$SCREENS"; do
SCREEN_OPTS="$SCREEN_OPTS -origin ${X_OFFSET_CURRENT},0 -screen ${SCREEN_SIZE}+${X_OFFSET_CURRENT}"
SCREEN_COUNTER=$(("$SCREEN_COUNTER" + 1))
X_OFFSET_CURRENT=$(("$X_OFFSET_CURRENT" + "$X_OFFSET_ADD"))
done

(
# shellcheck disable=SC2086
Xephyr $SCREEN_OPTS +xinerama +extension RANDR \
-ac -br -reset -terminate -verbosity 10 \
-softCursor ":$DISPLAY_NUMBER" &

export DISPLAY=":$DISPLAY_NUMBER"
echo "Waiting for windows to appear..." && sleep 2

xterm -hold xrandr &
xterm &
dist/build/xmonadrc/xmonadrc
)

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

@@ -13,9 +13,9 @@ module XMonad.Local.Keys (keys, rawKeys) where
--------------------------------------------------------------------------------
-- General Haskell Packages.
import qualified Data.Map as M
import Data.Version (showVersion)
import Graphics.X11.Xlib
import System.Directory
import System.FilePath ((</>))

--------------------------------------------------------------------------------
-- Package: xmonad.
@@ -25,6 +25,7 @@ import qualified XMonad.StackSet as W
--------------------------------------------------------------------------------
-- Package: xmonad-contrib.
import XMonad.Actions.CopyWindow (kill1)
import XMonad.Actions.CycleSelectedLayouts (cycleThroughLayouts)
import XMonad.Actions.DynamicProjects (switchProjectPrompt)
import XMonad.Actions.GroupNavigation (Direction (..), nextMatch)
import XMonad.Actions.Navigation2D
@@ -34,42 +35,23 @@ import XMonad.Actions.TagWindows (addTag, delTag, withTagged)
import XMonad.Actions.UpdatePointer (updatePointer)
import XMonad.Hooks.ManageDocks (ToggleStruts(..))
import XMonad.Hooks.UrgencyHook (focusUrgent)
import XMonad.Layout.BinarySpacePartition hiding (Swap)
import XMonad.Layout.ComboP (PartitionWins(..))
import XMonad.Layout.Gaps (GapMessage(..))
import XMonad.Layout.LayoutCombinators (JumpToLayout(..))
import XMonad.Layout.ResizableTile
import XMonad.Layout.Spacing (incWindowSpacing, decWindowSpacing, toggleWindowSpacingEnabled)
import XMonad.Layout.ToggleLayouts (ToggleLayout(..))
import XMonad.Prompt.ConfirmPrompt (confirmPrompt)
import XMonad.Prompt.Shell (shellPrompt)
import XMonad.Prompt.Window (WindowPrompt(..), windowPrompt, windowMultiPrompt, allWindows, wsWindows)
import XMonad.Prompt.XMonad (xmonadPrompt)
import XMonad.Util.EZConfig (mkKeymap)
import XMonad.Util.NamedScratchpad (namedScratchpadAction)

--------------------------------------------------------------------------------
-- Local modules.
import Paths_xmonadrc (version)
import XMonad.Local.Layout (selectLayoutByName)
import XMonad.Local.Music (radioPrompt)
import XMonad.Local.Prompt (promptConfig)
import qualified XMonad.Local.Prompt as Local
import XMonad.Local.Tagging
import XMonad.Local.Workspaces (asKey, viewPrevWS, scratchPads)

--------------------------------------------------------------------------------
data GPResize = GPExpandL
| GPExpandR
| GPExpandU
| GPExpandD
| GPShrinkL
| GPShrinkR
| GPShrinkU
| GPShrinkD

data LayoutType = BSP -- ^ Binary Space Partition
| Other -- ^ Other (generic) layout
import XMonad.Local.Workspaces (asKey, viewPrevWS)

--------------------------------------------------------------------------------
-- Join all the key maps into a single list and send it through @mkKeymap@.
@@ -105,10 +87,10 @@ withUpdatePointer = map addAction
-- Specifically manage my prefix key (C-z), and for controlling XMonad.
baseKeys :: XConfig Layout -> [(String, X ())]
baseKeys _ =
[ ("M-g", return ()) -- Same as above.
, ("M-x M-r", restart "xmonadrc" True)
, ("M-x M-d", restartIntoDebugging)
, ("M-x M-<Space>", xmonadPrompt Local.promptConfig)
[ ("M-g", return ()) -- Same as above.
, ("M-x r", restartIntoDebugging)
, ("M-x <Space>", xmonadPrompt Local.promptConfig)
, ("M-x <Esc>", spawn "systemctl --user restart compton.service")
]

--------------------------------------------------------------------------------
@@ -116,53 +98,52 @@ baseKeys _ =
windowKeys :: XConfig Layout -> [(String, X ())]
windowKeys _ =
-- Focusing Windows:
[ ("M-w M-l", nextMatch History (return True))
, ("M-w M-b", windows W.focusUp)
, ("M-w M-f", windows W.focusDown)
, ("M-w M-u", focusUrgent)
, ("M-w M-o", windowPromptGoto)
, ("M-w M-c", windowPrompt Local.promptConfig BringCopy allWindows)
, ("M-o", windowPromptGoto')
, ("M-n", windowGo D True)
, ("M-p", windowGo U True)
, ("M-f", windowGo R True)
, ("M-b", windowGo L True)
, ("M-w M-m", windows W.focusMaster)
[ ("M-;", nextMatch History (return True))
, ("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-j", windowGo D True)
, ("M-k", windowGo U True)
, ("M-l", windowGo R True)
, ("M-h", windowGo L True)
, ("M-w m", windows W.focusMaster)

-- Moving Windows:
, ("M-m M-f", windowSwap R False)
, ("M-m M-b", windowSwap L False)
, ("M-m M-n", windowSwap D False)
, ("M-m M-p", windowSwap U False)
, ("M-m M-m", promote) -- Promote current window to master.
, ("M-M1-l", windowSwap R False)
, ("M-M1-h", windowSwap L False)
, ("M-M1-j", windowSwap D False)
, ("M-M1-k", windowSwap U False)
, ("M-m", promote) -- Promote current window to master.

-- Resizing Windows:
, ("M-<Left>", sendResize GPExpandL)
, ("M-<Right>", sendResize GPShrinkL)
, ("M-<Up>", sendResize GPExpandU)
, ("M-<Down>", sendResize GPShrinkU)
, ("M-w -", sendMessage $ IncMasterN (-1))
, ("M-w =", sendMessage $ IncMasterN 1)
, ("M-C-h", sendMessage Shrink)
, ("M-C-l", sendMessage Expand)
, ("M-C-j", sendMessage MirrorShrink)
, ("M-C-k", sendMessage MirrorExpand)
, ("M-w -", sendMessage $ IncMasterN (-1))
, ("M-w S-=", sendMessage $ IncMasterN 1)

-- Window Layers and Killing and Yanking:
, ("M-w M-t", withFocused $ windows . W.sink) -- Tile window.
, ("M-w M-k", kill1) -- Kill the current window.
, ("M-k", killWindowToBury)
, ("M-y", yankWindowFromBury)
, ("M-w t", withFocused $ windows . W.sink) -- Tile window.
, ("M-q", kill1) -- Kill the current window.
, ("M-b", killWindowToBury)
, ("M-v", yankWindowFromBury)
]

--------------------------------------------------------------------------------
-- Navigate windows by using tags.
windowTagKeys :: XConfig Layout -> [(String, X ())]
windowTagKeys _ =
[ ("M-t M-<Space>", tagPrompt Local.promptConfig)
, ("M-S-t", tagPrompt Local.promptConfig)
, ("M-h", secondaryJumpTagUp)
, ("M-j", primaryJumpTagUp)
, ("M-t M-a", addFocusTag)
, ("M-t M-d", rmFocusTag)
, ("M-t M-j", tagPrompt' Local.promptConfig [SetJumpTag])
, ("M-t M-r", rmFocusTagAll >> addFocusTag)
[ ("M-/", tagPrompt Local.promptConfig)
, ("M-a", primaryJumpTagUp)
, ("M-s", secondaryJumpTagUp)
, ("M-t a", addFocusTag)
, ("M-t d", rmFocusTag)
, ("M-t j", tagPrompt' Local.promptConfig [SetJumpTag])
, ("M-t r", rmFocusTagAll >> addFocusTag)
] ++ numberedTags
where
addFocusTag :: X ()
@@ -193,8 +174,7 @@ windowTagKeys _ =
-- Keys for manipulating workspaces.
workspaceKeys :: XConfig Layout -> [(String, X ())]
workspaceKeys _ =
[ ("M-w M-w", viewPrevWS)
, ("M-S-w", viewPrevWS)
[ ("M-'", viewPrevWS)
, ("M-<Space>", switchProjectPrompt Local.promptConfig)
]

@@ -202,117 +182,42 @@ workspaceKeys _ =
-- Layout switching and manipulation.
layoutKeys :: XConfig Layout -> [(String, X ())]
layoutKeys c =
[ ("M-l M-<Space>", selectLayoutByName Local.promptConfig)
, ("M-l <Esc>", setLayout (layoutHook c)) -- Reset to default layout.
, ("M-l M-2", sendMessage (JumpToLayout "2C"))
, ("M-l M-3", sendMessage (JumpToLayout "3C"))
, ("M-l M-b", sendMessage (JumpToLayout "BSP"))
, ("M-l M-f", sendMessage (JumpToLayout "Focus") >> sendMessage PartitionWins)
, ("M-l M-l", sendMessage (Toggle "Full"))
, ("M-l M-t", sendMessage (JumpToLayout "Tall"))
, ("M-w M-g", sendMessage ToggleGaps)
, ("M-w M-r", sendMessage Rotate)
[ ("M-[", selectLayoutByName Local.promptConfig)
, ("M-]", sendMessage NextLayout)
, ("M-w <Esc>", setLayout (layoutHook c)) -- Reset to default layout.
, ("M-<Backspace>", sendMessage (Toggle "Full"))
, ("M-S-8", cycleThroughLayouts ["Auto", "Focus"])
, ("M-w g", sendMessage ToggleGaps)
, ("M-w s", toggleWindowSpacingEnabled)
, ("M-w M-s", sendMessage ToggleStruts)
, ("M-C-S-=", incWindowSpacing 5)
, ("M-C--", decWindowSpacing 5)
]

--------------------------------------------------------------------------------
-- Keys to manipulate screens (actual physical monitors).
screenKeys :: XConfig Layout -> [(String, X ())]
screenKeys _ =
[ ("M-s M-f", onNextNeighbour def W.view)
, ("M-s M-b", onPrevNeighbour def W.view)
, ("M-s M-s", screenSwap L True)
, ("M1-<F11>", spawn "xbacklight -dec 10")
, ("M1-<F12>", spawn "xbacklight -inc 10")
, ("M1-S-<F11>", spawn "xbacklight -set 10")
, ("M1-S-<F12>", spawn "xbacklight -set 80")
[ ("M-)", onNextNeighbour def W.view)
, ("M-(", onPrevNeighbour def W.view)
, ("M-\\", screenSwap L True)
]

--------------------------------------------------------------------------------
-- Keys for launching applications.
appKeys :: XConfig Layout -> [(String, X ())]
appKeys _ =
[ ("M-<Return>", spawn "urxvtc -e tmux-new-terminal")
, ("M-M1-<Return>", spawn "urxvtc -name BigTerm -e tmux-new-terminal")
, ("M-M1-l", spawn "lockscreen.sh")
, ("M-<Print> M-r", spawn "screenshot.sh root")
, ("M-<Print> M-w", spawn "screenshot.sh window")
, ("M-e M-e", spawn "e -c") -- Start per-workspace Emacs.
, ("M-e M-r", shellPrompt Local.promptConfig)

-- Laptops and keyboards with media/meta keys.
, ("<XF86WebCam>", spawn "tptoggle.sh") -- Weird.
, ("<XF86TouchpadToggle>", spawn "tptoggle.sh")
, ("M1-<F6>", spawn "tptoggle.sh")
, ("M1-<F10>", spawn "xrandr-projector")

-- Scratch pads.
, ("M-; M-c", namedScratchpadAction scratchPads "calc")
, ("M-; M-p", namedScratchpadAction scratchPads "pass")
, ("M-; M-t", namedScratchpadAction scratchPads "todoist")
-- FIXME: , ("M-; M-;", closeAllNamedScratchpads scratchPads)
appKeys c =
[ ("M-<Return>", spawn (terminal c))
, ("M-e", spawn "e -c") -- Start per-workspace Emacs.
, ("M-<Esc>", shellPrompt Local.promptConfig)
]

--------------------------------------------------------------------------------
-- Keys for controlling music and volume.
musicKeys :: XConfig Layout -> [(String, X ())]
musicKeys _ =
[ ("M-S-1", playPause)
, ("M-S-2", prevTrack)
, ("M-S-3", nextTrack)
, ("M-S-4", radioPrompt Local.promptConfig)
, ("M-S-5", clearPlaylist)
, ("M-S-6", audioMute)
, ("M-S-7", audioLower)
, ("M-S-8", audioRaise)

-- Keys for my laptop and keyboards with media keys.
, ("M-<XF86AudioMute>", playPause)
, ("M-<XF86AudioLowerVolume>", prevTrack)
, ("M-<XF86AudioRaiseVolume>", nextTrack)
, ("<XF86AudioPlay>", playPause)
, ("<XF86AudioPrev>", prevTrack)
, ("<XF86AudioNext>", nextTrack)
, ("<XF86AudioMute>", audioMute)
, ("<XF86AudioLowerVolume>", audioLower)
, ("<XF86AudioRaiseVolume>", audioRaise)
[ ("M-r", radioPrompt Local.promptConfig)
]
where
playPause = spawn "mpc-pause"
nextTrack = spawn "mpc next"
prevTrack = spawn "mpc prev"
clearPlaylist = spawn "mpc clear"
audioMute = spawn "amixer set Master toggle"
audioLower = spawn "amixer set Master 5%-"
audioRaise = spawn "amixer set Master 5%+"

--------------------------------------------------------------------------------
sendResize :: GPResize -> X ()
sendResize movement = do
winset <- gets windowset
let lname = description . W.layout . W.workspace . W.current $ winset
ltype = case lname of
"BSP" -> BSP
"Focus" -> BSP
_ -> Other

case (ltype, movement) of
(BSP, GPExpandL) -> sendMessage (ExpandTowards L)
(BSP, GPExpandR) -> sendMessage (ExpandTowards R)
(BSP, GPExpandU) -> sendMessage (ExpandTowards U)
(BSP, GPExpandD) -> sendMessage (ExpandTowards D)
(BSP, GPShrinkL) -> sendMessage (ShrinkFrom L)
(BSP, GPShrinkR) -> sendMessage (ShrinkFrom R)
(BSP, GPShrinkU) -> sendMessage (ShrinkFrom U)
(BSP, GPShrinkD) -> sendMessage (ShrinkFrom D)
(Other, GPExpandL) -> sendMessage Shrink
(Other, GPExpandR) -> sendMessage Expand
(Other, GPExpandU) -> sendMessage MirrorShrink
(Other, GPExpandD) -> sendMessage MirrorExpand
(Other, GPShrinkL) -> sendMessage Expand
(Other, GPShrinkR) -> sendMessage Shrink
(Other, GPShrinkU) -> sendMessage MirrorExpand
(Other, GPShrinkD) -> sendMessage MirrorShrink

--------------------------------------------------------------------------------
-- | Restart XMonad but instead of starting the XMonad in @PATH@,
@@ -320,22 +225,7 @@ sendResize movement = do
restartIntoDebugging :: X ()
restartIntoDebugging = do
home <- io getHomeDirectory

-- Path to my xmonad (as generated by `cabal new-build'):
let path = foldl (\x y -> x ++ "/" ++ y) home
[ "develop/rc/xmonadrc/dist-newstyle/build"
, "xmonadrc-" ++ showVersion version
, "build/xmonadrc/xmonadrc"
]

exists <- io (doesFileExist path)

if exists
then restart path True
else do io (putStrLn ("bad path: " ++ path))
confirmPrompt promptConfig
"xmonad.errors for bad path"
(return ())
restart (home </> "src/rc/xmonadrc/dist/build/xmonadrc/xmonadrc") True

--------------------------------------------------------------------------------
windowPromptGoto :: X ()

+ 49
- 41
src/XMonad/Local/Layout.hs View File

@@ -15,16 +15,18 @@ module XMonad.Local.Layout (layoutHook, selectLayoutByName) where
--------------------------------------------------------------------------------
import XMonad hiding ((|||), layoutHook, float)
import XMonad.Layout.Accordion (Accordion(..))
import XMonad.Layout.BinarySpacePartition (emptyBSP)
import XMonad.Layout.ComboP (Property(..), combineTwoP)
import XMonad.Layout.Gaps (Gaps, gaps)
import XMonad.Layout.ComboP (PartitionWins(..), Property(..), combineTwoP)
import XMonad.Layout.Gaps (gaps)
import XMonad.Layout.GridVariants (SplitGrid(..))
import qualified XMonad.Layout.GridVariants as Grid
import XMonad.Layout.IfMax (ifMax)
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.LayoutModifier
import XMonad.Layout.Master (mastered)
import XMonad.Layout.NoBorders (noBorders)
import XMonad.Layout.Reflect (reflectHoriz, reflectVert)
import XMonad.Layout.Reflect (reflectVert)
import XMonad.Layout.Renamed (Rename(..), renamed)
import XMonad.Layout.ResizableTile (ResizableTall(..))
import XMonad.Layout.Spacing (Border(..), spacingRaw)
import XMonad.Layout.ThreeColumns (ThreeCol(..))
import XMonad.Layout.ToggleLayouts (toggleLayouts)
import XMonad.Layout.TwoPane (TwoPane(..))
@@ -40,41 +42,43 @@ layoutHook =
(noBorders fullscreen)
allLays
where
-- addSpace = renamed [CutWordsLeft 2] . spacingRaw 4

fullscreen :: ModifiedLayout Rename (ModifiedLayout Gaps Full) Window
fullscreen = renamed [Replace "Full"] (gaps (uniformGaps 60) Full)
uniformGaps n = [(U, n), (D, n), (L, n), (R, n)] :: [(Direction2D,Int)]
uniformBorder n = Border n n n n
spacing = spacingRaw False (uniformBorder 10) True (uniformBorder 10) True

fullscreen = gaps (uniformGaps 60) Full
threeCols = spacing $ ThreeColMid 1 (1/20) (1/2)
twoCols = spacing $ mastered (1/100) (1/2) Accordion
twoPane = spacing $ TwoPane (3/100) (1/2)
tall = spacing $ ResizableTall 1 (1.5/100) (3/5) []
focusTag = spacing $ only (Tagged "focus")
grid = spacing $ SplitGrid Grid.L 2 2 (2/3) (1/2) 1

-- One window, centered on the screen.
centFull = spacingRaw False (Border 20 20 200 200)
True (Border 0 0 0 0) False Full

threeCols = renamed [Replace "3C"] (ThreeColMid 1 (1/20) (1/2))
twoCols = renamed [Replace "2C"] (mastered (1/100) (1/2) Accordion)
twoPane = renamed [Replace "2P"] (TwoPane (3/100) (1/2))
bspace = renamed [Replace "BSP"] emptyBSP
tall = renamed [Replace "Tall"] (ResizableTall 1 (1.5/100) (3/5) [])
-- Automatically adapt to the number of open windows:
autoL = ifMax 1 centFull $
ifMax 2 twoPane threeCols

-- A layout where windows you want to focus on are specified using
-- @WindowProperties@. Windows matching the given properties will
-- be placed into the main layout. Other windows are pushed to
-- the top of the screen in a small @Accordion@.
only = combineTwoP (reflectVert $ Mirror $ TwoPane 0 (9/10))
bspace (Mirror Accordion)

focusTag = renamed [Replace "Focus"] $ only (Tagged "focus")

-- When I'm teaching a class I start with a weird layout before
-- focusing on specific windows using another layout.
projector = renamed [Replace "Projector"] topHalf where
topHalf = combineTwoP (Mirror twoPane) bspace bottomHalf (ClassName "Emacs")
bottomHalf = combineTwoP (reflectHoriz twoPane) Full Full (ClassName ".zathura-wrapped_")
twoCols (Mirror Accordion)

-- All layouts put together.
allLays = bspace |||
focusTag |||
projector |||
tall |||
threeCols |||
twoCols |||
twoPane
allLays =
renamed [Replace "Auto"] autoL |||
renamed [Replace "Tall"] tall |||
renamed [Replace "3C"] threeCols |||
renamed [Replace "2C"] twoCols |||
renamed [Replace "2P"] twoPane |||
renamed [Replace "Focus"] focusTag |||
renamed [Replace "Grid"] grid |||
renamed [Replace "Full"] fullscreen

--------------------------------------------------------------------------------
-- | A data type for the @XPrompt@ class.
@@ -91,16 +95,20 @@ selectLayoutByName conf =

where
go :: String -> X ()
go selected = case lookup selected layoutNames of
Just name -> sendMessage (JumpToLayout name)
Nothing -> return ()
go selected =
case lookup selected layoutNames of
Nothing -> return ()
Just name -> do sendMessage (JumpToLayout name)
sendMessage PartitionWins

layoutNames :: [(String, String)]
layoutNames = [ ("Tall", "Tall")
, ("Binary Space Partition (BSP)", "BSP")
, ("Two Columns (2C)", "2C")
, ("Two Pane (2P)", "2P")
, ("Three Columns (3C)", "3C")
, ("Projector", "Projector")
, ("Focus", "Focus")
]
layoutNames =
[ ("Auto", "Auto")
, ("Tall", "Tall")
, ("Three Columns (3C)", "3C")
, ("Two Columns (2C)", "2C")
, ("Two Pane (2P)", "2P")
, ("Full", "Full")
, ("Focus", "Focus")
, ("Grid", "Grid")
]

+ 3
- 3
src/XMonad/Local/Theme.hs View File

@@ -23,9 +23,9 @@ import XMonad.Layout.Decoration

--------------------------------------------------------------------------------
xmonadColors :: XConfig a -> XConfig a
xmonadColors x = x { normalBorderColor = darkgray
, focusedBorderColor = blue
, borderWidth = 1
xmonadColors x = x { normalBorderColor = "#444444"
, focusedBorderColor = "#ff52bb"
, borderWidth = 5
}

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

+ 10
- 82
src/XMonad/Local/Workspaces.hs View File

@@ -11,7 +11,6 @@ the LICENSE file. -}
module XMonad.Local.Workspaces
( projects
, names
, scratchPads
, asKey
, viewPrevWS
) where
@@ -20,9 +19,7 @@ module XMonad.Local.Workspaces
import Control.Monad (unless)
import XMonad
import XMonad.Actions.DynamicProjects
import XMonad.Layout.LayoutCombinators (JumpToLayout(..))
import qualified XMonad.StackSet as StackSet
import XMonad.Util.NamedScratchpad

--------------------------------------------------------------------------------
projects :: [Project]
@@ -31,110 +28,41 @@ projects =
, projectDirectory = "~/"
, projectStartHook = Just $ do
spawn "e -c"
spawn "urxvtc"
}

, Project { projectName = "clocks"
, projectDirectory = "~/"
, projectStartHook = Just $ do
sendMessage (JumpToLayout "BSP")
spawn "urxvtc -e ncmpcpp"
spawn "urxvtc -name BigTerm -e env TZ=America/New_York tty-clock -C 0 -c -f 'South Carolina'"
spawn "urxvtc -name BigTerm -e tty-clock -c -C 4 -f '%b. %d, %Y'"
spawn "konsole"
spawn "konsole"
}

, Project { projectName = "browsers"
, projectDirectory = "~/download"
, projectStartHook = Just $ do
sendMessage (JumpToLayout "BSP")
spawn "chromium"
spawn "chromium"
, projectStartHook = Just $ spawn "firefox"
}

, Project { projectName = "mail"
, projectDirectory = "~/"
, projectStartHook = Just $ do
sendMessage (JumpToLayout "3C")
spawn "e -cs irc -- -F '((name . \"irc\"))'"
spawn "e -cs gnus"
}

, Project { projectName = "emacs"
, projectDirectory = "~/core/emacs"
, projectStartHook = Nothing
}

, Project { projectName = "rip"
, projectDirectory = "~/documents/ripping"
, projectStartHook = Nothing
, projectStartHook = Just $ spawn "e -cs mail"
}

, Project { projectName = "xmonad"
, projectDirectory = "~/core/xmonadrc"
, Project { projectName = "rc"
, projectDirectory = "~/src/rc"
, projectStartHook = Nothing
}

, Project { projectName = "rfa"
, projectDirectory = "~/develop/rfa"
, projectDirectory = "~/src/rfa"
, projectStartHook = Nothing
}

-- Classes I teach:
, Project { projectName = "training"
, projectDirectory = "~/training/courses"
, Project { projectName = "mint"
, projectDirectory = "~/src/mint"
, projectStartHook = Nothing
}

, Project { projectName = "advjs"
, projectDirectory = "~/training/courses/src/javascript/advjs"
, projectStartHook = Just workshopHook
}

, Project { projectName = "corejs"
, projectDirectory = "~/training/courses/src/javascript/corejs"
, projectStartHook = Just workshopHook
}

, Project { projectName = "intcss"
, projectDirectory = "~/training/courses/src/css/intcss"
, projectStartHook = Just workshopHook
}
]
where
workshopHook = do
sendMessage (JumpToLayout "Projector")
spawn "e -c"
spawn "urxvtc -name BigTerm -e clockdown"
spawn "zathura"



--------------------------------------------------------------------------------
-- | Names of my workspaces.
names :: [WorkspaceId]
names = ["scratch", "tasks", "clocks", "browsers", "mail"]

--------------------------------------------------------------------------------
scratchPads :: NamedScratchpads
scratchPads =
[ NS { name = "calc"
, cmd = "e -c -s calc -e '(full-calc)' -- -F '((name . \"calculator\"))'"
, query = appName =? "calculator"
, hook = floatOnRight
}
, NS { name = "pass"
, cmd = "e -c -s pass -e '(passmm-list-passwords)' -- -F '((name . \"passwords\"))'"
, query = appName =? "passwords"
, hook = floatOnRight
}
, NS { name = "todoist"
, cmd = "chromium --app=https://todoist.com/app"
, query = appName =? "todoist.com__app"
, hook = floatOnRight
}
]
where
floatOnRight = customFloating $ StackSet.RationalRect (2/3) 0 (1/3) 0.98
names = ["scratch", "browsers", "agenda", "music", "mail", "chat"]

--------------------------------------------------------------------------------
-- | Helper function to translate workspace names into key names for

+ 3
- 5
xmonadrc.hs View File

@@ -18,7 +18,6 @@ import XMonad.Actions.Navigation2D
import XMonad.Config.Desktop (desktopConfig)
import XMonad.Hooks.ManageDocks (avoidStruts)
import XMonad.Hooks.UrgencyHook hiding (urgencyConfig)
import XMonad.Util.NamedScratchpad (namedScratchpadManageHook)

--------------------------------------------------------------------------------
import qualified XMonad.Local.Action as Local
@@ -33,12 +32,11 @@ import qualified XMonad.Local.Workspaces as Workspaces
--
-- config :: XConfig a
config = desktopConfig
{ terminal = "urxvtc"
{ terminal = "konsole"
, layoutHook = avoidStruts Local.layoutHook

, manageHook = manageHook desktopConfig <>
Local.manageHook <>
namedScratchpadManageHook Workspaces.scratchPads
Local.manageHook

, handleEventHook = handleEventHook desktopConfig <>
Local.handleEventHook
@@ -56,7 +54,7 @@ config = desktopConfig
-- | Configuration for 'XMonad.Actions.Navigation2D'.
navConf :: Navigation2DConfig
navConf = def
{ defaultTiledNavigation = centerNavigation
{ defaultTiledNavigation = hybridOf sideNavigation centerNavigation
}

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

Loading…
Cancel
Save