http://linuxforum.ru/index.php?showtopic=83484&view=findpost&p=891010

  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
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses, TypeSynonymInstances, FlexibleContexts, NoMonomorphismRestriction #-}
import XMonad hiding ( (|||) )
import XMonad.Config.Kde
import qualified XMonad.StackSet as W -- to shift and float windows
import XMonad.Util.EZConfig
import XMonad.Actions.CycleWS
import XMonad.Actions.CycleRecentWS
import qualified XMonad.Actions.FlexibleManipulate as Flex
import XMonad.Actions.SpawnOn
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.FadeInactive
import XMonad.Layout.Combo
import XMonad.Layout.Grid
import XMonad.Layout.LayoutModifier
import XMonad.Layout.Named
import XMonad.Layout.NoBorders
import XMonad.Layout.PerWorkspace
import XMonad.Layout.Reflect
import XMonad.Layout.TwoPane
import XMonad.Layout.WindowNavigation
import XMonad.Layout.LayoutCombinators
import XMonad.Layout.IM
import XMonad.Layout.ThreeColumns
import XMonad.Util.WindowProperties
import XMonad.Util.Run
import Control.Monad
import Data.Ratio
import qualified Data.Map as M
-- подключаем библиотеки X11
import Graphics.X11.Xlib.Extras
import Graphics.X11.ExtraTypes.XF86
import Foreign.C.Types (CLong)
import XMonad.Prompt.Ssh
import XMonad.Prompt.Window
import XMonad.Prompt.Workspace
import XMonad.Prompt.XMonad
myBaseConfig = kdeConfig
-- Взять значение свойства окна
getProp :: Atom -> Window -> X (Maybe [CLong])
getProp a w = withDisplay $ \dpy -> io $ getWindowProperty32 dpy a w
-- Эта функция проверяет, выставлено ли свойство окна name в значение value
checkAtom name value = ask >>= \w -> liftX $ do
a <- getAtom name
val <- getAtom value
mbr <- getProp a w
case mbr of
Just [r] -> return $ elem (fromIntegral r) [val]
_ -> return False
-- Эта функция проверяет, является ли окно диалогом
checkDialog = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_DIALOG"
-- Отрывающиеся (tear-off) меню
checkMenu = checkAtom "_NET_WM_WINDOW_TYPE" "_NET_WM_WINDOW_TYPE_MENU"
myBorderWidth = 0
basicLayout = Mirror tiled where
tiled = Tall nmaster delta ratio
nmaster = 1
delta = 2/100
ratio = 2/5
wideLayout = Mirror basicLayout
basicALayout = avoidStruts $ basicLayout
imLayout = avoidStruts $ reflectHoriz $ withIMs ratio rosters chatLayout where
chatLayout = Mirror Grid
ratio = 1%5
rosters = [skypeRoster, kopeteRoster]
kopeteRoster = (ClassName "Kopete") `And` (Title "Kopete")
skypeRoster = (ClassName "Skype") `And` (Not (Title "Options")) `And` (Not (Role "Chats")) `And` (Not (Role "CallWindowForm"))
manageMenus = checkMenu --> doFloat
manageDialogs = checkDialog --> doFloat
myLayoutHook = fullscreen $ im $ normal where
normal = basicLayout ||| basicALayout ||| wideLayout ||| Full
fullscreen = onWorkspace "4, 5, 9" Full
im = onWorkspace "3" imLayout
myManageHook = imManageHooks <+> manageMenus <+> manageDialogs <+> manageHook myBaseConfig
imManageHooks = composeAll
[ className =? "Gran Paradiso" --> moveTo "2"
, title =? "Gran Paradiso Preferences" --> doFloat
, className =? "Kmix" --> doFloat
, className =? "Gimp" --> doFloat
, className =? "Skype" --> moveTo "3"
, className =? "Kopete" --> moveTo "3"
, className =? "Amarok" --> moveTo "4"
, title =? "SMPlayer" --> moveTo "5"
, className =? "Quassel" --> moveTo "6"
, className =? "wine" --> moveTo "7"
, className =? "Qt-subapplication" --> doIgnore
, className =? "Plasma" --> doIgnore
{- , title =? " NX" --> moveTo "9"
, title =? "NX - evv@Home-Server:1041 - evv" --> moveTo "9"
, title =? "NX - evv@Home-Server:1042 - evv" --> moveTo "9"
, title =? "NX - evv@Home-Server:1043 - evv" --> moveTo "9"
, title =? "NX - evv@Home-Server:1044 - evv" --> moveTo "9"
, title =? "NX - evv@Home-Server:1045 - evv" --> moveTo "9"
, title =? "NX - evv@Home-Server:1046 - evv" --> moveTo "9"
, title =? "NX - evv@Home-Server:1047 - evv" --> moveTo "9"
, title =? "NX - evv@Home-Server:1048 - evv" --> moveTo "9"
, title =? "NX - evv@Home-Server:1049 - evv" --> moveTo "9"-}
]
where
moveTo = doF . W.shift
--role = stringProperty "WM_WINDOW_ROLE"
myLogHook :: X ()
myLogHook = fadeInactiveLogHook fadeAmount
where fadeAmount = 0x66666666
myModMask = mod4Mask
main = xmonad $ myBaseConfig
{ modMask = myModMask
, layoutHook = myLayoutHook
, manageHook = myManageHook
, borderWidth = myBorderWidth
, logHook = myLogHook
, terminal = "urxvt"
}
`additionalKeysP`
[ ("M1-<F4>", kill),
("xF86XK_Launch9", prevWS),
--("xF86XK_Mail", mpcAct "next"),
("xF86XK_Favorites", shiftToNext),
("xF86XK_Launch6", spawn "urxvt -e ssh evv@192.168.0.1"),
("xF86XK_Launch7", spawn "urxvt -e ssh -p 43434 evv@90.189.142.25")
]
-- | Data type for LayoutModifier which converts given layout to IM-layout
-- (with dedicated space for the roster and original layout for chat windows)
data AddRosters a = AddRosters Rational [Property] deriving (Read, Show)
instance LayoutModifier AddRosters Window where
modifyLayout (AddRosters ratio props) = applyIMs ratio props
modifierDescription _ = "IMs"
-- | Modifier which converts given layout to IMs-layout (with dedicated
-- space for rosters and original layout for chat windows)
withIMs :: LayoutClass l a => Rational -> [Property] -> l a -> ModifiedLayout AddRosters l a
withIMs ratio props = ModifiedLayout $ AddRosters ratio props
-- | IM layout modifier applied to the Grid layout
gridIMs :: Rational -> [Property] -> ModifiedLayout AddRosters Grid a
gridIMs ratio props = withIMs ratio props Grid
hasAnyProperty :: [Property] -> Window -> X Bool
hasAnyProperty [] _ = return False
hasAnyProperty (p:ps) w = do
b <- hasProperty p w
if b then return True else hasAnyProperty ps w
-- | Internal function for placing the rosters specified by
-- the properties and running original layout for all chat windows
applyIMs :: (LayoutClass l Window) =>
Rational
-> [Property]
-> W.Workspace WorkspaceId (l Window) Window
-> Rectangle
-> X ([(Window, Rectangle)], Maybe (l Window))
applyIMs ratio props wksp rect = do
let stack = W.stack wksp
let ws = W.integrate' $ stack
rosters <- filterM (hasAnyProperty props) ws
let n = fromIntegral $ length rosters
let (rostersRect, chatsRect) = splitHorizontallyBy (n * ratio) rect
let rosterRects = splitHorizontally n rostersRect
let filteredStack = stack >>= W.filter (`notElem` rosters)
wrs <- runLayout (wksp {W.stack = filteredStack}) chatsRect
return ((zip rosters rosterRects) ++ fst wrs, snd wrs)