mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-09 00:11:52 -07:00
documentation for marshallPP
This commit is contained in:
@@ -19,8 +19,10 @@ module XMonad.Layout.IndependentScreens (
|
|||||||
VirtualWorkspace, PhysicalWorkspace,
|
VirtualWorkspace, PhysicalWorkspace,
|
||||||
workspaces',
|
workspaces',
|
||||||
withScreens, onCurrentScreen,
|
withScreens, onCurrentScreen,
|
||||||
countScreens,
|
|
||||||
marshallPP,
|
marshallPP,
|
||||||
|
countScreens,
|
||||||
|
-- * Converting between virtual and physical workspaces
|
||||||
|
-- $converting
|
||||||
marshall, unmarshall, unmarshallS, unmarshallW,
|
marshall, unmarshall, unmarshallS, unmarshallW,
|
||||||
marshallWindowSpace, unmarshallWindowSpace
|
marshallWindowSpace, unmarshallWindowSpace
|
||||||
) where
|
) where
|
||||||
@@ -69,6 +71,14 @@ import XMonad.Hooks.DynamicLog
|
|||||||
type VirtualWorkspace = WorkspaceId
|
type VirtualWorkspace = WorkspaceId
|
||||||
type PhysicalWorkspace = WorkspaceId
|
type PhysicalWorkspace = WorkspaceId
|
||||||
|
|
||||||
|
-- $converting
|
||||||
|
-- You shouldn't need to use the functions below very much. They are used
|
||||||
|
-- internally. However, in some cases, they may be useful, and so are exported
|
||||||
|
-- just in case. In general, the \"marshall\" functions convert the convenient
|
||||||
|
-- form (like \"web\") you would like to use in your configuration file to the
|
||||||
|
-- inconvenient form (like \"2_web\") that xmonad uses internally. Similarly,
|
||||||
|
-- the \"unmarshall\" functions convert in the other direction.
|
||||||
|
|
||||||
marshall :: ScreenId -> VirtualWorkspace -> PhysicalWorkspace
|
marshall :: ScreenId -> VirtualWorkspace -> PhysicalWorkspace
|
||||||
marshall (S sc) vws = show sc ++ '_':vws
|
marshall (S sc) vws = show sc ++ '_':vws
|
||||||
|
|
||||||
@@ -76,12 +86,6 @@ unmarshall :: PhysicalWorkspace -> (ScreenId, VirtualWorkspace)
|
|||||||
unmarshallS :: PhysicalWorkspace -> ScreenId
|
unmarshallS :: PhysicalWorkspace -> ScreenId
|
||||||
unmarshallW :: PhysicalWorkspace -> VirtualWorkspace
|
unmarshallW :: PhysicalWorkspace -> VirtualWorkspace
|
||||||
|
|
||||||
-- ^ You shouldn't need to use @marshall@ or the various @unmarshall@ functions
|
|
||||||
-- very much. They simply convert between the physical and virtual worlds.
|
|
||||||
-- For example, you might want to use them as part of a status bar
|
|
||||||
-- configuration. The function @unmarshallW@ would discard the screen
|
|
||||||
-- information from an otherwise unsightly workspace name.
|
|
||||||
|
|
||||||
unmarshall = ((S . read) *** drop 1) . break (=='_')
|
unmarshall = ((S . read) *** drop 1) . break (=='_')
|
||||||
unmarshallS = fst . unmarshall
|
unmarshallS = fst . unmarshall
|
||||||
unmarshallW = snd . unmarshall
|
unmarshallW = snd . unmarshall
|
||||||
@@ -110,10 +114,17 @@ onCurrentScreen f vws = screen . current >>= f . flip marshall vws
|
|||||||
countScreens :: (MonadIO m, Integral i) => m i
|
countScreens :: (MonadIO m, Integral i) => m i
|
||||||
countScreens = liftM genericLength . liftIO $ openDisplay "" >>= getScreenInfo
|
countScreens = liftM genericLength . liftIO $ openDisplay "" >>= getScreenInfo
|
||||||
|
|
||||||
-- TODO: documentation from here down
|
-- | This turns a naive pretty-printer into one that is aware of the
|
||||||
-- TODO: note somewhere that "marshall" functions go from convenient
|
-- independent screens. That is, you can write your pretty printer to behave
|
||||||
-- to inconvenient, and "unmarshall" functions go from
|
-- the way you want on virtual workspaces; this function will convert that
|
||||||
-- inconvenient to convenient
|
-- pretty-printer into one that first filters out physical workspaces on other
|
||||||
|
-- screens, then converts all the physical workspaces on this screen to their
|
||||||
|
-- virtual names.
|
||||||
|
--
|
||||||
|
-- For example, if you have handles @hLeft@ and @hRight@ for bars on the left and right screens, respectively, and @pp@ is a pretty-printer function that takes a handle, you could write
|
||||||
|
--
|
||||||
|
-- > logHook = let log screen handle = dynamicLogWithPP . marshallPP screen . pp $ handle
|
||||||
|
-- > in log 0 hLeft >> log 1 hRight
|
||||||
marshallPP :: ScreenId -> PP -> PP
|
marshallPP :: ScreenId -> PP -> PP
|
||||||
marshallPP s pp = pp {
|
marshallPP s pp = pp {
|
||||||
ppCurrent = ppCurrent pp . snd . unmarshall,
|
ppCurrent = ppCurrent pp . snd . unmarshall,
|
||||||
@@ -130,7 +141,9 @@ marshallSort s vSort = pScreens . vSort . vScreens where
|
|||||||
vScreens = map unmarshallWindowSpace . filter onScreen
|
vScreens = map unmarshallWindowSpace . filter onScreen
|
||||||
pScreens = map (marshallWindowSpace s)
|
pScreens = map (marshallWindowSpace s)
|
||||||
|
|
||||||
|
-- | Convert the tag of the 'WindowSpace' from a 'VirtualWorkspace' to a 'PhysicalWorkspace'.
|
||||||
marshallWindowSpace :: ScreenId -> WindowSpace -> WindowSpace
|
marshallWindowSpace :: ScreenId -> WindowSpace -> WindowSpace
|
||||||
|
-- | Convert the tag of the 'WindowSpace' from a 'PhysicalWorkspace' to a 'VirtualWorkspace'.
|
||||||
unmarshallWindowSpace :: WindowSpace -> WindowSpace
|
unmarshallWindowSpace :: WindowSpace -> WindowSpace
|
||||||
|
|
||||||
marshallWindowSpace s ws = ws { tag = marshall s (tag ws) }
|
marshallWindowSpace s ws = ws { tag = marshall s (tag ws) }
|
||||||
|
Reference in New Issue
Block a user