You are not logged in.

#1 2013-03-03 13:01:52

Reznor
Member
From: BiH
Registered: 2012-06-23
Posts: 78

[xmonad] xmonad.hs misconfiguration

Ok, I am currently using dwm-6.0.1 from community repository, configured to suit my needs. But because I am using it on laptop, I need to get a system tray like on xfce4 to control my wireless connection and volume.

For now, I patched systray, but nothing shows up, no changes. Next, I wanted statuscolors. patch -p1 < statuscolors-6.0.diff only shows that garbage is found.
So, I want something that is similar to dwm, but a little easy to configure. And I found xmonad. I tried xmonad earlier on desktop for a very short time.
If there is a way to use dzen2 instead of dwm bar, please let me know. I tried to execute it in .xinitrc but nothing shows up.

What I want to achieve is to have systray icons like dropbox, nm-applet and volwheel, and conky output. Nothing more than that.
I want to use xmobar.
Here are my:

.xmonad.hs: http://pastebin.com/09nbarSB

.xmobarrc: http://pastebin.com/axKZnxpM

.xinitrc: http://pastebin.com/3mthHf3e

xmonad shows errors in line 153, like some brackets aren't closed properly. I checked them with vim, seems ok, maybe I am missing something. Vim points to lines with mouse and keybindings configurations.

Thanks in advance.

Here's desktop I want to achieve, but with terminus font:

http://1.bp.blogspot.com/-5gmikgegCO4/T … -clean.png

Last edited by Reznor (2013-03-03 13:03:11)


rm -rf /

Offline

#2 2013-03-31 22:50:38

akh
Member
From: Copenhagen, Denmark
Registered: 2012-09-24
Posts: 25

Re: [xmonad] xmonad.hs misconfiguration

Have you had a look in the xmonad config archive?

I use xmonad with xmobar and trayer, but I don't have any experience with conky. I just run trayer from .xinitrc as:

# Start trayer
trayer --edge top --align right --SetDockType true --SetPartialStrut true \
  --expand true --width 3 --transparent true --alpha 0 --tint 0x000000 \
  --height 12 &

# Set the cursor
xsetroot -cursor_name left_ptr
# Set keyboard layout
setxkbmap -layout us -variant altgr-intl
# Start xmonad
exec xmonad

and the following .xmobarrc configuration (with terminus font).

Config { font = "-*-terminus-*-*-*-*-12-*-*-*-*-*-*-u"
       , bgColor = "#000000"
       , fgColor = "#FFFFFF"
       , border = NoBorder
       , borderColor = "#000000"
       , position = TopW L 97
       , lowerOnStart = True
       , hideOnStart = False
       , persistent = True
       , commands = [ Run Date "%a %b %d %Y %H:%M:%S" "date" 10
                    , Run Com "volume.sh" [] "volume" 10
                    , Run Wireless "wlan0" ["-t", "wlan0: <essid> <quality>%"] 10
                    , Run Memory ["-t","Mem: <usedratio>%"] 10
                    , Run Cpu ["-L","3","-H","50","--normal","#429942","--high","#A36666"] 10
                    , Run Battery ["BAT0"] 60
                    , Run CoreTemp ["-t", "Temp: <core0>C / <core1>C"] 10
                    , Run StdinReader
                    ]
       , sepChar = "%"
       , alignSep = "}{"
       , template = " %StdinReader% }{ %coretemp% <fc=#429942>|</fc> %battery% <fc=#429942>|</fc> %cpu% <fc=#429942>|</fc> %memory% <fc=#429942>|</fc> %wlan0wi% <fc=#429942>|</fc> Vol: %volume% <fc=#429942>|</fc> %date%"
       }

This has a static tray size with may be a problem for some people, but I never have more than two icons in it so it doesn't really matter much.

If you are interested I've posted my xmonad.hs configuration file here as well, but actually I think it is way more complicated than what I actually need. It is very much based on the configuration file of Mr.Elendig (as I remember).

-------------------------------------------------------------------------------
-- xmonad.hs
-------------------------------------------------------------------------------
-- Compiler flags --
{-# LANGUAGE NoMonomorphismRestriction #-}

-- Imports --
import XMonad
import qualified XMonad.StackSet as W
import qualified Data.Map as M
import System.Exit
import XMonad.Util.Run (safeSpawn, unsafeSpawn)
import Graphics.X11.ExtraTypes.XF86

-- Actions
import XMonad.Actions.GridSelect

-- Hooks
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName -- Used to impersonate LG3D
import XMonad.Hooks.UrgencyHook
import XMonad.Hooks.InsertPosition

-- Layouts
import XMonad.Layout.NoBorders
import XMonad.Layout.ResizableTile
import XMonad.Layout.Renamed
import XMonad.Layout.Spacing
import XMonad.Layout.Tabbed
import XMonad.Layout.ThreeColumns

-------------------------------------------------------------------------------
-- Main --
main :: IO ()
main = xmonad =<< statusBar cmd pp kb conf
  where
    uhook = withUrgencyHookC NoUrgencyHook urgentConfig
    cmd = "bash -c \"tee >(xmobar -x0) | xmobar -x1\""
    pp = customPP
    kb = toggleStrutsKey
    conf = uhook myConfig

-------------------------------------------------------------------------------
-- Configs --
myConfig = defaultConfig { workspaces = workspaces'
                         , modMask = modMask'
                         , borderWidth = borderWidth'
                         , normalBorderColor = normalBorderColor'
                         , focusedBorderColor = focusedBorderColor'
                         , terminal = terminal'
                         , keys = keys'
                         , layoutHook = layoutHook'
                         , manageHook = manageHook'
                         -- Impersonate "LG3D" to make Maple work
                         , startupHook = setWMName "LG3D"
                         }

-------------------------------------------------------------------------------
-- Window Management --
manageHook' = composeAll [ isFullscreen --> doFullFloat
                         , className =? "MPlayer" --> doFloat
                         , className =? "mplayer2" --> doFloat
                         , className =? "Gimp" --> doFloat
                         , insertPosition Below Newer
                         , transience'
                         ]


-------------------------------------------------------------------------------
-- Looks --
-- Xmobar
customPP = defaultPP { ppCurrent = xmobarColor "#429942" "" . wrap "<" ">"
                     , ppHidden = xmobarColor "#FFFFFF" ""
                     , ppUrgent = xmobarColor "#FFFFAF" "" . wrap "[" "]"
                     , ppLayout = xmobarColor "#FFFFFF" ""
                     , ppTitle = xmobarColor "#00FF00" "" . shorten 70
                     , ppSep = xmobarColor "#F0F0F0" "" " | "
                     }

-- GridSelect
myGSConfig = defaultGSConfig { gs_cellwidth = 160 }

-- Urgent notification
urgentConfig = UrgencyConfig { suppressWhen = Focused, remindWhen = Dont }

-- Borders
borderWidth' = 2
normalBorderColor' = "#333333"
focusedBorderColor' = "#FF0000"

-- Tabs
tabTheme1 = defaultTheme { decoHeight = 16
                         , activeColor = "#a6c292"
                         , activeBorderColor = "#a6c292"
                         , activeTextColor = "#000000"
                         , inactiveBorderColor = "#000000"
                         }

-- Workspaces
workspaces' = map show [1..9]


------------------------------------------------------------------------
-- Layouts --
layoutHook' = tile ||| full
  where
    rt = ResizableTall 1 (2/100) (1/2) []
    tile = renamed [Replace "Tile"] $ smartBorders $ rt
    full = renamed [Replace "Full"] $ noBorders $ Full
    --tab = renamed [Replace "Tab" ] $ noBorders $ tabbed shrinkText tabTheme1
    --spacedTile = spacing 30 $ ThreeColMid 1 (2/100) (1/3)

-------------------------------------------------------------------------------
-- Terminal --
terminal' = "urxvt"

-------------------------------------------------------------------------------
-- Keys/Button bindings --
-- Set modMask to mod4Mask (windows key)
modMask' = mod4Mask

-- Key bindings
toggleStrutsKey :: XConfig Layout -> (KeyMask, KeySym)
toggleStrutsKey XConfig {XMonad.modMask = modMask} = (modMask .|. shiftMask, xK_b)

keys' :: XConfig Layout -> M.Map (KeyMask, KeySym) (X ())
keys' conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  -- Launching and killing programs
  [ ((modMask, xK_Return), safeSpawn (XMonad.terminal conf) [])
  , ((modMask .|. shiftMask, xK_c ), kill)
  , ((modMask, xK_p ), safeSpawn "dmenu_run" [])
  , ((modMask .|. shiftMask, xK_p ), safeSpawn "gmrun" [])
  , ((modMask, xK_b ), safeSpawn "firefox" [])
  , ((modMask .|. shiftMask, xK_t ), safeSpawn "thunderbird" [])
  , ((modMask .|. shiftMask, xK_m ), safeSpawn "urxvt" ["-e", "mutt"])
  , ((modMask, xK_f ), safeSpawn "urxvt" ["-e", "ranger"])

  -- Power management / screen lock
  , ((modMask .|. shiftMask, xK_Delete),
    unsafeSpawn "alock -bg shade:shade=20 -cursor glyph -auth pam >&/dev/null")
  , ((modMask .|. shiftMask, xK_F12 ), unsafeSpawn "systemctl suspend")

  -- Multimedia
  , ((0, xF86XK_AudioRaiseVolume ), safeSpawn "amixer" ["-q", "set", "Master", "2+"])
  , ((0, xF86XK_AudioLowerVolume ), safeSpawn "amixer" ["-q", "set", "Master", "2-"])
  , ((0, xF86XK_AudioMute ), safeSpawn "amixer" ["-q", "set", "Master", "toggle"])
  , ((0, xF86XK_AudioPlay ), safeSpawn "ncmpcpp" ["play"])
  , ((0, xF86XK_AudioNext ), safeSpawn "ncmpcpp" ["next"])
  , ((0, xF86XK_AudioPrev ), safeSpawn "ncmpcpp" ["prev"])
  , ((0, xF86XK_AudioStop ), safeSpawn "ncmpcpp" ["stop"])

  -- Grid
  , ((modMask, xK_g ), goToSelected myGSConfig)

  -- Layouts
  , ((modMask, xK_space ), sendMessage NextLayout)
  , ((modMask .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)

  -- Floating layer stuff
  , ((modMask, xK_t ), withFocused $ windows . W.sink)

  -- Refresh
  , ((modMask, xK_n ), refresh)

  -- Focus
  , ((modMask, xK_Tab ), windows W.focusDown)
  , ((modMask, xK_j ), windows W.focusDown)
  , ((modMask, xK_k ), windows W.focusUp)
  , ((modMask, xK_m ), windows W.focusMaster)

  -- Swapping
  , ((modMask .|. shiftMask, xK_Return), windows W.swapMaster)
  , ((modMask .|. shiftMask, xK_j ), windows W.swapDown )
  , ((modMask .|. shiftMask, xK_k ), windows W.swapUp )

  -- Increase or decrease number of windows in the master area
  , ((modMask , xK_comma ), sendMessage (IncMasterN 1))
  , ((modMask , xK_period), sendMessage (IncMasterN (-1)))

  -- Resizing
  , ((modMask, xK_h ), sendMessage Shrink)
  , ((modMask, xK_l ), sendMessage Expand)
  , ((modMask .|. shiftMask, xK_h ), sendMessage MirrorShrink)
  , ((modMask .|. shiftMask, xK_l ), sendMessage MirrorExpand)

  -- Quit, or restart
  , ((modMask .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
  , ((modMask , xK_q ), spawn "xmonad --recompile; xmonad --restart")
  ]
  ++
  -- 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] %! switch to twinview screen 1/2
  -- mod-shift-[w,e] %! move window to screen 1/2
  [((m .|. modMask, key), screenWorkspace sc >>= flip whenJust (windows . f))
      | (key, sc) <- zip [xK_w, xK_e] [0..]
      , (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]

-------------------------------------------------------------------------------

Last edited by akh (2013-03-31 22:50:56)

Offline

Board footer

Powered by FluxBB