summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xmonad.hs152
1 files changed, 115 insertions, 37 deletions
diff --git a/xmonad.hs b/xmonad.hs
index 2e97911..1c565cc 100644
--- a/xmonad.hs
+++ b/xmonad.hs
@@ -31,6 +31,8 @@ import XMonad.Actions.FindEmptyWorkspace
import XMonad.Actions.FloatSnap
import XMonad.Actions.GridSelect
import XMonad.Actions.SinkAll
+import XMonad.Actions.SpawnOn
+import XMonad.Actions.TopicSpace hiding (pprWindowSet)
import XMonad.Actions.UpdateFocus
import qualified XMonad.Actions.FlexibleManipulate as Flex
@@ -59,6 +61,9 @@ import XMonad.Util.Replace (replace)
import Control.Monad (when)
import System.Environment (getArgs)
+import Data.Maybe (fromMaybe, fromJust, isNothing, isJust)
+import Data.Ord (comparing)
+
-- custom modules
import HistoryGrid
import EZConfig
@@ -73,8 +78,6 @@ term = "urxvt"
browser :: String
browser = "browser"
-myWorkspaces :: [String]
-myWorkspaces = ["1:web", "2:mail" ,"3:irc", "4:im", "5:code"] ++ map show [6 .. 9 :: Int] ++ ["0", "video", "music"]
modM = mod4Mask -- mod1Mask = Alt, mod2Mask = , mod3Mask= , mod4Mask = Win, mod5Mask = AltGr
@@ -109,10 +112,65 @@ main = do
, keys = \c -> mkKeymap c $ myKeys c
, mouseBindings = \c -> M.union (M.fromList $ myMouse c) $ mouseBindings defaultConfig c
, layoutHook = myLayout
- , workspaces = myWorkspaces
+ , workspaces = topics
, handleEventHook = myEventHook
, startupHook = myStartupHook
}
+--}}}
+
+--{{{ TopicSpaces
+
+topics :: [Topic]
+topics = [ "web", "mail", "irc", "im", "video", "music"
+ , "spline", "usdx", "partdb", "riot", "zedat"
+ , "emacs", "xmonad", "gimp"]
+
+topicsConfig = TopicConfig
+ { topicDirs = M.fromList $
+ [ ("web", "./")
+ , ("mail", "./")
+ , ("irc", "./")
+ , ("im", "./")
+ , ("video", "media/video")
+ , ("music", "media/audio/")
+ , ("spline", "dev/spline/")
+ , ("usdx", "dev/usdx/")
+ , ("partdb", "dev/Part-DB/")
+ , ("riot", "dev/RIOT/")
+ , ("zedat", "./")
+ , ("emacs", "./")
+ , ("xmoand", ".xmonad/")
+ , ("gimp", "./")
+ ]
+ , defaultTopicAction = const $ spawnShell >*> 2
+ , defaultTopic = "web"
+ , maxTopicHistory = 10
+ , topicActions = M.fromList $
+ [ ("web" , spawnHere browser)
+ , ("mail" , spawn "emacsclient -e '(wl-start)'")
+ , ("irc" , spawnHere "hexchat")
+ , ("im" , spawnHere "tkabber")
+ , ("music" , spawnHere "guayadeque")
+ , ("zedat" , spawnHere $ term ++ " -e is")
+ , ("emacs" , spawnHere "emacs")
+ , ("gimp" , spawnHere "gimp")
+ ]
+ }
+ where
+ spawnShell = currentTopicDir topicsConfig >>= spawnShellIn
+ spawnShellIn dir =
+ spawnHere $ "cd " ++ dir ++ " && " ++ term
+
+topicsGrid =
+ withWindowSet $ \w -> do
+ let wss = W.workspaces w
+ usednames = filter (\w -> w /= "NSP") $ map W.tag $ wss
+ newnames = filter (\used -> (show used `notElem` (map show topics))) usednames
+ gridselect topicsGridConfig (map (\t -> (t, t)) (topics ++ newnames))
+
+promptedGoto = topicsGrid >>= flip whenJust (switchTopic topicsConfig)
+
+promptedShift = topicsGrid >>= \x -> whenJust x $ \y -> windows (W.greedyView y . W.shift y)
--}}}
@@ -205,13 +263,44 @@ historyGridConfig = defaultGSConfig
, gs_font = font
}
+topicsGridConfig = defaultGSConfig
+ { gs_navigate = navNSearch
+ , gs_font = font
+ , gs_colorizer = colorizer
+ }
+ where
+ colorizer topic selected
+ | selected = return ("#839596", "#002b36")
+ | otherwise = return ("#002b36", "#839496")
+
--}}}
--{{{ Hooks
myLogHook statusFile = do
ewmhDesktopsLogHook
- dynamicLogWithPP $ myPP statusFile
+ topicOutput <- lastTopics topicsConfig pp
+ otherOutput <- dynamicLogString pp { ppVisible = \_ -> ""
+ , ppCurrent = \_ -> ""
+ , ppUrgent = \_ -> ""
+ , ppHidden = \_ -> ""
+ }
+ io $ ppOutput pp (topicOutput ++ otherOutput)
+ where
+ pp = myPP statusFile
+ lastTopics tg pp = do
+ winset <- gets windowset
+ urgents <- readUrgents
+ let empty_workspaces = map W.tag $ filter (isNothing . W.stack) $ W.workspaces winset
+ maxDepth = maxTopicHistory tg
+ setLastFocusedTopic (W.tag . W.workspace . W.current $ winset)
+ (\t -> (t `notElem` empty_workspaces && t /= "NSP"))
+ lastWs <- getLastFocusedTopics
+ let depth topic = fromJust $ elemIndex topic $ lastWs ++ [topic]
+ add_depth proj topic = proj pp . (((topic++":")++) . show) . depth $ topic
+ pp' = pp { ppHidden = add_depth ppHidden, ppVisible = add_depth ppVisible, ppUrgent = add_depth ppUrgent }
+ sortWindows = take maxDepth . sortBy (comparing $ depth . W.tag) . namedScratchpadFilterOutWorkspace
+ return $ pprWindowSet sortWindows urgents pp' winset
myEventHook = do
ewmhDesktopsEventHook
@@ -287,26 +376,24 @@ xPropMatches =
]
myShifts =
- [ (wM_CLASS, (==), "Opera", "1:web")
- , (wM_CLASS, (==), "Chrome", "1:web")
- , (wM_CLASS, (==), "Chromium-browser", "1:web")
- , (wM_CLASS, (==), "Firefox-bin", "1:web")
+ [ (wM_CLASS, (==), "Opera", "web")
+ , (wM_CLASS, (==), "Chrome", "web")
+ , (wM_CLASS, (==), "Chromium-browser", "web")
+ , (wM_CLASS, (==), "Firefox-bin", "web")
- , (wM_CLASS, (==), "Claws-mail", "2:mail")
- , (wM_CLASS, (==), "Mitter", "2:mail")
- , (wM_CLASS, (==), "wanderlust", "2:mail")
- , (wM_NAME, (==), "newsbeuter", "2:mail")
+ , (wM_CLASS, (==), "Claws-mail", "mail")
+ , (wM_CLASS, (==), "Mitter", "mail")
+ , (wM_CLASS, (==), "wanderlust", "mail")
+ , (wM_NAME, (==), "newsbeuter", "mail")
- , (wM_CLASS, (==), "Hexchat", "3:irc")
+ , (wM_CLASS, (==), "Hexchat", "irc")
-- tkabber roater
- , (wM_CLASS, (==), "Tkabber", "4:im")
+ , (wM_CLASS, (==), "Tkabber", "im")
-- tkabber single messages
- , (wM_CLASS, (==), "headlines", "4:im")
- , (wM_CLASS, isPrefixOf, "chat_##xmpp##1_zedatconferencejabberfuberlinde", "4:im")
- , (wM_CLASS, isPrefixOf, "chat_##xmpp##1_mailanimuxdeSyslogBot", "4:im")
-
- , (wM_CLASS, (==), "emacs", "5:code")
+ , (wM_CLASS, (==), "headlines", "im")
+ , (wM_CLASS, isPrefixOf, "chat_##xmpp##1_zedatconferencejabberfuberlinde", "im")
+ , (wM_CLASS, isPrefixOf, "chat_##xmpp##1_mailanimuxdeSyslogBot", "im")
, (wM_CLASS, (==), "MPlayer", "video")
, (wM_CLASS, (==), "Amarokapp", "music")
@@ -369,8 +456,7 @@ myKeys c =
, ("M-d", spawn "fbsetroot -solid black")
, ("M-f", spawn "fbsetroot -l")
- , ("M-^", viewEmptyWorkspace)
- , ("M-S-^", tagToEmptyWorkspace)
+ , ("M-^", focusUrgent)
, ("M-p", myShellPrompt P.defaultXPConfig)
, ("M-e", launchApp P.defaultXPConfig "emacsclient" >> (windows (W.greedyView "5:code")))
@@ -382,15 +468,14 @@ myKeys c =
, ("M-o M-s", sshPrompt P.defaultXPConfig)
, ("M-o M-x", xmonadPrompt P.defaultXPConfig)
- , ("M-g", goToSelected defaultGSConfig)
- , ("M-S-g", bringSelected defaultGSConfig)
-
- , ("M-<Escape>", focusUrgent)
-
, ("M-+", sendMessage Mag.MagnifyMore)
, ("M-S-+", sendMessage Mag.MagnifyLess)
, ("M-#", sendMessage Mag.Toggle)
+ -- topics
+ ,("M-s" , promptedGoto)
+ ,("M-S-s", promptedShift)
+
-- multimedia keys
, ("<XF86AudioLowerVolume>", spawn "amixer -c0 -- set Master playback 2dB-")
, ("<XF86AudioRaiseVolume>", spawn "amixer -c0 -- set Master playback 2dB+")
@@ -401,20 +486,13 @@ myKeys c =
]
++
-
- -- switch to / move / copy to workspace
[
- (m ++ k, windows $ f i)
- | (i, k) <- zip myWorkspaces $ [[k] | k <- "1234567890"] ++ ["<ssharp>", "<acute>"],
- (m, f) <- [("M-", W.view), ("M-S-", W.shift), ("M-C-", copy)]
+ -- switch to / move to topic
+ ("M-" ++ m ++ [k], a i)
+ | (a, m) <- [(switchNthLastFocused topicsConfig,""), (shiftNthLastFocused, "S-")]
+ , (i, k) <- zip [1..] "123456789"
]
- ++
- [
- (m ++ k, screenWorkspace s >>= flip whenJust (windows . f))
- | (k, s) <- [("a", 0), ("s", 1)],
- (m, f) <- [("M-", W.view), ("M-S-", W.shift), ("M-C-", copy)]
- ]
myMouse c =
[ ((modM, button1),