rendered paste body-- import Control.OldException(catchDyn,try)
import Control.OldException(catchDyn)
import XMonad
import System.Exit
import XMonad.Config.Gnome
import XMonad.Layout.Circle
import XMonad.Layout.NoBorders
import XMonad.Layout.ShowWName
import XMonad.Layout.IM
import XMonad.Layout.PerWorkspace
import XMonad.Util.Run
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
-- import XMonad.Hooks.UrgencyHook
import DBus
import DBus.Connection
import DBus.Message
-- import Control.Concurrent
-- import System.Cmd
import qualified XMonad.StackSet as W
import qualified Data.Map as M
main = withConnection Session $ \ dbus -> do
getWellKnownName dbus
-- spawn "feh --bg-scale ~/desktop.png"
-- spawn "pidof xcompmgr || xcompmgr -cCf -r 0 -D 2 > /dev/null"
-- xmobar <- spawnPipe "xmobar ~/.xmonad/xmobar"
xmonad $ gnomeConfig{
terminal ="urxvt"
,focusFollowsMouse = False
,borderWidth = 1
,modMask = mod4Mask
,workspaces = ["dp1","dp2","dp3","ww","im","dp6","dp7","dp8","dp9"]
,normalBorderColor = "#202020"
,focusedBorderColor = "#e67817"
,keys = myKeys
,mouseBindings = myMouseBindings
,layoutHook = showWName' mySWNConfig myLayout
,manageHook = myManageHook <+> manageDocks
,logHook = dynamicLogWithPP (myPrettyPrinter dbus)
,startupHook = spawn "pidof xcompmgr || xcompmgr -cCf -r 0 -D 2 > /dev/null"}
myPrettyPrinter :: Connection -> PP
myPrettyPrinter dbus = defaultPP {
ppOutput = outputThroughDBus dbus
, ppTitle = pangoColor "#e67817" . shorten 50 . pangoSanitize
, ppCurrent = pangoColor "#e67817" . wrap "[" "]" . pangoSanitize
, ppVisible = pangoColor "#663366" . wrap "(" ")" . pangoSanitize
, ppHidden = wrap " " " "
, ppUrgent = pangoColor "red"
}
-- This retry is really awkward, but sometimes DBus won't let us get our
-- name unless we retry a couple times.
getWellKnownName :: Connection -> IO ()
getWellKnownName dbus = tryGetName `catchDyn` (\ (DBus.Error _ _) ->
getWellKnownName dbus)
where
tryGetName = do
namereq <- newMethodCall serviceDBus pathDBus interfaceDBus "RequestName"
addArgs namereq [String "org.xmonad.Log", Word32 5]
sendWithReplyAndBlock dbus namereq 0
return ()
outputThroughDBus :: Connection -> String -> IO ()
outputThroughDBus dbus str = do
let str' = "<span font=\"Ubuntu\">" ++ str ++ "</span>"
-- let str' = "<span>" ++ str ++ "</span>"
msg <- newSignal "/org/xmonad/Log" "org.xmonad.Log" "Update"
addArgs msg [String str']
send dbus msg 0 `catchDyn` (\ (DBus.Error _ _ ) -> return 0)
return ()
pangoColor :: String -> String -> String
pangoColor fg = wrap left right
where
left = "<span foreground=\"" ++ fg ++ "\">"
right = "</span>"
pangoSanitize :: String -> String
pangoSanitize = foldr sanitize ""
where
sanitize '>' acc = ">" ++ acc
sanitize '<' acc = "<" ++ acc
sanitize '\"' acc = """ ++ acc
sanitize '&' acc = "&" ++ acc
sanitize x acc = x:acc
-- startNitrogen :: IO ()
-- startNitrogen = do
-- threadDelay (5 * 1000 * 1000)
-- try_ $ rawSystem "nitrogen" ["--restore"]
-- try_ :: MonadIO m => IO a -> m ()
-- try_ action = liftIO $ try action >> return ()
mySWNConfig = defaultSWNConfig
{swn_font = "-xos4-terminus-bold-*-normal-*-14-*-*-*-*-*-iso10646-*"
,swn_bgcolor = "#202020"
,swn_color = "#e67817"
,swn_fade = 1/4}
-- ssworkspaces :: [String]
-- ssworkspaces = ["dp1","dp2","dp3","dp4","dp5","dp6","dp7"]
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
[((controlMask .|. mod1Mask,xK_q),spawn $ XMonad.terminal conf)
,((controlMask .|. mod4Mask,xK_a),spawn "firefox")
,((mod1Mask .|. mod4Mask,xK_a),spawn "gajim")
,((mod4Mask,xK_Up),spawn "amixer set 'PCM' 5+ > /dev/null")
,((mod4Mask,xK_Down),spawn "amixer set 'PCM' 5- > /dev/null")
,((0,xK_Print),spawn "scrot ~/scrots/%m-%d-%T_scrot.png")
,((mod1Mask,xK_x),withFocused $ windows . W.sink)
,((mod1Mask,xK_q),spawn "xkill")
,((mod1Mask,xK_w),kill)
--, ((mod1Mask,xK_x), withFocused (sendMessage . expandWindowAlt) >> sendMessage Expand)
--, ("M-h", withFocused (sendMessage . shrinkWindowAlt) >> sendMessage Shrink)
-- , ((mod1Mask,xK_x), sendMessage MirrorShrink)
-- , ((mod1Mask,xK_z), sendMessage MirrorExpand)
-- close focused window
-- , ((modMask .|. shiftMask, xK_c ), kill)
-- Rotate through the available layout algorithms
, ((modMask, xK_space ), sendMessage NextLayout)
-- Reset the layouts on the current workspace to default
, ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
-- Resize viewed windows to the correct size
, ((modMask, xK_n ), refresh)
-- Move focus to the next window
, ((mod1Mask, xK_Tab ), windows W.focusDown)
-- Move focus to the next window
, ((modMask, xK_j ), windows W.focusDown)
-- Move focus to the previous window
, ((modMask, xK_k ), windows W.focusUp )
-- Move focus to the master window
, ((modMask, xK_m ), windows W.focusMaster )
-- Swap the focused window and the master window
, ((modMask, xK_Return), windows W.swapMaster)
-- Swap the focused window with the next window
, ((modMask .|. shiftMask, xK_j ), windows W.swapDown )
-- Swap the focused window with the previous window
, ((modMask .|. shiftMask, xK_k ), windows W.swapUp )
-- Shrink the master area
, ((modMask, xK_h ), sendMessage Shrink)
-- Expand the master area
, ((modMask, xK_l ), sendMessage Expand)
-- Push window back into tiling
-- , ((modMask, xK_t ), withFocused $ windows . W.sink)
-- Increment the number of windows in the master area
, ((modMask , xK_comma ), sendMessage (IncMasterN 1))
-- Deincrement the number of windows in the master area
, ((modMask , xK_period), sendMessage (IncMasterN (-1)))
-- toggle the status bar gap
-- TODO, update this binding with avoidStruts , ((modMask , xK_b ),
-- Quit xmonad
, ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
-- Restart xmonad
, ((modMask , xK_q ), restart "xmonad" True)
]
++
--
-- mod-[1..9], Switch to workspace N
-- mod-shift-[1..9], Move client to workspace N
--
[((m .|. mod1Mask, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
++
--
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
--
[((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
[((mod1Mask,button1),(\w -> focus w >> mouseMoveWindow w))
,((mod1Mask,button2),(\w -> focus w >> windows W.swapMaster))
,((mod1Mask,button3),(\w -> focus w >> mouseResizeWindow w))]
myLayout = avoidStruts $ smartBorders $ onWorkspace "im" imLayout $ standardLayouts
where
standardLayouts = tiled ||| Circle ||| Mirror tiled ||| Full
tiled = Tall nmaster delta ratio
nmaster = 1
ratio = 1/2
delta = 3/100
imLayout = withIM (1/10) (Role "roster") (standardLayouts)
-- tiled = ResizableTall 1 (2/100) (1/2) []
myManageHook = composeAll
[className =? "MPlayer" --> doFloat
,className =? "Gimp" --> doFloat
,className =? "Gajim.py" --> doShift "im"
-- ,(className =? "Gajim.py" <&&> role =? "roster") --> doFloat
,className =? "Firefox" --> doShift "ww"
-- ,(className =? "Gajim.py" <&&> role =? "roster") --> (ask >>= doF . W.sink)
]
-- where
-- role = stringProperty "WM_WINDOW_ROLE"