Created
April 10, 2011 10:50
-
-
Save tomasv/912242 to your computer and use it in GitHub Desktop.
xmonad config with a hack for floating windows
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 Data.Monoid | |
import System.Exit | |
import qualified XMonad.StackSet as W | |
import qualified Data.Map as M | |
import XMonad.Hooks.DynamicLog | |
import XMonad.Hooks.ManageDocks | |
import XMonad.Hooks.EwmhDesktops | |
import qualified XMonad.Actions.FlexibleManipulate as Flex | |
import XMonad.Actions.FloatSnap | |
import XMonad.Actions.Promote | |
import XMonad.Layout.NoBorders ( noBorders, smartBorders ) | |
import XMonad.Layout.Tabbed | |
import XMonad.Layout.ToggleLayouts | |
import XMonad.Layout.SimpleDecoration | |
import XMonad.Layout.DecorationMadness | |
import XMonad.Layout.SimplestFloat | |
import XMonad.Layout.PerWorkspace | |
import XMonad.Prompt | |
import XMonad.Prompt.Shell | |
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $ | |
[ ((modm, xK_a ), spawn $ XMonad.terminal conf) | |
, ((modm, xK_p ), spawn "exe=`dmenu_path | dmenu` && eval \"exec $exe\"") | |
, ((modm, xK_q ), spawn "gmrun") | |
, ((modm, xK_f ), spawn "firefox") | |
, ((modm, xK_Escape), kill) | |
, ((modm, xK_space ), sendMessage NextLayout) | |
, ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf) | |
, ((modm, xK_n ), refresh) | |
, ((modm, xK_Tab ), windows W.focusDown) | |
, ((modm, xK_j ), windows W.focusDown) | |
, ((modm, xK_k ), windows W.focusUp ) | |
, ((modm, xK_m ), windows W.focusMaster ) | |
, ((modm, xK_Return), windows W.swapMaster) | |
, ((modm .|. shiftMask, xK_j ), windows W.swapDown ) | |
, ((modm .|. shiftMask, xK_k ), windows W.swapUp ) | |
, ((modm, xK_h ), sendMessage Shrink) | |
, ((modm, xK_l ), sendMessage Expand) | |
, ((modm, xK_t ), withFocused $ windows . W.sink) | |
, ((modm , xK_comma ), sendMessage (IncMasterN 1)) | |
, ((modm , xK_period), sendMessage (IncMasterN (-1))) | |
, ((modm , xK_d ), sendMessage ToggleLayout) | |
, ((modm , xK_b ), sendMessage ToggleStruts) | |
, ((modm .|. shiftMask, xK_q ), io (exitWith ExitSuccess)) | |
, ((modm .|. controlMask, xK_r ), spawn "xmonad --recompile && xmonad --restart") | |
, ((modm, xK_Left), withFocused $ snapMove L Nothing) | |
, ((modm, xK_Right), withFocused $ snapMove R Nothing) | |
, ((modm, xK_Up), withFocused $ snapMove U Nothing) | |
, ((modm, xK_Down), withFocused $ snapMove D Nothing) | |
, ((modm .|. shiftMask, xK_Left), withFocused $ snapShrink R Nothing) | |
, ((modm .|. shiftMask, xK_Right), withFocused $ snapGrow R Nothing) | |
, ((modm .|. shiftMask, xK_Up), withFocused $ snapShrink D Nothing) | |
, ((modm .|. shiftMask, xK_Down), withFocused $ snapGrow D Nothing) | |
] | |
++ | |
[((m .|. modm, k), windows $ f i) | |
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9] | |
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]] | |
++ | |
[((m .|. modm, 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 = modm}) = M.fromList $ | |
[ ((modm, button1), (\w -> focus w >> mouseMoveWindow w >> windows W.shiftMaster)) | |
, ((modm, button2), (\w -> focus w >> windows W.shiftMaster)) | |
, ((modm, button3), (\w -> focus w >> Flex.mouseWindow Flex.linear w >> windows W.shiftMaster)) | |
] | |
myLayout = smartBorders $ | |
onWorkspace "6" simplestFloat $ | |
toggleLayouts Full $ | |
avoidStruts | |
(tallSimpleDwmStyle ||| tiled ||| Mirror tiled ||| simpleTabbed) | |
where | |
tiled = Tall nmaster delta ratio | |
nmaster = 1 | |
ratio = 1/2 | |
delta = 3/100 | |
-- To find the property name associated with a program, use | |
-- > xprop | grep WM_CLASS | |
myManageHook = composeAll | |
[ className =? "MPlayer" --> doFloat | |
, className =? "Gimp" --> doFloat | |
, className =? "Skype" --> doFloat | |
, className =? "Pidgin" --> doFloat | |
, className =? "Sonata" --> doFloat | |
, className =? "Deadbeef" --> doFloat | |
, className =? "ROX-Filer" --> doFloat | |
, className =? "Wicd-client.py" --> doFloat | |
, resource =? "desktop_window" --> doIgnore | |
, resource =? "kdesktop" --> doIgnore ] | |
<+> manageDocks | |
myEventHook = floatClickFocusHandler | |
-- bring clicked floating window to the front | |
floatClickFocusHandler :: Event -> X All | |
floatClickFocusHandler ButtonEvent { ev_window = w } = do | |
withWindowSet $ \s -> do | |
if isFloat w s | |
then (focus w >> promote) | |
else return () | |
return (All True) | |
where isFloat w ss = M.member w $ W.floating ss | |
floatClickFocusHandler _ = return (All True) | |
myLogHook = mempty | |
myStartupHook = return () | |
myWorkspaces = map show [1..6 :: Int] | |
myNormalBorderColor = "#dddddd" | |
myFocusedBorderColor = "#aa0000" | |
main = xmonad $ ewmh defaults | |
defaults = defaultConfig { | |
terminal = "urxvt", | |
focusFollowsMouse = False, | |
borderWidth = 1, | |
modMask = mod4Mask, | |
workspaces = myWorkspaces, | |
normalBorderColor = myNormalBorderColor, | |
focusedBorderColor = myFocusedBorderColor, | |
keys = myKeys, | |
mouseBindings = myMouseBindings, | |
layoutHook = myLayout, | |
manageHook = myManageHook, | |
handleEventHook = myEventHook, | |
logHook = myLogHook, | |
startupHook = myStartupHook | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks to! I have been looking for a similar solution for a long time.