Last active
August 6, 2021 03:38
-
-
Save hoschi/7003182 to your computer and use it in GitHub Desktop.
Command mode for XMonad, tried to use http://www.reddit.com/r/xmonad/comments/1mfr1f/modal_xmonad/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/xmonad.hs b/xmonad.hs | |
index fbf7b5e..4c8cef6 100644 | |
--- a/xmonad.hs | |
+++ b/xmonad.hs | |
@@ -23,6 +23,7 @@ import Control.Monad (filterM,liftM, join) | |
import Data.IORef | |
import Data.Monoid | |
import Data.List | |
+import Data.Bits | |
import System.Exit | |
@@ -79,6 +80,7 @@ import XMonad.Actions.Commands | |
import XMonad.Actions.GridSelect | |
import XMonad.Actions.PhysicalScreens | |
import XMonad.Actions.Workscreen | |
+import qualified XMonad.Actions.Submap as SM | |
import XMonad.Prompt | |
import XMonad.Prompt.Shell | |
@@ -545,7 +547,7 @@ myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $ | |
------------------------------------------------------------------------ | |
-- Key bindings. Add, modify or remove key bindings here. | |
-- | |
-myKeys toggleFadeSet conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ | |
+ks toggleFadeSet conf@(XConfig {XMonad.modMask = modMask}) = | |
[ | |
-- launch a terminal | |
-- ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) | |
@@ -702,10 +704,12 @@ myKeys toggleFadeSet conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ | |
-- mod-[c,w], Switch to screen N | |
-- | |
- ++ | |
- [((m .|. modMask, key), sc >>= screenWorkspace >>= flip whenJust (windows . f)) | |
- | (key, sc) <- zip [xK_c, xK_w] [(screenBy (-1)),(screenBy 1)] | |
- , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] | |
+ {- | |
+ -++ | |
+ -[((m .|. modMask, key), sc >>= screenWorkspace >>= flip whenJust (windows . f)) | |
+ - | (key, sc) <- zip [xK_c, xK_w] [(screenBy (-1)),(screenBy 1)] | |
+ - , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] | |
+ -} | |
-- Standard keybindings: | |
-- mod-[1..9], Switch to workspace N | |
@@ -725,3 +729,7 @@ myKeys toggleFadeSet conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ | |
--, ((modMask .|. shiftMask, xK_l), sendMessage MirrorExpand) | |
] | |
+modalmode toggleFadeSet conf@(XConfig {XMonad.modMask = modMask}) = [ ((m `xor` modMask, k), a >> (SM.submap . M.fromList $ modalmode toggleFadeSet conf)) | ((m, k), a) <- ks toggleFad | |
+ | |
+myKeys :: IORef (S.Set Window) -> XConfig Layout -> M.Map (KeyMask, KeySym) (X ()) | |
+myKeys toggleFadeSet conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ ((modMask, xK_w), SM.submap . M.fromList $ (modalmode toggleFadeSet conf)) : (ks toggleFadeSet conf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XMonad | |
import qualified XMonad.StackSet as W | |
import qualified XMonad.Actions.FlexibleResize as Flex | |
import qualified Data.Map as M | |
import qualified Data.Set as S | |
import Control.Monad (filterM,liftM, join) | |
import Data.IORef | |
import Data.Monoid | |
import Data.List | |
import Data.Bits | |
import System.Exit | |
import XMonad.Config.Desktop (desktopLayoutModifiers) | |
import XMonad.Layout.Accordion | |
import XMonad.Layout.WorkspaceDir | |
import XMonad.Layout.NoBorders | |
import XMonad.Layout.ResizableTile | |
import XMonad.Layout.Reflect | |
import XMonad.Layout.Tabbed | |
import XMonad.Layout.DecorationMadness | |
import XMonad.Layout.Named(named) | |
import XMonad.Layout.GridVariants | |
import XMonad.Layout.Minimize | |
import XMonad.Layout.BoringWindows | |
import XMonad.Layout.Maximize | |
import XMonad.Layout.Mosaic | |
import XMonad.Layout.ShowWName | |
import XMonad.Layout.LimitWindows | |
import XMonad.Layout.Magnifier | |
import XMonad.Layout.FixedColumn | |
import XMonad.Layout.PerWorkspace | |
import XMonad.Layout.MultiToggle | |
import XMonad.Layout.MultiToggle.Instances | |
import XMonad.Layout.Monitor | |
import XMonad.Layout.LayoutModifier | |
import XMonad.Hooks.DynamicLog | |
import XMonad.Hooks.DynamicBars | |
import XMonad.Hooks.SetWMName | |
import XMonad.Hooks.ManageDocks | |
import XMonad.Hooks.ManageHelpers | |
import XMonad.Hooks.EwmhDesktops | |
import XMonad.Hooks.UrgencyHook | |
import XMonad.Hooks.ServerMode | |
import XMonad.Hooks.FadeInactive | |
import XMonad.Hooks.ICCCMFocus | |
import XMonad.Util.EZConfig(additionalKeys) | |
import XMonad.Util.Scratchpad | |
import XMonad.Util.NamedScratchpad | |
import XMonad.Util.Run | |
import XMonad.Util.WorkspaceCompare | |
import XMonad.Actions.DynamicWorkspaces | |
import XMonad.Actions.CycleWS | |
import XMonad.Actions.CopyWindow | |
import XMonad.Actions.TopicSpace | |
import XMonad.Actions.SpawnOn | |
import XMonad.Actions.UpdatePointer | |
import XMonad.Actions.WindowGo | |
import XMonad.Actions.Commands | |
import XMonad.Actions.GridSelect | |
import XMonad.Actions.PhysicalScreens | |
import XMonad.Actions.Workscreen | |
import qualified XMonad.Actions.Submap as SM | |
import XMonad.Prompt | |
import XMonad.Prompt.Shell | |
import XMonad.Prompt.Man | |
import XMonad.Prompt.Ssh | |
import XMonad.Prompt.Window | |
import XMonad.Prompt.Workspace | |
import XMonad.Prompt.AppendFile | |
myLayout = | |
boringAuto $ | |
maximize $ | |
minimize $ | |
smartBorders $ | |
avoidStruts $ | |
myShowWName $ | |
desktopLayoutModifiers $ | |
-- transparency setting don't work :( | |
--ModifiedLayout monitorToggl $ | |
mkToggle (REFLECTX ?? NOBORDERS ?? FULL ?? EOT) $ | |
magnifierOff $ | |
onWorkspaces ["im", "vm"] (myGrid ||| all) $ | |
onWorkspaces ["sweetp", "grf2"] (mosaic 1.2 [18,9,8,1.5] ||| all) $ | |
onWorkspaces ["calendar", "grf"] (simpleTabbedAlways ||| all) $ | |
all | |
where | |
myCode = limitWindows 3 $ magnifiercz' 1.4 $ FixedColumn 1 20 80 10 | |
myResizableTall = limitWindows 4 $ ResizableTall nmaster ratio delta [] | |
myMosaic = limitWindows 5 $ mosaic 1.2 [18,6,3] | |
myEvenMosaic = limitWindows 5 $ mosaic 1.0 [10,6,3] | |
myGrid = SplitGrid XMonad.Layout.GridVariants.L 2 1 (1/2) (16/10) (5/100) | |
all = myMosaic ||| | |
myCode ||| | |
myEvenMosaic ||| | |
myResizableTall ||| | |
simpleTabbedAlways | |
nmaster = 1 | |
ratio = 0.03 | |
delta = 0.65 | |
myShowWName = showWName' defaultSWNConfig | |
{ swn_bgcolor = "red" | |
, swn_font = myBigFont | |
, swn_color = "black" | |
, swn_fade = 1.5 | |
} | |
------------------------------------------------------------------------------------------ | |
-- Monitors | |
------------------------------------------------------------------------------------------ | |
monitorToggl = monitor { | |
prop = ClassName "google-chrome" `And` Title "Toggl Nano" | |
, rect = Rectangle (3840-50) (1200-100) 50 100 | |
, persistent = True | |
, XMonad.Layout.Monitor.opacity = 0.4 | |
, visible = False | |
, XMonad.Layout.Monitor.name = "toggl" | |
} | |
------------------------------------------------------------------------------------------ | |
-- XPConfig | |
------------------------------------------------------------------------------------------ | |
myTerminal = "urxvt" | |
myShell = "zsh" | |
myNormalBorderColor = "#444444" | |
-- this fonts should work on every unix | |
-- myFont = "-misc-fixed-medium-r-*-*-25-*-*-*-*-*-*-*" | |
-- myDzenFont = "-misc-fixed-bold-r-*-*-12-*-*-*-*-*-*-*" | |
-- myTinyFont = "-misc-fixed-bold-r-*-*-15-*-*-*-*-*-*-*" | |
-- mySmallFont = "-misc-fixed-medium-r-*-*-18-*-*-*-*-*-*-*" | |
-- myBigFont = "-misc-fixed-medium-r-*-*-50-*-*-*-*-*-*-*" | |
myFont = "xft:DejaVu Sans Mono:size=22" | |
myDzenFont = "-misc-fixed-bold-r-*-*-12-*-*-*-*-*-*-*" | |
myTinyFont = "xft:DejaVu Sans Mono:size=12" | |
mySmallFont = "xft:DejaVu Sans Mono:size=15" | |
myBigFont = "xft:DejaVu Sans Mono:size=45" | |
myXPConfig :: XPConfig | |
myXPConfig = defaultXPConfig { | |
font = myFont | |
, bgColor = "#000000" | |
, height = 50 | |
} | |
appendXPConfig :: XPConfig | |
appendXPConfig = myXPConfig { | |
font = mySmallFont | |
} | |
------------------------------------------------------------------------------------------ | |
-- helper functions | |
------------------------------------------------------------------------------------------ | |
withScreen screen f = screenWorkspace screen >>= flip whenJust (windows . f) | |
copyToggl :: X() | |
copyToggl = runOrCopy "" (title =? "Toggl Nano") | |
spawnShell :: X () | |
spawnShell = currentTopicDir myTopicConfig >>= spawnShellIn | |
spawnShellIn :: Dir -> X () | |
spawnShellIn dir = spawnHere $ myTerminal ++ " -cd " ++ dir | |
spawnIn :: String -> Dir -> X () | |
spawnIn cmd dir = spawnHere $ myTerminal ++ " -hold -cd " ++ dir ++ " -e " ++ cmd | |
spawnScreen :: String -> String -> String -> X () | |
spawnScreen host screen window = spawnHere $ "ssh " ++ host ++ " " ++ myTerminal ++ " -e 'screen -x " ++ screen ++ " -p " ++ window ++ "'" | |
spawnLocalScreen :: String -> String -> X () | |
spawnLocalScreen screen window = spawnHere $ myTerminal ++ " -e screen -x " ++ screen ++ " -p " ++ window | |
goto :: Topic -> X () | |
goto = switchTopic myTopicConfig | |
promptedGoto :: X () | |
promptedGoto = workspacePrompt myXPConfig goto | |
promptedShift :: X () | |
promptedShift = workspacePrompt myXPConfig $ windows . W.shift | |
promptedCopy :: X () | |
promptedCopy = workspacePrompt myXPConfig $ windows . copy | |
------------------------------------------------------------------------------------------ | |
-- topics | |
------------------------------------------------------------------------------------------ | |
-- The list of all topics/workspaces of your xmonad configuration. | |
-- The order is important, new topics must be inserted | |
-- at the end of the list if you want hot-restarting | |
-- to work. | |
myTopics :: [Topic] | |
myTopics = | |
[ "dashboard" | |
, "dashboard2" | |
, "im" | |
, "spotify" | |
, "grf" | |
, "grf2" | |
, "calendar" | |
, "idea" | |
, "xmonad" | |
, "xmonad2" | |
, "sweetp" | |
, "stuff" | |
, "vm" | |
, "sweetp-md" | |
, "serien" | |
] | |
myTopicConfig :: TopicConfig | |
myTopicConfig = defaultTopicConfig | |
{ topicDirs = M.fromList $ | |
[ ("calendar", "~/") | |
, ("im", "~/") | |
, ("serien", "~/") | |
, ("dashboard", "~/") | |
, ("dashboard2", "~/") | |
, ("xmonad", "~/.xmonad") | |
, ("xmonad2", "~/.xmonad") | |
, ("grf", "~/repos/grf") | |
, ("grf2", "~/repos/grf") | |
, ("sweetp", "~/repos/sweetp") | |
, ("stuff", "~/") | |
, ("vm", "~/") | |
, ("sweetp-md", "~/repos/sweetp/sweetp-md") | |
, ("idea", "~/") | |
, ("spotify", "~/") | |
] | |
, defaultTopicAction = const $ spawnShell >*> 3 | |
, defaultTopic = "dashboard" | |
, maxTopicHistory = 9 | |
, topicActions = M.fromList $ | |
[ ("calendar", spawnHere "google-chrome --app='https://www.google.com/calendar/'" ) | |
, ("im", (spawnHere "skype" >> spawnHere "empathy" >> runOrCopy "xchat" (className =? "Xchat"))) | |
, ("serien", return ()) | |
, ("dashboard", copyToggl >> spawnIn "vim todo42.txt brain.otl projects.otl" "~/" >> spawnHere "google-chrome --app='http://rememberthemilk.com/'" >> spawnHere ("google-chrome --new-window \ | |
\ https://mail.google.com \ | |
\ http://technosplode.com/ \ | |
\ https://plus.google.com/stream/circles/p2008c1258d76c8ba \ | |
\ http://slant.co/?filter=new \ | |
\ http://news.ycombinator.com/ \ | |
\ http://www.echojs.com/ \ | |
\ http://webplatformdaily.org/ \ | |
\ http://www.kickstarter.com/discover/categories/technology/popular?ref=more \ | |
\ http://misoproject.com/d3-chart/charts.html \ | |
\ \ | |
\ https://www.facebook.com/ \ | |
\ https://bitdeli.com/hoschi \ | |
\ https://github.com/hoschi")) | |
, ("dashboard2", spawnShell >> runOrCopy "xchat" (className =? "Xchat")) | |
, ("xmonad", copyToggl >> spawnHere "google-chrome --new-window --pinned-tab-count=2 http://www.haskell.org/haskellwiki/Xmonad/Config_archive http://www.eng.uwaterloo.ca/~aavogt/xmonad/docs/xmonad-contrib/") | |
, ("xmonad2", spawnIn "vim xmonad.hs todo-xmonad.otl" "~/.xmonad" >> runOrCopy "xchat" (className =? "Xchat") >> spawnShell) | |
, ("idea", spawnHere "/home/hoschi/bin/idea") | |
, ("grf", spawnShell) | |
, ("grf2", spawnHere "gc-webdev") | |
, ("sweetp", spawnHere "gc-sweetp-site") | |
, ("stuff", return ()) | |
, ("vm", spawnHere "VirtualBox") | |
, ("sweetp-md", spawnShell) | |
, ("spotify", spawnHere "spotify") | |
] | |
} | |
------------------------------------------------------------------------------------------ | |
-- scratchpads | |
------------------------------------------------------------------------------------------ | |
scratchpads = | |
[ NS "amarok" "amarok" (className =? "Amarokapp") (customFloating $ W.RationalRect (1/4) (1/8) (1/2) (1/2)) | |
, NS "shell-fm" "urxvt -title 'shell-fm' -hold -e screen -S fm" (title =? "shell-fm") (customFloating $ W.RationalRect (1/4) (1/8) (1/2) (1/2)) | |
, NS "grooveshark" "gc-grooveshark --app='http://www.simfy.de/profiles/vkhoschi/playlists'" (fmap ("simfy" `isInfixOf`) title) (customFloating $ W.RationalRect (0.2) (0.2) (0.8) (0.8)) | |
] where role = stringProperty "WM_WINDOW_ROLE" | |
------------------------------------------------------------------------------------------ | |
-- manage hooks | |
------------------------------------------------------------------------------------------ | |
myManageHook = composeAll . concat $ | |
[ | |
[fmap(i `isPrefixOf`) resource --> doIgnore | i <- myIgnores] | |
, [fmap(f `isPrefixOf`) resource --> doCenterFloat | f <- myFloats] | |
, [className =? "MPlayer" --> (ask >>= doF . W.sink)] | |
, [className =? "Pidgin" --> doF (W.shift "im")] | |
, [(fmap ("volle-kanne-hoschi - Skype" `isInfixOf`) title) --> doF (W.shift "im")] | |
, [(fmap ("Kontaktliste" `isInfixOf`) title) --> doF (W.shift "im")] | |
, [className =? "Skype" --> doF (W.shift "im")] | |
, [className =? "Xchat" --> doF (W.shift "im")] | |
, [className =? "Empathy" --> doF (W.shift "im")] | |
, [(fmap ("Google Calendar" `isInfixOf`) title) --> doF (W.shift "calendar")] | |
, [(fmap ("evernote web" `isInfixOf`) title) --> doF (W.shift "thinkingrock")] | |
, [(fmap ("ThinkingRock" `isInfixOf`) title) --> doF (W.shift "thinkingrock")] | |
, [(fmap ("NX - " `isInfixOf`) title) --> doCenterFloat] | |
, [(fmap ("My Window State Sample" `isInfixOf`) title) --> doFloat] | |
, [(fmap ("cairo-dock-dialog" `isInfixOf`) title) --> doSideFloat CE] | |
, [(fmap ("Guake" `isInfixOf`) title) --> (doRectFloat $ W.RationalRect (1/4) 0 (1/2) (1/3))] | |
, [isFullscreen --> doFullFloat] | |
-- changes layout when you open the 5th window | |
-- set names for custom layouts see XMonad.Layout.Named | |
-- , [(liftX (gets windowset) >>= return . (>3) . length . W.index) --> liftX (sendMessage (JumpToLayout "whatever it is called")) >> doF id] | |
--, [isFullscreen --> (doF W.focusDown <+> doFullFloat)] | |
, [manageVirtualBox] | |
] where | |
myFloats = [ "gnome-panel" | |
, "MPlayer" | |
, "timer-applet" | |
, "focus booster" | |
, "gloobus-preview" | |
] | |
myIgnores = ["Do"] | |
role = stringProperty "WM_WINDOW_ROLE" | |
-- examples here: | |
-- http://www.haskell.org/haskellwiki/Xmonad/Config_archive/ivy-foster-xmonad.hs | |
manageVirtualBox :: ManageHook | |
manageVirtualBox = | |
className =? "VirtualBox" | |
--> composeOne | |
[ (fmap ("dev [wird wiederhergestellt] - oracle vm" `isInfixOf`) title) -?> doF (W.shift "financy") | |
, (fmap ("dev [wird ausgeführt] - oracle vm" `isInfixOf`) title) -?> doF (W.shift "financy") | |
, (fmap ("Beenden der virtuellen Maschine" `isInfixOf`) title) -?> doCenterFloat | |
, return True -?> doF (W.shift "vm")] | |
-- | |
-- dzen | |
-- | |
dzenBarHeight :: Integer | |
dzenBarHeight = 25 | |
-- leipzig | |
{- | |
-myDzenWorkSpaceBarShorter = | |
- "dzen2\ | |
- \ -ta 'l' \ | |
- \ -w '1000' \ | |
- \ -y '" ++ show (1080 - dzenBarHeight) ++ "' \ | |
- \ -h '" ++ show dzenBarHeight ++ "' \ | |
- \ -bg '#000000' \ | |
- \ -fg '#555555' \ | |
- \ -fn '" ++ myDzenFont ++ "' -xs " | |
- | |
-myDzenInfoBar = | |
- " nice -n 19 mydzen | dzen2\ | |
- \ -ta 'l' \ | |
- \ -x '1020' -w '900' \ | |
- \ -y '" ++ show (1080 - dzenBarHeight) ++ "' \ | |
- \ -h '" ++ show dzenBarHeight ++ "' \ | |
- \ -bg '#000000' \ | |
- \ -fg '#555555' \ | |
- \ -fn '" ++ myDzenFont ++ "' -p -xs " | |
- | |
-myDzenWorkSpaceBar = | |
- "dzen2\ | |
- \ -fn '" ++ myDzenFont ++ "' -ta 'l' \ | |
- \ -h '" ++ show dzenBarHeight ++ "' \ | |
- \ -bg '#000000' \ | |
- \ -fg '#555555' \ | |
- \ -w 1000 -xs " | |
- | |
--- not used currently because of experimenting with dunst | |
-myDzenNotifyBar = | |
- "/home/hoschi/bin/notin | dzen2\ | |
- \ -ta 'l' \ | |
- \ -h '27' -x '500' -w '877' \ | |
- \ -bg '#000000' \ | |
- \ -fg '#555555' \ | |
- \ -fn '" ++ myDzenFont ++ "' -p " | |
- | |
-} | |
-- daheim | |
myDzenWorkSpaceBarShorter = | |
"dzen2\ | |
\ -ta 'l' \ | |
\ -x '75' -w '1377' \ | |
\ -h '" ++ show dzenBarHeight ++ "' \ | |
\ -bg '#000000' \ | |
\ -fg '#555555' \ | |
\ -fn '" ++ myDzenFont ++ "' -xs " | |
-- my info bar | |
myDzenInfoBar = | |
" nice -n 19 mydzen | dzen2\ | |
\ -ta 'l' \ | |
\ -x '1020' -w '900' \ | |
\ -y '" ++ show (1080 - dzenBarHeight) ++ "' \ | |
\ -h '" ++ show dzenBarHeight ++ "' \ | |
\ -bg '#000000' \ | |
\ -fg '#555555' \ | |
\ -fn '" ++ myDzenFont ++ "' -p -xs " | |
myDzenWorkSpaceBar = | |
"dzen2\ | |
\ -fn '" ++ myDzenFont ++ "' -ta 'l' \ | |
\ -h '" ++ show dzenBarHeight ++ "' \ | |
\ -bg '#000000' \ | |
\ -fg '#555555' \ | |
\ -w 1920 -xs " | |
-- not used currently because of experimenting with dunst | |
myDzenNotifyBar = | |
"/home/hoschi/bin/notin | dzen2\ | |
\ -ta 'l' \ | |
\ -h '27' -x '500' -w '877' \ | |
\ -bg '#000000' \ | |
\ -fg '#555555' \ | |
\ -fn '" ++ myDzenFont ++ "' -p " | |
barCreator :: DynamicStatusBar | |
barCreator (S sid) = do if (sid == 0) | |
then do | |
let cmd = myDzenWorkSpaceBarShorter ++ show (sid + 1) | |
trace ("CREATING " ++ show sid ++ " cmd: " ++ cmd) | |
trace ("CREATING " ++ show sid ++ " cmd: " ++ myDzenInfoBar) | |
spawn (myDzenInfoBar ++ show (sid + 1)) | |
spawnPipe (cmd) | |
else do | |
let cmd = myDzenWorkSpaceBar ++ show (sid + 1) | |
trace ("CREATING " ++ show sid ++ " cmd: " ++ cmd) | |
spawnPipe (cmd) | |
barDestroyer :: DynamicStatusBarCleanup | |
barDestroyer = safeSpawn "killall" ["dzen2"] | |
-- | |
-- my PP | |
-- | |
myLogHookWithPP :: IORef (S.Set Window) -> X () | |
myLogHookWithPP toggleFadeSet = do | |
ewmhDesktopsLogHook | |
myFadeHook toggleFadeSet | |
updatePointer (Relative 0.02 0.02) | |
multiPP focused unfocused | |
takeTopFocus | |
where | |
focused = defaultPP { | |
ppCurrent = dzenColor "#ffff69" "black" | |
, ppTitle = dzenColor "#ffff69" "black" | |
, ppVisible = dzenColor "#666666" "black" | |
, ppHidden = const "" | |
, ppHiddenNoWindows = const "" | |
, ppUrgent = wrap "^fg(#00ff00)" "^fg()" | |
, ppSep = " " | |
, ppWsSep = " " | |
, ppLayout = id | |
, ppOrder = id | |
, ppSort = mkWsSort getXineramaPhysicalWsCompare | |
} | |
unfocused = focused { | |
ppCurrent = dzenColor "#c9c9c9" "black" | |
, ppTitle = dzenColor "#c9c9c9" "black" | |
} | |
myStartupHook = do | |
configWorkscreen (fromWorkspace 3 | |
[ "spotify", "dashboard", "dashboard2" | |
, "spotify", "grf2", "grf" | |
, "im", "grf2", "grf" | |
, "dashboard", "grf2", "grf" | |
, "dashboard", "xmonad", "xmonad2" | |
, "dashboard", "sweetp", "sweetp"]) | |
dynStatusBarStartup barCreator barDestroyer | |
return () | |
-- | |
-- fate stuff | |
-- | |
myFadeHook toggleFadeSet = fadeOutLogHook $ fadeIf (testCondition toggleFadeSet) 0.9 | |
doNotFadeOutWindows = | |
isFullscreen | |
<||> title =? "Call with " | |
<||> className =? "xine" | |
<||> className =? "MPlayer" | |
<||> className =? "Vlc" | |
<||> className =? "Totem" | |
<||> className =? "Shutter" | |
<||> className =? "URxvt" | |
<||> className =? "Eog" | |
testCondition :: IORef (S.Set Window) -> Query Bool | |
testCondition floats = | |
liftM not doNotFadeOutWindows -- <&&> isUnfocused | |
<&&> (join . asks $ \w -> liftX . io $ S.notMember w `fmap` readIORef floats) | |
toggleFadeOut :: Window -> S.Set Window -> S.Set Window | |
toggleFadeOut w s | w `S.member` s = S.delete w s | |
| otherwise = S.insert w s | |
-- | |
-- main | |
-- | |
main :: IO () | |
main = do | |
checkTopicConfig myTopics myTopicConfig | |
toggleFadeSet <- newIORef S.empty | |
xmonad =<< return | |
(ewmh | |
$ withUrgencyHook NoUrgencyHook | |
$ defaultConfig | |
{ layoutHook = myLayout | |
, XMonad.workspaces = myTopics | |
, logHook = myLogHookWithPP toggleFadeSet | |
, terminal = myTerminal | |
, manageHook = namedScratchpadManageHook scratchpads <+> manageSpawn <+> manageDocks <+> myManageHook <+> manageMonitor monitorToggl | |
, startupHook = ewmhDesktopsStartup >> setWMName "LG3D" >> myStartupHook | |
, handleEventHook = ewmhDesktopsEventHook <+> serverModeEventHook <+> fullscreenEventHook <+> dynStatusBarEventHook barCreator barDestroyer | |
, normalBorderColor = myNormalBorderColor | |
, mouseBindings = myMouseBindings | |
, keys = myKeys toggleFadeSet | |
, borderWidth = 3 | |
}) | |
-- | |
-- Mouse bindings: | |
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $ | |
[ ((modMask .|. shiftMask, button1), (\w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster)) -- set the window to floating mode and move by dragging | |
, ((modMask, button2), (\w -> focus w >> windows W.shiftMaster)) -- raise the window to the top of the stack | |
, ((modMask, button3), (\w -> focus w >> Flex.mouseResizeWindow w)) -- set the window to floating mode and resize by dragging | |
, ((modMask, button4), (\_ -> prevWS)) -- switch to previous workspace | |
, ((modMask, button5), (\_ -> nextWS)) -- switch to next workspace | |
-- , ((modMask, button9), (toggleWS)) -- switch to next workspace | |
] | |
------------------------------------------------------------------------ | |
-- Key bindings. Add, modify or remove key bindings here. | |
-- | |
ks toggleFadeSet conf@(XConfig {XMonad.modMask = modMask}) = | |
[ | |
-- launch a terminal | |
-- ((modMask .|. shiftMask, xK_Return), spawn $ XMonad.terminal conf) | |
((modMask .|. shiftMask, xK_Return), spawnShell ) | |
-- launch gmrun | |
--, ((modMask , xK_w ), spawn "gmrun") | |
-- close focused window | |
, ((modMask, xK_p ), kill1) | |
-- 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) | |
-- Move focus to the next window | |
, ((modMask .|. controlMask, xK_e ), windows W.focusDown) | |
-- Move focus to the previous window | |
, ((modMask .|. controlMask, xK_a ), windows W.focusUp ) | |
-- Move focus to the next window | |
, ((modMask, xK_e ), focusDown) | |
-- Move focus to the previous window | |
, ((modMask, xK_a ), focusUp ) | |
-- Move focus to the master window | |
, ((modMask, xK_m ), 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_e ), windows W.swapDown ) | |
-- Swap the focused window with the previous window | |
, ((modMask .|. shiftMask, xK_a ), windows W.swapUp ) | |
-- Shrink the master area | |
, ((modMask, xK_x ), sendMessage Shrink) | |
-- Expand the master area | |
, ((modMask, xK_v ), sendMessage Expand) | |
-- Push window back into tiling | |
, ((modMask .|. shiftMask, xK_f ), withFocused $ windows . W.sink) | |
-- Increment the number of windows in the master area | |
, ((modMask .|. controlMask, xK_comma ), sendMessage (IncMasterN 1)) | |
-- Deincrement the number of windows in the master area | |
, ((modMask .|. controlMask, xK_period), sendMessage (IncMasterN (-1))) | |
-- toggle the status bar gap | |
-- , ((modMask .|. shiftMask, xK_l ), sendMessage ToggleStruts) | |
-- Quit xmonad | |
, ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) | |
-- Restart xmonad | |
, ((modMask , xK_q ), restart "xmonad" True) | |
-- | |
-- Added by hand | |
-- | |
-- run stuff | |
, ((modMask , xK_d ), spawnHere "google-chrome") | |
-- mosaic | |
, ((modMask , xK_comma ), sendMessage Taller) | |
, ((modMask , xK_period), sendMessage Wider) | |
, ((modMask .|. shiftMask , xK_comma ), increaseLimit) | |
, ((modMask .|. shiftMask , xK_period), decreaseLimit) | |
, ((modMask .|. shiftMask , xK_d ), sendMessage Reset) | |
-- Window/Screen stuff | |
, ((modMask , xK_u ), nextScreen) | |
, ((modMask .|. shiftMask , xK_u ), shiftNextScreen) | |
, ((modMask , xK_i ), toggleWS) | |
, ((modMask .|. shiftMask , xK_i ), swapNextScreen) | |
-- , ((modMask , xK_F8 ), nextScreen >> (windows $ W.greedyView W.currentTag)) | |
-- minimizing | |
, ((modMask , xK_h ), withFocused minimizeWindow) | |
, ((modMask .|. shiftMask , xK_h ), sendMessage RestoreNextMinimizedWin) | |
-- maximizing | |
, ((modMask .|. shiftMask , xK_m ), withFocused (sendMessage . maximizeRestore)) | |
-- boring windows | |
, ((modMask , xK_b ), markBoring) | |
, ((modMask .|. shiftMask , xK_b ), clearBoring) | |
-- copy stuff | |
, ((modMask .|. shiftMask , xK_p ), killAllOtherCopies) | |
, ((modMask , xK_y ), promptedCopy) | |
, ((modMask .|. shiftMask , xK_y ), windows copyToAll) | |
-- Topic stuff | |
, ((modMask .|. shiftMask , xK_n ), currentTopicAction myTopicConfig) | |
, ((modMask .|. controlMask , xK_n ), spawnHere "groovy /home/hoschi/bin/logmenu.groovy | dzen2 -p 7 -l 30 -w 500 -bg darkblue -fg grey75 -x 300 -y 300 -e 'onstart=scrollhome,uncollapse'") | |
-- Prompts | |
, ((modMask , xK_r ), shellPromptHere myXPConfig) | |
, ((modMask , xK_n ), promptedGoto) | |
, ((modMask , xK_o ), promptedShift) | |
, ((modMask , xK_g ), goToSelected defaultGSConfig) | |
, ((modMask .|. shiftMask , xK_g ), windowPromptBring myXPConfig | |
{ autoComplete = Just 500000 }) | |
, ((modMask , xK_t ), appendFilePrompt appendXPConfig "/home/hoschi/THOUGHTS.txt") | |
, ((modMask .|. shiftMask , xK_t ), appendFilePrompt appendXPConfig "/home/hoschi/brain.otl") | |
, ((modMask .|. shiftMask , xK_r ), spawn "echo ' ' >> /home/hoschi/log/notin.log") | |
--, ((modMask .|. shiftMask , xK_f ), spawn "9menu -popup desktop:set-resolution-desktop tablet-full:set-resolution-tablet-fullscreen") | |
-- shell-fm commands | |
, ((modMask .|. shiftMask , xK_s ), spawn "screen -x fm -X stuff 'n'") | |
, ((modMask .|. controlMask , xK_s ), spawn "screen -x fm -X stuff 'B'") | |
-- DynamicWorkspaces | |
, ((modMask, xK_BackSpace), addWorkspacePrompt myXPConfig) | |
, ((modMask .|. controlMask, xK_BackSpace), renameWorkspace myXPConfig) | |
, ((modMask .|. shiftMask, xK_BackSpace), removeWorkspace) | |
-- Layout Togglers | |
, ((modMask, xK_l ), sendMessage $ XMonad.Layout.MultiToggle.Toggle REFLECTX) | |
, ((modMask .|. shiftMask, xK_l ), sendMessage $ XMonad.Layout.MultiToggle.Toggle NOBORDERS) | |
, ((modMask .|. controlMask, xK_l ), sendMessage $ XMonad.Layout.MultiToggle.Toggle FULL) | |
, ((modMask, xK_z ), sendMessage XMonad.Layout.Magnifier.Toggle) | |
, ((modMask .|. shiftMask, xK_z ), sendMessage MagnifyLess) | |
, ((modMask .|. controlMask, xK_z ), sendMessage MagnifyMore) | |
--, ((modMask .|. shiftMask, xK_f ), broadcastMessage ToggleMonitor >> refresh) | |
, ((modMask , xK_f ), withFocused $ io . modifyIORef toggleFadeSet . toggleFadeOut) | |
] | |
++ | |
-- switch workspaces with FXX keys | |
[((m .|. modMask, k), f i) | |
| (i, k) <- zip [0..11] [xK_F1 .. xK_F12] | |
, (f, m) <- [(viewWorkscreen, 0), (shiftToWorkscreen, 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 | |
-- | |
[((modMask .|. mask, key), f sc) | |
| (key, sc) <- zip [xK_1, xK_2, xK_3] [0..] | |
, (f, mask) <- [(viewScreen, 0), (sendToScreen, shiftMask)]] | |
-- mod-[c,w], Switch to screen N | |
-- | |
{- | |
-++ | |
-[((m .|. modMask, key), sc >>= screenWorkspace >>= flip whenJust (windows . f)) | |
- | (key, sc) <- zip [xK_c, xK_w] [(screenBy (-1)),(screenBy 1)] | |
- , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]] | |
-} | |
-- Standard keybindings: | |
-- mod-[1..9], Switch to workspace N | |
-- mod-shift-[1..9], Move client to workspace N | |
-- mod-control-[1..9] @@ Copy client to workspace N | |
++ | |
[((m .|. modMask, k), windows $ f i) | |
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 ..] | |
, (f, m) <- [(W.greedyView, controlMask)]] | |
-- scratchpads keys | |
++ | |
[ | |
((modMask , xK_s), namedScratchpadAction scratchpads "shell-fm") | |
-- shrink/expand for Tall layout | |
--, ((modMask .|. shiftMask, xK_c), sendMessage MirrorShrink) | |
--, ((modMask .|. shiftMask, xK_l), sendMessage MirrorExpand) | |
] | |
modalmode toggleFadeSet conf@(XConfig {XMonad.modMask = modMask}) = [ ((m `xor` modMask, k), a >> (SM.submap . M.fromList $ modalmode toggleFadeSet conf)) | ((m, k), a) <- ks toggleFadeSet conf] | |
myKeys :: IORef (S.Set Window) -> XConfig Layout -> M.Map (KeyMask, KeySym) (X ()) | |
myKeys toggleFadeSet conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $ ((modMask, xK_w), SM.submap . M.fromList $ (modalmode toggleFadeSet conf)) : (ks toggleFadeSet conf) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment