You are not logged in.
hello Ive recently moved to arch and now xmonad. And I cannot believe i did not discover these beauties before!! (Previous distro was fedora)
So little by little with google and examples of configs out there ive manage to customize a xmonad.hs file to how i work and would like to work.
To a degree i can read my own hs file but some things idk what they do or how they work (like main).
I would basically like to implement an update pointer action. I've seen the 3rd party extensions page for xmonad but i can seem to figure out how to implement it in my xmonad config file.
I created a "myLogHook" variable (not sure if that's what haskell calls it) but dont know where to go from there. Here is my config:
import System.IO
import System.Exit
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Layout.Fullscreen
import XMonad.Layout.NoBorders
import XMonad.Layout.Spiral
import XMonad.Layout.Tabbed
import XMonad.Layout.ThreeColumns
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import XMonad.Actions.SpawnOn
import XMonad.Actions.CycleWS
import XMonad.Actions.PhysicalScreens
import XMonad.Layout.Circle
import XMonad.Actions.UpdatePointer
-- FOR MULTIMEDIA KEYS RUN:
-- "xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'"
-- Then look in /usr/include/X11/XF86keysym.h and look for the name and code.
--
------------------------------------------------------------------------
-- Terminal
-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
myTerminal = "terminator"
myInternet = "google-chrome-stable"
myIM = "pidgin"
myCalc = "libreoffice --calc"
myEditor = "gedit"
myBackground = "feh --bg-scale '/home/dvm/Pictures/infinity___widescreen_pack_by_morague.jpg'"
myScreenshot = "scrot /home/dvm/Pictures/screen_%Y-%m-%d-%H-%M-%S.png -d 1"
myMouseshot = "sleep 0.2; scrot -s ~/Pictures/screen_%Y-%m-%d-%H-%M-%S.png -d 1"
myVirtual = "virtualbox"
myRdesktop = "/home/dvm/.xmonad/bin/usrds006"
myWTL = "/home/dvm/.xmonad/bin/wtl.sh"
------------------------------------------------------------------------
-- Workspaces
-- The default number of workspaces (virtual screens) and their names.
--
myWorkspaces = ["1:main","2:www","3:office","4:rdp","5:editor","6:email","7:files","8:chat","9:WTL"]
------------------------------------------------------------------------
-- Window rules
-- Execute arbitrary actions and WindowSet manipulations when managing
-- a new window. You can use this to, for example, always float a
-- particular program, or have a client always appear on a particular
-- workspace.
--
-- To find the property name associated with a program, use
-- > xprop | grep WM_CLASS
-- and click on the client you're interested in.
--
-- To match on the WM_NAME, you can use 'title' in the same way that
-- 'className' and 'resource' are used below.
--
myManageHook = composeAll
[ resource =? "desktop_window" --> doIgnore
, className =? "Galculator" --> doFloat
, className =? "Steam" --> doFloat
, className =? "Gimp" --> doFloat
, resource =? "gpicview" --> doFloat
, className =? "MPlayer" --> doFloat
, className =? "Google-chrome-stable" --> doShift "2:www"
, className =? "libreoffice-calc" --> doShift "3:office"
, className =? "VirtualBox" --> doShift "3:office"
, className =? "rdesktop" --> doShift "4:rdp"
, className =? "Gedit" --> doShift "5:editor"
, className =? "Evolution" --> doShift "6:email"
, className =? "Nautilus" --> doShift "7:files"
, className =? "Pidgin" --> doShift "8:chat"
, className =? "Wine" --> doShift "9:WTL"
, className =? "stalonetray" --> doIgnore
, isFullscreen --> (doF W.focusDown <+> doFullFloat)]
------------------------------------------------------------------------
-- Layouts
-- You can specify and transform your layouts by modifying these values.
-- If you change layout bindings be sure to use 'mod-shift-space' after
-- restarting (with 'mod-q') to reset your layout state to the new
-- defaults, as xmonad preserves your old layout settings by default.
--
-- The available layouts. Note that each layout is separated by |||,
-- which denotes layout choice.
--
myLayout = avoidStruts (
Tall 1 (3/100) (1/2) |||
Mirror (Tall 1 (3/100) (1/2)) |||
tabbed shrinkText tabConfig |||
Full |||
Circle |||
spiral (6/7)) |||
noBorders (fullscreenFull Full)
------------------------------------------------------------------------
-- Colors and borders
-- Currently based on the ir_black theme.
--
myNormalBorderColor = "#000000"
myFocusedBorderColor = "#FF0000"
-- Colors for text and backgrounds of each tab when in "Tabbed" layout.
tabConfig = defaultTheme {
activeBorderColor = "#FF0000",
activeTextColor = "#CEFFAC",
activeColor = "#000000",
inactiveBorderColor = "#FF0000",
inactiveTextColor = "#EEEEEE",
inactiveColor = "#000000"
}
-- Color of current window title in xmobar.
xmobarTitleColor = "#00ff00"
-- Color of current workspace in xmobar.
xmobarCurrentWorkspaceColor = "#ee9a00"
-- Width of the window border in pixels.
myBorderWidth = 2
------------------------------------------------------------------------
-- Key bindings
--
-- modMask lets you specify which modkey you want to use. The default
-- is mod1Mask ("left alt"). You may also consider using mod3Mask
-- ("right alt"), which does not conflict with emacs keybindings. The
-- "windows key" is usually mod4Mask.
--
myModMask = mod4Mask
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
----------------------------------------------------------------------
-- Custom key bindings
--
-- Start a terminal. Terminal to start is specified by myTerminal variable.
[ ((modMask .|. controlMask, xK_t), spawn $ XMonad.terminal conf)
-- Lock the screen using xscreensaver.
, ((0, 0x1008FF2F), spawn "xscreensaver-command -lock")
-- Run dmenu
, ((modMask, xK_p), spawn "dmenu_run")
-- Launch remote desktop script
, ((modMask .|. controlMask, xK_r), spawn myRdesktop)
-- Launch Google Chrome
, ((modMask .|. controlMask, xK_i), spawn myInternet)
-- Launch Gedit
, ((modMask .|. controlMask, xK_g), spawn myEditor)
-- Launch Libreoffice Calc
, ((modMask .|. controlMask, xK_c), spawn myCalc)
-- Launch Virtualbox
, ((modMask .|. controlMask, xK_v), spawn myVirtual)
-- Launch Evolution Email Client
, ((modMask .|. controlMask, xK_e), spawn "evolution")
-- Launch WT Library
, ((modMask .|. controlMask, xK_w), spawn myWTL)
-- Launch nautilius File Manager
, ((modMask .|. controlMask, xK_f), spawn "nautilus")
-- Switch to next workspace
, ((modMask, xK_Page_Up), nextWS)
-- Switch to prev workspace
, ((modMask, xK_Page_Down), prevWS)
-- Take a screenshot in select mode.
-- After pressing this key binding, click a window, or draw a rectangle with the mouse.
, ((modMask, xK_Print), spawn myMouseshot)
-- Take full screenshot in multi-head mode.
-- That is, take a screenshot of everything you see.
-- , ((modMask .|. controlMask .|. shiftMask, xK_p), spawn "screenshot")
, ((0, xK_Print), spawn myScreenshot)
-- Fetch a single use password.
, ((modMask .|. shiftMask, xK_o), spawn "fetchotp -x")
-- Mute volume.
-- , ((0, xK_F9), spawn "amixer -q set Master toggle")
, ((0, 0x1008FF12), spawn "amixer -q set Master toggle")
-- Decrease volume.
-- , ((0, xK_F10), spawn "amixer -q set Master 10%-")
, ((0, 0x1008FF11), spawn "amixer -q set Master 10%-")
-- Increase volume.
-- , ((0, xK_F11), spawn "amixer -q set Master 10%+")
, ((0, 0x1008FF13), spawn "amixer -q set Master 10%+")
-- Audio previous.
, ((0, 0x1008FF16), spawn "")
-- Play/pause.
, ((0, 0x1008FF14), spawn "")
-- Audio next.
, ((0, 0x1008FF17), spawn "")
-- Audio stop.
, ((0, 0x1008FF15), spawn "")
-- Eject CD tray.
-- , ((0, 0x1008FF2C), spawn "eject -T")
-- Switch to Prev Xinerama
, ((modMask, xK_Right), onPrevNeighbour W.view)
-- Switch to Next Xinerama
, ((modMask, xK_Left), onNextNeighbour W.view)
-- Switch to Prev Workspace
, ((modMask, xK_Down), prevWS)
-- Switch to Next Workspace
, ((modMask, xK_Up), nextWS)
--------------------------------------------------------------------
-- "Standard" xmonad key bindings
--
-- Close focused window.
, ((modMask .|. shiftMask, xK_c), kill)
-- Cycle 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.
, ((modMask, 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))
-- Decrement 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 .|. modMask, 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)]]
------------------------------------------------------------------------
-- Mouse bindings
--
-- Focus rules
-- True if your focus should follow your mouse cursor.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
[
-- mod-button1, Set the window to floating mode and move by dragging
((modMask, button1),
(\w -> focus w >> mouseMoveWindow w))
-- mod-button2, Raise the window to the top of the stack
, ((modMask, button2),
(\w -> focus w >> windows W.swapMaster))
-- Closed focus window. Modmask + Ctrl + Middle mouse button.
, ((modMask .|. controlMask, button2), (\w -> focus w >> kill))
-- mod-button3, Set the window to floating mode and resize by dragging
, ((modMask, button3),
(\w -> focus w >> mouseResizeWindow w))
-- you may also bind events to the mouse scroll wheel (button4 and button5)
-- mod-button4, Switch to next workspace
, ((modMask, button4),
(\w -> focus w >> nextWS))
-- mod-button5, Switch to previous workspace
, ((modMask, button5),
(\w -> focus w >> prevWS))
]
------------------------------------------------------------------------
-- Status bars and logging
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'DynamicLog' extension for examples.
--
-- To emulate dwm's status bar
--
-- > logHook = dynamicLogDzen
--
myLogHook = updatePointer (Relative 1 1)
------------------------------------------------------------------------
-- Startup hook
-- Perform an arbitrary action each time xmonad starts or is restarted
-- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
-- per-workspace layout choices.
--
-- By default, do nothing.
myStartupHook = return ()
------------------------------------------------------------------------
-- Run xmonad with all the defaults we set up.
--
main = do
xmproc <- spawnPipe "xmobar ~/.xmonad/xmobar.hs"
xmonad $ defaults {
logHook = dynamicLogWithPP $ xmobarPP {
ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor xmobarTitleColor "" . shorten 50
, ppCurrent = xmobarColor xmobarCurrentWorkspaceColor ""
, ppSep = " : "
, ppLayout = xmobarColor "orange" ""
}
-- , manageHook = manageDocks <+> myManageHook
, manageHook = manageSpawn <+> manageDocks <+> myManageHook
, startupHook = setWMName "LG3D"
-- >> spawnHere "trayer --edge top --align left --SetDockType true --SetPartialStrut true --expand true --width 6 --transparent true --alpha 0 --tint 0x000000 --height 16"
>> spawnHere "/usr/bin/xscreensaver -no-splash &"
>> spawnHere "udiskie --tray &"
>> spawnHere myBackground
-- >> spawnHere "mpd"
-- >> spawnOn "1:main" "/home/dvm/.xmonad/bin/nload.sh"
-- >> spawnOn "1:main" "/home/dvm/.xmonad/bin/clock.sh"
-- >> spawnOn "1:main" "/home/dvm/.xmonad/bin/visual.sh"
-- >> spawnHere myTerminal
-- >> spawnOn "2:www" myInternet
-- >> spawnOn "3:office" myCalc
-- >> spawnOn "4:rdp" "/home/dvm/.xmonad/bin/usrds006"
-- >> spawnOn "5:editor" myEditor
-- >> spawnOn "6:email" "evolution"
-- >> spawnOn "7:files" "nautilus"
-- >> spawnOn "9:WTL" myWTL
}
------------------------------------------------------------------------
-- Combine it all together
-- A structure containing your configuration settings, overriding
-- fields in the default config. Any you don't override, will
-- use the defaults defined in xmonad/XMonad/Config.hs
--
-- No need to modify this.
--
defaults = defaultConfig {
-- simple stuff
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = smartBorders $ myLayout,
manageHook = myManageHook,
startupHook = myStartupHook
}Any input/insight would be greatly appreciated. Thank you for you time.
Last edited by davama (2014-04-08 13:53:59)
Offline
Welcome to the forums.
Just add it to the end of logHook:
xmonad $ defaults {
logHook = dynamicLogWithPP $ xmobarPP {
ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor xmobarTitleColor "" . shorten 50
, ppCurrent = xmobarColor xmobarCurrentWorkspaceColor ""
, ppSep = " : "
, ppLayout = xmobarColor "orange" ""
}
>> updatePointer (Relative 1.0 1.0)***EDIT***
I have inconsistent results with using (Relative 1.0 1.0) here, but (Relative 0.99 0.99) seems to behave correctly.
Last edited by skottish (2014-04-07 21:12:50)
Offline
Welcome to the forums.
Just add it to the end of logHook:
xmonad $ defaults { logHook = dynamicLogWithPP $ xmobarPP { ppOutput = hPutStrLn xmproc , ppTitle = xmobarColor xmobarTitleColor "" . shorten 50 , ppCurrent = xmobarColor xmobarCurrentWorkspaceColor "" , ppSep = " : " , ppLayout = xmobarColor "orange" "" } >> updatePointer (Relative 1.0 1.0)
That won't compile until you remove the dollar sign between "dynamicLogWithPP" and "xmobarPP" (it wasn't necessary before and now you get in trouble with (>>) because the latter has higher precedence).
Offline
skottish and raynman thank you for your replies.
Ive tried what you suggested before, but i tried again this time with "1.0" and "0.99" but it does not compile as reynman mentioned.
, ppLayout = xmobarColor "orange" ""
}
>> updatePointer (Relative 1.0 1.0)How would i go about removing the "$" between dynamicLogWithPP and xmonbarPP? how is it that it "wasn't neccessary before"?
Sorry i dont know how to indent someone's comments.
Thank again.
Offline
I can get your xmonad.hs to compile on my machine with the following changes:
xmonad $ defaults {
logHook = dynamicLogWithPP xmobarPP {
ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor xmobarTitleColor "" . shorten 50
, ppCurrent = xmobarColor xmobarCurrentWorkspaceColor ""
, ppSep = " : "
, ppLayout = xmobarColor "orange" ""
}
>> updatePointer (Relative 0.99 0.99)
... snip ...First, make sure that the whitespace is correct (read: tabs or spaces being consistent). If you can't find anything wrong, then posting the compiler error would help.
Last edited by skottish (2014-04-08 13:06:30)
Offline
How would i go about removing the "$" between dynamicLogWithPP and xmonbarPP?
Open the file with an editor and remove the character.
how is it that it "wasn't neccessary before"?
In Haskell, function application (no operator, just "f x" for f applied to x) has the highest precedence level -- it binds more strongly than any other operator. ($) is also function application, but with the lowest precedence level. So "negate 1 + 1" evaluates to 0 (it's parsed as "(negate 1) + 1"), but "negate $ 1 + 1" evaluates to -2 (equivalent to "negate (1 + 1)").
Record updates effectively have even higher precedence than function application, so "dynamicLogWithPP xmobarPP {..}" is parsed as "dynamicLogWithPP (xmobarPP {..})" and the dollar sign won't change anything. When you combine it with (>>), the latter has higher precedence than ($), but lower than normal function application. That means that the version with ($) is equivalent to the following (changed formatting to make parenthesized part stand out more):
xmonad $ defaults {
logHook = dynamicLogWithPP
( xmobarPP {
ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor xmobarTitleColor "" . shorten 50
, ppCurrent = xmobarColor xmobarCurrentWorkspaceColor ""
, ppSep = " : "
, ppLayout = xmobarColor "orange" ""
}
>> updatePointer (Relative 0.99 0.99)
)
... snip ...(>>) needs the same type of action on both sides, but here you have a PP configuration on one side and an X action to update the pointer on the other. You need to first apply dynamicLogWithPP to the PP configuration to get an action of the same type, and that is exactly what happens without ($) because normal function application comes before (>>).
Last edited by Raynman (2014-04-08 13:23:44)
Offline
Awesome!!
Skotish, thank you! I copied your code into my config and it worked like a charm. At first I thought they were identical so i tried it with my code, since you mentioned watch for tabs and spaces. My block didn't work of course but I didn't understand why since "tabs and spaces" were identical. Until i put your block side by side with my block. Then i noticed the "$" was removed from:
logHook = dynamicLogWithPP $ xmobarPP {I still dont understand Haskell much and what the "$" means but Im still learning.
BTW my config has changed a bit so im going to post it (with pointer update included):
import System.IO
import System.Exit
import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Layout.Fullscreen
import XMonad.Layout.NoBorders
--import XMonad.Layout.Spiral
import XMonad.Layout.Tabbed
import XMonad.Layout.ThreeColumns
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import XMonad.Actions.SpawnOn
import XMonad.Actions.CycleWS
import XMonad.Actions.PhysicalScreens
import XMonad.Layout.Circle
import XMonad.Actions.WindowBringer
import XMonad.Layout.Cross
import XMonad.Layout.Grid
import XMonad.Layout.Minimize
import XMonad.Layout.Maximize
import XMonad.Actions.WindowMenu
import XMonad.Actions.UpdatePointer
-- FOR MULTIMEDIA KEYS RUN:
-- xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'
-- Then look in /usr/include/X11/XF86keysym.h and look for the name and code.
--
------------------------------------------------------------------------
-- Terminal
-- The preferred terminal program, which is used in a binding below and by
-- certain contrib modules.
--
myTerminal = "terminator"
myInternet = "google-chrome-stable"
myIM = "pidgin"
myCalc = "libreoffice --calc"
myEditor = "gedit"
myBackground = "feh --bg-scale '/home/dvm/Pictures/infinity___widescreen_pack_by_morague.jpg'"
myScreenshot = "scrot /home/dvm/Pictures/screen_%Y-%m-%d-%H-%M-%S.png -d 1"
myMouseshot = "sleep 0.2; scrot -s ~/Pictures/screen_%Y-%m-%d-%H-%M-%S.png -d 1"
myVirtual = "virtualbox"
myRdesktop = "/home/dvm/.xmonad/bin/usrds006"
myWTL = "/home/dvm/.xmonad/bin/wtl.sh"
------------------------------------------------------------------------
-- Workspaces
-- The default number of workspaces (virtual screens) and their names.
--
myWorkspaces = ["1:main","2:www","3:office","4:rdp","5:editor","6:email","7:files","8:chat","9:WTL"]
------------------------------------------------------------------------
-- Window rules
-- Execute arbitrary actions and WindowSet manipulations when managing
-- a new window. You can use this to, for example, always float a
-- particular program, or have a client always appear on a particular
-- workspace.
--
-- To find the property name associated with a program, use
-- > xprop | grep WM_CLASS
-- and click on the client you're interested in.
--
-- To match on the WM_NAME, you can use 'title' in the same way that
-- 'className' and 'resource' are used below.
--
myManageHook = composeAll
[ resource =? "desktop_window" --> doIgnore
, className =? "Galculator" --> doFloat
, className =? "Steam" --> doFloat
, className =? "Gimp" --> doFloat
, resource =? "gpicview" --> doFloat
, className =? "MPlayer" --> doFloat
, className =? "Google-chrome-stable" --> doShift "2:www"
, className =? "libreoffice-calc" --> doShift "3:office"
, className =? "VirtualBox" --> doShift "3:office"
, className =? "rdesktop" --> doShift "4:rdp"
, className =? "Gedit" --> doShift "5:editor"
, className =? "Evolution" --> doShift "6:email"
, className =? "Nautilus" --> doShift "7:files"
, className =? "Pidgin" --> doShift "8:chat"
, className =? "Wine" --> doShift "9:WTL"
, className =? "stalonetray" --> doIgnore
, isFullscreen --> (doF W.focusDown <+> doFullFloat)]
------------------------------------------------------------------------
-- Layouts
-- You can specify and transform your layouts by modifying these values.
-- If you change layout bindings be sure to use 'mod-shift-space' after
-- restarting (with 'mod-q') to reset your layout state to the new
-- defaults, as xmonad preserves your old layout settings by default.
--
-- The available layouts. Note that each layout is separated by |||,
-- which denotes layout choice.
--
myLayout = avoidStruts (
Tall 1 (3/100) (1/2) |||
Mirror (Tall 1 (3/100) (1/2)) |||
tabbed shrinkText tabConfig |||
Full |||
Grid ||| -- This one is nice
Circle ||| -- This and cross are similar but
simpleCross) ||| -- cross sends focus window to center.
-- spiral (6/7)) |||
noBorders (fullscreenFull Full)
------------------------------------------------------------------------
-- Colors and borders
-- Currently based on the ir_black theme.
--
myNormalBorderColor = "#000000"
myFocusedBorderColor = "#FF0000"
-- Colors for text and backgrounds of each tab when in "Tabbed" layout.
tabConfig = defaultTheme {
activeBorderColor = "#FF0000",
activeTextColor = "#CEFFAC",
activeColor = "#000000",
inactiveBorderColor = "#FF0000",
inactiveTextColor = "#EEEEEE",
inactiveColor = "#000000"
}
-- Color of current window title in xmobar.
xmobarTitleColor = "#00ff00"
-- Color of current workspace in xmobar.
xmobarCurrentWorkspaceColor = "#ee9a00"
-- Width of the window border in pixels.
myBorderWidth = 2
------------------------------------------------------------------------
-- Key bindings
--
-- modMask lets you specify which modkey you want to use. The default
-- is mod1Mask ("left alt"). You may also consider using mod3Mask
-- ("right alt"), which does not conflict with emacs keybindings. The
-- "windows key" is usually mod4Mask.
--
myModMask = mod4Mask
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
----------------------------------------------------------------------
-- Custom key bindings
--
-- Start a terminal. Terminal to start is specified by myTerminal variable.
[ ((modMask .|. controlMask, xK_t), spawn $ XMonad.terminal conf)
-- Launch remote desktop script
, ((modMask .|. controlMask, xK_r), spawn myRdesktop)
-- Launch Google Chrome
, ((modMask .|. controlMask, xK_i), spawn myInternet)
-- Launch Gedit
, ((modMask .|. controlMask, xK_g), spawn myEditor)
-- Launch Libreoffice Calc
, ((modMask .|. controlMask, xK_c), spawn myCalc)
-- Launch Virtualbox
, ((modMask .|. controlMask, xK_v), spawn myVirtual)
-- Launch Evolution Email Client
, ((modMask .|. controlMask, xK_e), spawn "evolution")
-- Launch WT Library
, ((modMask .|. controlMask, xK_w), spawn myWTL)
-- Launch nautilius File Manager
, ((modMask .|. controlMask, xK_f), spawn "nautilus")
-- display a number of actions related to window management in the center of the focused window.
-- Actions include: Closing, maximizing, minimizing and shifting the window to another workspace.
, ((modMask .|. shiftMask, xK_s), windowMenu)
-- Pops open a dmenu with window titles. Choose one,
-- and you will be taken to the corresponding workspace.
, ((modMask .|. shiftMask, xK_g), gotoMenu)
-- Pops open an application with window titles given
-- over stdin. Choose one, and it will be dragged, kicking
-- and screaming, into your current workspace.
, ((modMask .|. shiftMask, xK_b), bringMenu)
-- Lock the screen using xscreensaver. Using sleep button
, ((0, 0x1008FF2F), spawn "xscreensaver-command -lock")
-- Mute volume.
-- , ((0, xK_F9), spawn "amixer -q set Master toggle")
, ((0, 0x1008FF12), spawn "amixer -q set Master toggle")
-- Decrease volume.
-- , ((0, xK_F10), spawn "amixer -q set Master 10%-")
, ((0, 0x1008FF11), spawn "amixer -q set Master 10%-")
-- Increase volume.
-- , ((0, xK_F11), spawn "amixer -q set Master 10%+")
, ((0, 0x1008FF13), spawn "amixer -q set Master 10%+")
-- Audio previous.
, ((0, 0x1008FF16), spawn "ncmpcpp prev")
-- Play/pause.
, ((0, 0x1008FF14), spawn "ncmpcpp toggle")
-- , ((0, 0x1008FF14), spawn "ncmpcpp stop; ncmpcpp play")
-- Audio next.
, ((0, 0x1008FF17), spawn "ncmpcpp next")
-- Audio stop.
, ((0, 0x1008FF15), spawn "ncmpcpp stop")
-- Take full screenshot in multi-head mode.
-- That is, take a screenshot of everything you see.
-- , ((modMask .|. controlMask .|. shiftMask, xK_p), spawn "screenshot")
, ((0, xK_Print), spawn myScreenshot)
-- Take a screenshot in select mode.
-- After pressing this key binding, click a window, or draw a rectangle with the mouse.
, ((modMask, xK_Print), spawn myMouseshot)
-- Run dmenu
, ((modMask, xK_p), spawn "dmenu_run")
-- Eject CD tray.
, ((modMask, xK_F12), spawn "eject -T")
-- Switch to Prev Xinerama
, ((modMask, xK_Right), onPrevNeighbour W.view)
-- Switch to Next Xinerama
, ((modMask, xK_Left), onNextNeighbour W.view)
-- Switch to Prev Workspace
, ((modMask, xK_Down), moveTo Prev HiddenNonEmptyWS)
-- Switch to Next Workspace
, ((modMask, xK_Up), moveTo Next HiddenNonEmptyWS)
-- Switch to next workspace
, ((modMask, xK_Page_Up), moveTo Next HiddenWS)
-- Switch to prev workspace
, ((modMask, xK_Page_Down), moveTo Prev HiddenWS)
--------------------------------------------------------------------
-- "Standard" xmonad key bindings
--
-- Close focused window.
, ((modMask .|. shiftMask, xK_c), kill)
-- Cycle 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.
, ((modMask, 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))
-- Decrement 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 .|. modMask, 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)]]
------------------------------------------------------------------------
-- Mouse bindings
--
-- Focus rules
-- True if your focus should follow your mouse cursor.
myFocusFollowsMouse :: Bool
myFocusFollowsMouse = True
myMouseBindings (XConfig {XMonad.modMask = modMask}) = M.fromList $
[
-- mod-button1, Set the window to floating mode and move by dragging
((modMask, button1),
(\w -> focus w >> mouseMoveWindow w))
-- mod-button2, Raise the window to the top of the stack
, ((modMask, button2),
(\w -> focus w >> windows W.swapMaster))
-- Closed focus window. Modmask + Ctrl + Middle mouse button.
, ((modMask .|. controlMask, button2), (\w -> focus w >> kill))
-- mod-button3, Set the window to floating mode and resize by dragging
, ((modMask, button3),
(\w -> focus w >> mouseResizeWindow w))
-- you may also bind events to the mouse scroll wheel (button4 and button5)
-- mod-button4, Switch to next workspace
, ((modMask, button4),
(\w -> focus w >> moveTo Next HiddenNonEmptyWS))
-- mod-button5, Switch to previous workspace
, ((modMask, button5),
(\w -> focus w >> moveTo Prev HiddenNonEmptyWS))
]
------------------------------------------------------------------------
-- Status bars and logging
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'DynamicLog' extension for examples.
--
-- To emulate dwm's status bar
--
-- > logHook = dynamicLogDzen
--
------------------------------------------------------------------------
-- Startup hook
-- Perform an arbitrary action each time xmonad starts or is restarted
-- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
-- per-workspace layout choices.
--
-- By default, do nothing.
myStartupHook = return ()
------------------------------------------------------------------------
-- Run xmonad with all the defaults we set up.
--
main = do
xmproc <- spawnPipe "xmobar ~/.xmonad/xmobar.hs"
xmonad $ defaults {
logHook = dynamicLogWithPP xmobarPP {
ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor xmobarTitleColor "" . shorten 50
, ppCurrent = xmobarColor xmobarCurrentWorkspaceColor ""
, ppSep = " : "
, ppLayout = xmobarColor "orange" ""
}
>> updatePointer (TowardsCentre 0.99 0.99) -- moves pointer to center of focused window
-- >> updatePointer (Relative 0.99 0.99) -- moves pointer to lower right corner of focused window
-- , manageHook = manageDocks <+> myManageHook
, manageHook = manageSpawn <+> manageDocks <+> myManageHook
, startupHook = setWMName "LG3D"
-- >> spawnHere "trayer --edge top --align left --SetDockType true --SetPartialStrut true --expand true --width 6 --transparent true --alpha 0 --tint 0x000000 --height 16"
>> spawnHere "/usr/bin/xscreensaver -no-splash &"
>> spawnHere "udiskie --tray &"
>> spawnHere myBackground
-- >> spawnHere "mpd"
-- >> spawnOn "1:main" "/home/dvm/.xmonad/bin/nload.sh"
-- >> spawnOn "1:main" "/home/dvm/.xmonad/bin/clock.sh"
-- >> spawnOn "1:main" "/home/dvm/.xmonad/bin/visual.sh"
-- >> spawnHere myTerminal
-- >> spawnOn "2:www" myInternet
-- >> spawnOn "3:office" myCalc
-- >> spawnOn "4:rdp" "/home/dvm/.xmonad/bin/usrds006"
-- >> spawnOn "5:editor" myEditor
-- >> spawnOn "6:email" "evolution"
-- >> spawnOn "7:files" "nautilus"
-- >> spawnOn "9:WTL" myWTL
}
------------------------------------------------------------------------
-- Combine it all together
-- A structure containing your configuration settings, overriding
-- fields in the default config. Any you don't override, will
-- use the defaults defined in xmonad/XMonad/Config.hs
--
-- No need to modify this.
--
defaults = defaultConfig {
-- simple stuff
terminal = myTerminal,
focusFollowsMouse = myFocusFollowsMouse,
borderWidth = myBorderWidth,
modMask = myModMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = smartBorders $ myLayout,
manageHook = myManageHook,
startupHook = myStartupHook
}Actually decided to use "TowardsCentre" instead.
For anyone else reading this, i'm currently using xmonad v0.11 and xmobar v0.20.1
Woa! Rayman just saw you updated the post. Thanks for the explanation! Going to have to sit on that one to reread it cuz it just went over my head. Thanks for updating. I'll try your suggestion too, looks cleaner.
Thank you all for your time.
-Dave
Offline
Woa! Rayman just saw you updated the post. Thanks for the explanation! Going to have to sit on that one to reread it cuz it just went over my head. Thanks for updating. I'll try your suggestion too, looks cleaner.
I suggested removing the dollar sign (in my first reply). The code block in my second reply was me trying to explain the problem with the dollar sign (so that would give a similar compile error), but I hope at least that much becomes clear when you reread it.
You wouldn't be the first to find use of the dollar sign confusing, so you can also look elsewhere for not too technical explanations, such as the [haskell] tag on stackoverflow.com.
Offline