blob: e126dcc59e2ce25378b72628f484961d6c0ff7b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
-- | What the pager needs from a window manager.
module Pager.Backend
( Backend(..)
, getBackend
) where
import Data.Text (Text)
import Pager.Types
import qualified Pager.Backend.Rivermonad
import qualified Pager.Backend.X11
import qualified Rivermonad.Client
data Backend = Backend
{ getScreenGeometry :: IO Geometry
, getWorkspaces :: Geometry -> [Int] -> IO [Workspace]
-- ^ Screen geometry and the focused window of every workspace, as
-- given on the command line.
, viewWorkspace :: Text -> IO ()
, shiftWindowToWorkspace :: Int -> Text -> IO ()
}
-- | rivermonad if its socket is there, EWMH on X11 otherwise. See
-- 'Rivermonad.Client.selected'.
getBackend :: IO Backend
getBackend = do
rivermonad <- Rivermonad.Client.selected
return $
if rivermonad then
Backend
{ getScreenGeometry = Pager.Backend.Rivermonad.getScreenGeometry
, getWorkspaces = Pager.Backend.Rivermonad.getWorkspaces
, viewWorkspace = Pager.Backend.Rivermonad.viewWorkspace
, shiftWindowToWorkspace = Pager.Backend.Rivermonad.shiftWindowToWorkspace
}
else
Backend
{ getScreenGeometry = Pager.Backend.X11.getScreenGeometry
, getWorkspaces = Pager.Backend.X11.getWorkspaces
, viewWorkspace = Pager.Backend.X11.viewWorkspace
, shiftWindowToWorkspace = Pager.Backend.X11.shiftWindowToWorkspace
}
|