diff options
Diffstat (limited to 'src/Rahm/Desktop')
| -rw-r--r-- | src/Rahm/Desktop/Desktop.hs | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/src/Rahm/Desktop/Desktop.hs b/src/Rahm/Desktop/Desktop.hs deleted file mode 100644 index 04895c7..0000000 --- a/src/Rahm/Desktop/Desktop.hs +++ /dev/null @@ -1,76 +0,0 @@ -module Rahm.Desktop.Desktop where - --- A "Desktop" is a mapping from screen -> workspace. This is used to save the --- state of the current screen -> workspace and thus restore it. - --- import XMonad.Operations - -import Control.Monad (forM_) -import Data.Default (Default (..)) -import Data.Map (Map) -import qualified Data.Map as Map (fromList, insert, lookup) -import Data.Maybe (fromMaybe) -import XMonad (X (..)) -import qualified XMonad as X - ( ExtensionClass (..), - ScreenId, - StateExtension (PersistentExtension), - WorkspaceId, - windows, - withWindowSet, - ) -import qualified XMonad.StackSet as W - ( Screen (Screen, screen, workspace), - StackSet (StackSet), - Workspace (tag), - screens, - workspaces, - ) -import qualified XMonad.Util.ExtensibleState as XS (get, modify) - -newtype Desktop si wi = Desktop (Map si wi) - deriving (Read, Show) - -newtype Desktops = Desktops - { theaters :: Map String (Desktop X.ScreenId X.WorkspaceId) - } - deriving (Read, Show) - -instance Default Desktops where - def = Desktops mempty - -instance X.ExtensionClass Desktops where - initialValue = def - extensionType = X.PersistentExtension - -saveCurrentDesktop :: String -> X () -saveCurrentDesktop name = - X.withWindowSet $ \windowSet -> - XS.modify $ \(Desktops m) -> - Desktops $ - flip (Map.insert name) m $ - Desktop $ - Map.fromList $ - map (\(W.Screen ws sid _) -> (sid, W.tag ws)) $ W.screens windowSet - -restoreDesktop :: String -> X () -restoreDesktop name = do - (Desktops theaters) <- XS.get - forM_ (Map.lookup name theaters) $ \(Desktop screenToWorkspace) -> - X.windows $ \ws@(W.StackSet cur vis hidden float) -> - let workspacesById = Map.fromList $ map (\ws -> (W.tag ws, ws)) (W.workspaces ws) - - newScreenWorkspace scr = - fromMaybe scr $ do - wid <- Map.lookup (W.screen scr) screenToWorkspace - workspace <- Map.lookup wid workspacesById - return $ scr {W.workspace = workspace} - - newScreens = map newScreenWorkspace (cur : vis) - newVisibleWorkspaces = map (W.tag . W.workspace) newScreens - newHiddenWorkspaces = - filter (\ws -> not (W.tag ws `elem` newVisibleWorkspaces)) $ - W.workspaces ws - - (newCur : newVisible) = newScreens - in W.StackSet newCur newVisible newHiddenWorkspaces float |