You are not logged in.
Do you have the xmonad-contrib package installed?
If not, then you don't have DynamicLog installed.
No I had not This explains a lot!.
Anyway, after installing contrib now I got this weird bug: parse error on input `{'
Offline
Probably just an indentation issue, haskell is kinda strict about stuff like that.
This should work.
import XMonad
import XMonad.Hooks.DynamicLog
main=do
xmonad $ defaultConfig
{ terminal = "urxvt"
, modMask = mod4Mask
, borderWidth = 1
}
Edit: Edited the code sample to make it more apparent how indentation should be.
Last edited by myrkiada (2010-06-06 15:42:46)
My Configs @ Github
Offline
Thanks! It works
Offline
Okay, I'm trying to get dzen to work with the statusBar command in DynamicLog. But I simply can't figure it out myself and since it is kinda new I haven't found any configs I could use as reference. My current try is below, if anyone could help me out it would be much appreciated
import XMonad
import XMonad.Hooks.DynamicLog
main = xmonad =<< statusBar "dzen2" tsKey myPP myConf
myPP = defaultPP
{ ppCurrent = "#429942"
}
tsKey XConfig
{ XMonad.modMask = mod4Mask} = (modMask, xK_b)
myConf = defaultConfig
{ terminal = "urxvt"
, modMask = mod4Mask
, borderWidth = 1
}
Offline
What error are you getting?
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
Sorry, I forgot to include them, here they are:
xmonad.hs:4:36:
Couldn't match expected type `PP'
against inferred type `XConfig t -> (XConfig l -> KeyMask, KeySym)'
In the second argument of `statusBar', namely `tsKey'
In the second argument of `(=<<)', namely
`statusBar "dzen2" tsKey myPP myConf'
In the expression: xmonad =<< statusBar "dzen2" tsKey myPP myConf
xmonad.hs:7:22:
Couldn't match expected type `WorkspaceId -> String'
against inferred type `[Char]'
In the `ppCurrent' field of a record
In the expression: defaultPP {ppCurrent = "#429942"}
In the definition of `myPP':
myPP = defaultPP {ppCurrent = "#429942"}
Last edited by paldepind (2010-06-16 11:14:18)
Offline
Bump..
Offline
Offline
Bump..
What is that tskey function for?
Edit: Oh, right, sorry. I'm dumb.
Here's a simple configuration that hopefully does what you want:
-- needed for monitoring state update
import XMonad.Hooks.DynamicLog
-- needed for spawning the pipe
import XMonad.Util.Run
-- the command that runs your bar
myStatusBar = "dzen2 " ++ myDzenOptions
-- general options for your bar; you could also just add them to the myStatusBarLine,
-- but I like everything neat and orderly
myDzenOptions = "<insert your favourite dzen options here>"
-- your pretty printer options
myPP h = defaultPP
{ ppCurrent = dzenColor <foreground color> <background color>
-- you need ppOutput for the pipe later on
, ppOutput = putStrLn h
}
main = do
-- launch the pipe through which you want to pipe stuff
myStatusBarPipe <- spawnPipe myStatusBar
-- launch XMonad
xmonad defaultConfig
{
-- start the logHook with the pipe we specified two lines earlier, so XMonad knows where it should pipe into
logHook = dynamicLogWithPP $ myPP myStatusBarPipe
}
I hope this works…
Edit 2: At the beginning, you might want to use do notation instead of arrow notation, it makes everything a bit more readable (at least it does so from my point of view).
Last edited by Runiq (2010-06-16 12:12:30)
Offline
How should I define the colors in ppCurrent? I've tried a lot of different things but I can't get it to work.
Offline
"#rrggbb" (replace with actuall hex numbers ofcourse)
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
How should I define the colors in ppCurrent? I've tried a lot of different things but I can't get it to work.
As you probably know, dzen needs to wrap strings around something to make it a certain color, e.g. "^fg(#ff0000)blablabla^fg()" for red text. For that, you have the wrap function, e.g.
wrap "^fg(#ff0000)" "^fg()" blablabla
wraps the necessary dzen foreground color stuff around blablabla. Now the cool thing is that you don't need to explicitly add the blablabla string, because that's what your ppCurrent is – it's added automatically if you don't do it manually (thanks to a feature of haskell called partial function application).
Okay, that sounded evilly convoluted. I have this as ppCurrent:
ppCurrent = dzenColor myCurrentFgColor myCurrentBgColor
which I could also write as:
ppCurrent = wrap ("^fg(" ++ myCurrentFgColor ++ ")^fg(" ++ myCurrentBgColor ++ ")") ("^bg()^fg()")
I put the two arguments to wrap in parentheses for (hopefully) better readability. As you can see, dzenColor is just another layer around the "wrap" function; the only thing it does is to add two colors to a string at once, a foreground color and a background color.
Offline
Then why doesn't this work:
ppCurrent = wrap ("^fg(" ++ "#000000" ++ ")^fg(" ++ "#FFFFFF" ++ ")") ("^bg()^fg()")
Offline
Then why doesn't this work:
ppCurrent = wrap ("^fg(" ++ "#000000" ++ ")^fg(" ++ "#FFFFFF" ++ ")") ("^bg()^fg()")
You have used ^fg twice, should be ^fg and ^bg. Also, what's the error output?
That being said, I typed it from the top of my head, so bear with me
Offline
Then why doesn't this work:
ppCurrent = wrap ("^fg(" ++ "#000000" ++ ")^fg(" ++ "#FFFFFF" ++ ")") ("^bg()^fg()")
To the best of my knowledge, the plus signs before and after your string, make it appear to be a variable rather than a value.
so rather than looking for the color denoted by '#000000" it is looking for the value contained in the variable '#000000". And since variables don't start with a pound sign, it outputs an error somewhere, and moves on; or stops, one a the two.
Knute
Offline
the ++ is used to concatenate lists (and strings are lists of characters) so the follow are equivalent:
ppCurrent = wrap ("^fg(" ++ "#000000" ++ ")^fg(" ++ "#FFFFFF" ++ ")") ("^bg()^fg()")
ppCurrent = wrap "^fg(#000000)^fg(#FFFFFF)" "^bg()^fg()"
Runiq just used the ++ to combine "some string" with someVariable so he could declare and reuse colors (strings) by themselves.
Last edited by brisbin33 (2010-06-16 18:57:36)
//github/
Offline
Thank you for that clarification. I wasn't sure quite what they were for, but only saw them around variables, but now it makes sense. Thanks.
Knute
Offline
I'm sorry I'm such a noob, but I still can't get it to work.
My haskel.hs gives this error:
xmonad.hs:19:17:
Couldn't match expected type `String -> IO ()'
against inferred type `IO ()'
In the `ppOutput' field of a record
In the expression:
defaultPP
{ppCurrent = wrap ("^fg(#000000)^bg(#FFFFFF)") ("^bg()^fg()"),
ppOutput = putStrLn h}
In the definition of `myPP':
myPP h = defaultPP
{ppCurrent = wrap ("^fg(#000000)^bg(#FFFFFF)") ("^bg()^fg()"),
ppOutput = putStrLn h}
Offline
I'm sorry I'm such a noob, but I still can't get it to work.
No problem, it's nice to be able to help someone for a change.
My xmonad.hs gives this error:
xmonad.hs:19:17: Couldn't match expected type `String -> IO ()' against inferred type `IO ()
Whoops, typo on my part: It's supposed to be "hPutStrLn" instead of "putStrLn" in ppOutput. After changing that, I got it to compile, and the color option seems to work too.
Offline
BTW, in case anyone wants to see it, here's my xmonad.hs:
-- XMonad configuration file.
import XMonad
-- for elemIndex
import List
import Data.Monoid
import System.Exit
import System.IO
import qualified XMonad.StackSet as W
import qualified Data.Map as M
-- Layout stuff
import XMonad.Layout.IM
import XMonad.Layout.NoBorders
import XMonad.Layout.PerWorkspace
import XMonad.Layout.ResizableTile
import XMonad.Layout.Reflect
-- Hooks
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.EwmhDesktops
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.SetWMName
import XMonad.Hooks.UrgencyHook
-- Utils
-- import XMonad.Util.Loggers
import XMonad.Util.Run (spawnPipe)
------------------------------------------------------------------------
-- Miscellaneous stuff:
myTerminal = "urxvtc"
myModMask = mod4Mask
-- The mask for the numlock key. Numlock status is "masked" from the
-- current modifier status, so the keybindings will work with numlock on or
-- off. You may need to change this on some systems.
--
-- Set numlockMask = 0 if you don't have a numlock key, or want to treat
-- numlock status separately.
--
myNumlockMask = mod2Mask
-- in Db!
myVolStep = "1"
myWorkspaces = ["一","二","三","四","五","六","七","八","九"]
myNormalBorderColor = "#000000"
myFocusedBorderColor = "#ffffff"
-- TODO: Other border colors; for windows that are marked urgent,
-- maybe?
------------------------------------------------------------------------
-- Layouts:
-- smartBorders and avoidStruts are used for all layouts.
--
-- smartBorders removes borders when floated window is fullscreen or when
-- there's only one window on a screen
--
-- avoidStruts leaves enough space for docks wherever they appear.
--
-- GIMP layout is used on workspace 6 only.
myLayout = avoidStruts $ smartBorders $ onWorkspace "六" gimpLayout $ standardLayouts
where
-- List of layouts to use.
standardLayouts = tiled ||| Mirror tiled ||| Full
-- Layout for the GIMP:
-- Uses the left and right edge of the screen for GIMP's toolboxes (if
-- they are present). Apart from that, the usual layouts can be used.
gimpLayout = withIM (0.11) (Role "gimp-toolbox") $
reflectHoriz $
withIM (0.15) (Role "gimp-dock") standardLayouts
-- default tiling algorithm partitions the screen into two panes
tiled = ResizableTall nmaster delta ratio slaves
-- The default number of windows in the master pane
nmaster = 1
-- Default proportion of screen occupied by master pane
ratio = 1/2
-- Percent of screen to increment by when resizing panes
delta = 3/100
-- ??
slaves = []
------------------------------------------------------------------------
-- Window rules:
-- To match on the WM_NAME, you can use 'title' in the same way that
-- 'className' and 'resource' are used below.
myManageHook = composeAll
[ className =? "MPlayer" --> doFloat <+> doShift "四"
, className =? "feh" --> doFloat
, className =? "Ario" --> doShift "四"
, className =? "Ossxmix" --> doShift "四"
-- TODO: Copy galculator to different workspaces
, className =? "Galculator" --> doFloat
, className =? "Firefox" --> doShift "一"
, className =? "Gimp" --> doShift "六"
, className =? "mednafen" --> doFloat <+> doShift "五"
]
------------------------------------------------------------------------
-- Event handling
-- Defines a custom handler function for X Events. The function should
-- return (All True) if the default handler is to be run afterwards. To
-- combine event hooks use mappend or mconcat from Data.Monoid.
myEventHook = mempty
------------------------------------------------------------------------
--
-- TODO: Urgency hook config
------------------------------------------------------------------------
-- Status bars and logging
-- Perform an arbitrary action on each internal state change or X event.
-- See the 'XMonad.Hooks.DynamicLog' extension for examples.
--
-- General status bar options
myStatusBar = "dzen2 -w 800 -ta l " ++ myDzenGenOpts
-- General dzen options
myDzenGenOpts = "-fg '" ++ myGeneralFgColor ++ "' -bg '" ++ myGeneralBgColor ++ "' -fn '" ++ myFont ++ "'"
-- Icons
myIconPath = "/home/runiq/.config/dzen2/icons/"
-- Fonts
myFont = "Meguri P-9:bold"
myJapaneseFont = "Meguri P-14:bold"
mySymbolFont = "DejaVu Sans-9"
-- Colors
myGeneralFgColor = "#ffffff"
myGeneralBgColor = "#000000"
myCurrentFgColor = "#ffffff"
myCurrentBgColor = "#000000"
myVisibleFgColor = "#1994d1"
myVisibleBgColor = "#000000"
myHiddenFgColor = "#1550aa"
myHiddenBgColor = "#000000"
myHiddenNWFgColor = "#888888"
myHiddenNWBgColor = "#000000"
myUrgentFgColor = "#ff0000"
myUrgentBgColor = "#000000"
myTitleFgColor = "#ffffff"
myTitleBgColor = "#000000"
myLayoutFgColor = "#1994d1"
myLayoutBgColor = "#000000"
mySep = " "
myWsSep = " "
-- Aaand here it comes!
-- TODO: Somehow put those redundant λ functions into one function
myPP h = dzenPP
{ ppCurrent = wrapFont myJapaneseFont . dzenColor myCurrentFgColor myCurrentBgColor
, ppVisible = wrapFont myJapaneseFont . dzenColor myVisibleFgColor myVisibleBgColor . \y -> ("^ca(1,xdotool key super+" ++ (currentWsIndex y) ++ ")" ++ y ++ "^ca()")
, ppHidden = wrapFont myJapaneseFont . dzenColor myHiddenFgColor myHiddenBgColor . \y -> ("^ca(1,xdotool key super+" ++ (currentWsIndex y) ++ ")" ++ y ++ "^ca()")
-- , ppHiddenNoWindows = const "" -- not needed
, ppUrgent = wrapFont myJapaneseFont . dzenColor myUrgentFgColor myUrgentBgColor . dzenStrip . \y -> ("^ca(1,xdotool key super+" ++ (currentWsIndex y) ++ ")" ++ y ++ "^ca()")
, ppSep = mySep
, ppWsSep = myWsSep
, ppTitle = dzenColor myTitleFgColor myTitleBgColor . shorten 50
, ppLayout = wrapClickable "space" . dzenColor myLayoutFgColor"" .
(\x -> case x of
"ResizableTall" -> wrapBitmap "dzen_bitmaps/tall.xbm"
"Mirror ResizableTall" -> wrapBitmap "dzen_bitmaps/mtall.xbm"
"Full" -> wrapBitmap "dzen_bitmaps/full.xbm"
"IM ReflectX IM ResizableTall" -> wrapBitmap "dzen_bitmaps/tall.xbm"
"IM ReflectX IM Mirror ResizableTall" -> wrapBitmap "dzen_bitmaps/mtall.xbm"
"IM ReflectX IM Full" -> wrapBitmap "dzen_bitmaps/full.xbm")
, ppOutput = hPutStrLn h
}
where
-- Returns the current workspace's index from the myWorkspaces list.
-- w = name of the workspace whose index you want.
currentWsIndex w = case (elemIndex w myWorkspaces) of
Nothing -> "1"
Just n -> show (n+1)
-- can be used to make a dzen element clickable
wrapClickable key = wrap ("^ca(1,xdotool key super+" ++ key ++ ")") "^ca()"
-- Some simple convenience functions.
wrapFont font = wrap ("^fn(" ++ font ++ ")") "^fn()"
wrapBitmap bitmap = "^p(5)^i(" ++ myIconPath ++ bitmap ++ ")^p(5)"
------------------------------------------------------------------------
-- Startup hook
-- Set WMName to LG3D for Java apps
myStartupHook = setWMName "LG3D"
------------------------------------------------------------------------
-- Key bindings. Add, modify or remove key bindings here.
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
-- launch a terminal
[ ((modm, xK_y ), spawn $ XMonad.terminal conf)
-- launch dmenu
-- TODO: outsource dmenu options
, ((modm, xK_x ), spawn "exe=`dmenu_path | dmenu -i -r -p \"Execute:\" -y 0 -w 1032 -nb black -nf \"#103060\" -sb black -sf \"#1d53ff\" -fn \"xft:DejaVu Sans-9:Condensed\"` && eval \"exec $exe\"")
-- close focused window
, ((modm .|. shiftMask, xK_c ), kill)
-- Rotate through the available layout algorithms
, ((modm, xK_space ), sendMessage NextLayout)
-- Reset the layouts on the current workspace to default
, ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
-- Resize viewed windows to the correct size
, ((modm, xK_n ), refresh)
-- Move focus to the next window
, ((modm, xK_j ), windows W.focusDown)
-- Move focus to the previous window
, ((modm, xK_k ), windows W.focusUp )
-- Move focus to the master window
, ((modm, xK_m ), windows W.focusMaster )
-- Swap the focused window and the master window
, ((modm, xK_Return), windows W.swapMaster)
-- Swap the focused window with the next window
, ((modm .|. shiftMask, xK_j ), windows W.swapDown )
-- Swap the focused window with the previous window
, ((modm .|. shiftMask, xK_k ), windows W.swapUp )
-- Shrink the master area
, ((modm, xK_h ), sendMessage Shrink)
-- Expand the master area
, ((modm, xK_l ), sendMessage Expand)
-- Push window back into tiling
, ((modm, xK_t ), withFocused $ windows . W.sink)
-- Increment the number of windows in the master area
, ((modm , xK_comma ), sendMessage (IncMasterN 1))
-- Deincrement the number of windows in the master area
, ((modm , xK_period), sendMessage (IncMasterN (-1)))
-- Quit xmonad
, ((modm .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
-- Restart xmonad
, ((modm , xK_q ), spawn "xmonad --recompile; xmonad --restart")
------------------------------------------------------------------------
-- my own keybindings
-- Control MPD
, ((modm , xK_Left ), spawn "mpc prev")
, ((modm , xK_Right ), spawn "mpc next")
, ((modm , xK_Down ), spawn "mpc toggle")
, ((modm , xK_Up ), spawn "mpc random")
-- The following are XF86* keybindings. The weird hex strings are
-- keycodes for XF86AudioMute, XF86AudioLowerVolume, XF86RaiseVolume.
-- Look 'em up in /usr/include/X11/XF86keysym.h.
--
-- Toggle between Mute and non-mute
, ((0 , 0x1008FF12), spawn "ossmix misc.front-mute toggle")
-- I tend to hit both the Fn and the Super key, so here goes nothing
, ((modm , xK_F3 ), spawn "ossmix misc.front-mute toggle")
-- Lower volume by <myVolStep> Db
, ((0 , 0x1008FF11), spawn ("ossmix vmix0-outvol -- -" ++ myVolStep))
-- I tend to hit both the Fn and the Super key, so here goes nothing
, ((modm , xK_F4 ), spawn ("ossmix vmix0-outvol -- -" ++ myVolStep))
-- Raise volume by <myVolStep> Db
, ((0 , 0x1008FF13), spawn ("ossmix vmix0-outvol -- +" ++ myVolStep))
-- I tend to hit both the Fn and the Super key, so here goes nothing
, ((modm , xK_F5 ), spawn ("ossmix vmix0-outvol -- +" ++ myVolStep))
-- Shrink slave windows
, ((modm .|. shiftMask, xK_h ), sendMessage MirrorShrink)
-- Expand slave windows
, ((modm .|. shiftMask, xK_l ), sendMessage MirrorExpand)
]
++
-- mod-[1..9], Switch to workspace N
-- mod-shift-[1..9], Move client to workspace N
[((m .|. modm, k), windows $ f i)
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
, (f, m) <- [(W.view, 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
-- No greedyView --> no swapping of workspaces (which is weird anyway)
[((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
| (key, sc) <- zip [xK_w, xK_e, xK_r] [1,0,2]
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
------------------------------------------------------------------------
-- Mouse bindings: default actions bound to mouse events
--
myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
-- mod-button1, Set the window to floating mode and move by dragging
[ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
>> windows W.shiftMaster))
-- mod-button2, Raise the window to the top of the stack
, ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
-- mod-button3, Set the window to floating mode and resize by dragging
, ((modm, button3), (\w -> focus w >> mouseResizeWindow w
>> windows W.shiftMaster))
-- you may also bind events to the mouse scroll wheel (button4 and button5)
]
------------------------------------------------------------------------
-- Now run xmonad with all the defaults we set up.
main = do
-- Spawns dzen as specified in myStatusBar
myStatusBarPipe <- spawnPipe myStatusBar
-- Spawns the other statusbar, which is fed from outside script
-- TODO: Is it necessary to do this in XMonad?
-- myOtherBarPipe <- spawnPipe myOtherBar
xmonad $ withUrgencyHook NoUrgencyHook $ ewmh defaultConfig {
-- simple stuff
terminal = myTerminal,
modMask = myModMask,
numlockMask = myNumlockMask,
workspaces = myWorkspaces,
normalBorderColor = myNormalBorderColor,
focusedBorderColor = myFocusedBorderColor,
-- key bindings
keys = myKeys,
mouseBindings = myMouseBindings,
-- hooks, layouts
layoutHook = myLayout,
manageHook = myManageHook,
handleEventHook = myEventHook,
logHook = dynamicLogWithPP $ myPP myStatusBarPipe,
startupHook = myStartupHook
}
Offline
I got it working now. No errors
Just one more thing: Isn't XMonad supposed to automatically add a space in the top of the screen for dzen? Because currently my dzen is just laying on top of the other windows..
Offline
Use avoidStruts. Or even better, use the statusBar function.
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
Use avoidStruts. Or even better, use the statusBar function.
That was actually what I tried in the beginning (see my post #329), but i couldn't make it work.
Offline
Thanks, Mr. Elendig, for making me remember the statusBar function. Now I wonder why I bothered with ppOutput and spawnPipe and couldn't get it to work…
Offline
paldepind: Du skal bare blive ved.*
I figured out how to configure XMonad but not to program Haskell - is that fail or partially win?
* Just keep at it.
Offline