ENH make workspace list reflect physical location

This commit is contained in:
Nathan Dwarshuis 2020-02-14 22:52:27 -05:00
parent 6895b2ddac
commit 9b42ce5d28
1 changed files with 25 additions and 11 deletions

View File

@ -9,11 +9,14 @@ module Main (main) where
import System.Exit import System.Exit
import System.IO import System.IO
-- import Graphics.XOSD import Data.List (sortBy)
import Data.Maybe (isJust)
import Data.Ord (comparing)
import XMonad import XMonad
import XMonad.Actions.CopyWindow import XMonad.Actions.CopyWindow
import XMonad.Actions.CycleWS import XMonad.Actions.CycleWS
import XMonad.Actions.PhysicalScreens
import XMonad.Actions.Volume import XMonad.Actions.Volume
-- import XMonad.Config.Desktop -- import XMonad.Config.Desktop
import XMonad.Hooks.DynamicLog import XMonad.Hooks.DynamicLog
@ -32,7 +35,6 @@ import XMonad.Prompt.ConfirmPrompt
import XMonad.Util.EZConfig import XMonad.Util.EZConfig
import XMonad.Util.NamedActions import XMonad.Util.NamedActions
import XMonad.Util.Run import XMonad.Util.Run
import XMonad.Util.WorkspaceCompare
import qualified XMonad.StackSet as W import qualified XMonad.StackSet as W
@ -76,15 +78,27 @@ myWorkspaces = map show [1..10 :: Int] ++ ["VM"]
myLayouts = onWorkspace "VM" (lessBorders OnlyScreenFloat Full) $ myLayouts = onWorkspace "VM" (lessBorders OnlyScreenFloat Full) $
(avoidStruts $ layoutHook def) (avoidStruts $ layoutHook def)
-- TODO hack dynamicLogXinerama and sort the screen by its xrandr -- | Format workspace and layout in loghook
-- position (Graphics.X11.Xrandr?) -- The format will be like "[<1> 2 3] 4 5 | LAYOUT" where each digit
myLoghook h = dynamicLogWithPP $ -- is the workspace and LAYOUT is the current layout. Each workspace
def { ppOutput = hPutStrLn h -- in the brackets is currently visible and the order reflects the
, ppCurrent = wrap "<" ">" -- physical location of each screen. The "<>" is the workspace
, ppVisible = wrap "[" "]" -- that currently has focus
, ppTitle = const "" myLoghook h = withWindowSet $ io . hPutStrLn h . myWindowSetXinerama
, ppSep = " | "
, ppSort = getSortByXineramaRule } myWindowSetXinerama ws = "[" ++ unwords onscreen ++ "] " ++
unwords offscreen ++ " | " ++ layout
where
onscreen = map (fmtTags . W.tag . W.workspace)
. sortBy compareXCoord $ W.current ws : W.visible ws
fmtTags t = if t == W.currentTag ws then wrap "<" ">" t else t
offscreen = map W.tag . filter (isJust . W.stack)
. sortBy (comparing W.tag) $ W.hidden ws
layout = description . W.layout . W.workspace . W.current $ ws
compareXCoord s0 s1 = compare x0 x1
where
(_, (Rectangle x0 _ _ _)) = getScreenIdAndRectangle s0
(_, (Rectangle x1 _ _ _)) = getScreenIdAndRectangle s1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Customize the way 'XMonad.Prompt' looks and behaves. It's a -- | Customize the way 'XMonad.Prompt' looks and behaves. It's a