Skip to main content

xmonad settings

One thing that I did like about using gnome was that for most things, it was very discoverable. You click a few menus, try this and that. But with something like xmonad, it's much more configurable for sure but you certainly have to know your way around. So after seaching the internet, I've finally had a setup which I pretty much like. Here it is for future reference. For ~/.xmnonad/xmonad.hs:

import XMonad
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import XMonad.Util.EZConfig(additionalKeys)
import System.IO

myManageHook = composeAll
[ className =? "Gimp" --> doFloat
]

main = do
xmproc <- spawnPipe "xmobar"
xmonad $ defaultConfig
{ terminal = "urxvt"
, modMask = mod4Mask
, borderWidth = 3
, manageHook = manageDocks <+> myManageHook <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP $ xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
} `additionalKeys`
[ ((mod4Mask .|. shiftMask, xK_z), spawn "xscreensaver-command -lock")
, ((controlMask, xK_Print), spawn "sleep 0.2; scrot -s")
, ((0, xK_Print), spawn "scrot")
]

That will, amongs other things, make sure that gimp does not tile but stay float, it will start up xmobar, set my default terminal to urxvt, use the win key for meta (better than using alt since alt is used by most programs), logHook to create an output to be used by xmobar, make sure xmobar stay visible eventhough the screen is full of other programs, set win+shift+z will lock the screen with xscreensaver.

Okay, next is setting for xmobar. This is my ~/.xmobarrc:

Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
, bgColor = "black"
, fgColor = "grey"
, position = TopW L 90
, lowerOnStart = True
, commands = [ Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
, Run Network "wlan0" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Network "eth0" ["-L","0","-H","32","--normal","green","--high","red"] 10
, Run Memory ["-t","Mem: <usedratio>%"] 10
, Run Date "%a %b %_d %Y %H:%M:%S" "date" 10
, Run StdinReader
]
, sepChar = "%"
, alignSep = "}{"
, template = "%StdinReader% }{ %cpu% | %memory% | %wlan0% | %eth0% * <fc=#ee9a00>%date%</fc> @ %hostname%"
}

Ok. This will create the xmobar on the top 90% of the screen. Another 10% we want to reserve for trayer for our programs that require a system tray (eg Pidgin) if we use any. It display a few useful info, but I think on of the most useful ones is the date, and also the output from xmonad which would show what workspace you are currently on (very very useful) and also the title of the window you're currently viewing (not so useful but still nice to have).
Next is I want my urxvt to look nice. So here is the settings for my ~/.Xresources:

URxvt*background: #242424
URxvt*cutchars: BACKSLASH '"'&()*,;<=>?@[]{|}
URxvt*colorUL: #86a2be
URxvt*foreground: #ffffff
URxvt*geometry: 80x25
URxvt.cursorColor: #86a2be
URxvt*internalBorder: 0
URxvt*jumpScroll: true
URxvt*loginShell: true
URxvt*perl-ext-common: default,matcher,searchable-scrollback
URxvt*pointerBlank: true
URxvt*saveLines: 4000
URxvt*secondaryScroll: true
URxvt*scrollBar: false
URxvt*scrollTtyKeypress: true
URxvt*scrollWithBuffer: true
URxvt*termName: rxvt-unicode
URxvt*underlineColor: #86a2be
URxvt*urlLauncher: /usr/bin/firefox
URxvt*color0: #242424
URxvt*color1: #bf7979
URxvt*color2: #97b26b
URxvt*color3: #cdcda1
URxvt*color4: #86a2be
URxvt*color5: #d9b798
URxvt*color6: #a1b5cd
URxvt*color7: #ffffff
URxvt*color8: #cdb5cd
URxvt*color9: #f4a45f
URxvt*color10: #c5f779
URxvt*color11: #ffffaf
URxvt*color12: #98afd9
URxvt*color13: #d7d998
URxvt*color14: #a1b5cd
URxvt*color15: #dedede
URxvt*font: xft:Terminus:pixelsize=15

I found this in a Ubuntu forum. I changed the font to Terminus with size 15 though. Much nicer on the eyes not to have to squint so much trying to read a small font. Then finally to put it all together, I have this in ~/.xinitrc:

xsetroot -cursor_name left_ptr
if xrandr -q | grep -q "VGA1 connected"; then
xrandr --output VGA1 --mode 1024x768 --left-of LVDS1 --output LVDS1 --mode 1366x768
fi
trayer --edge top --align right --transparent true --width 10 --tint 0x191970 --height 12 --expand true --widthtype request --heighttype request --SetDockType true --SetPartialStrut true &
xscreensaver -no-splash &
xrdb -merge ~/.Xresources
exec ck-launch-session xmonad

Amongst other things it detect whether I have an external monitor connected and automatically make xrandr extend to that if there is one. It sets up trayer (using the 10% we preserved earlier). It starts up xscreensaver. It actually load the .Xresources (normally this would be done by the gdm, but since I'm not using the gdm so this is how you load it and finally it launches xmonad. Phew.. That's basically it. As long as this blog post hold up, I can reformat my machine and recover the settings which I pretty much like for xmobar and gang.

Disclaimer: None of these settings are my original. Some of them I've got from xmonad and xmobar faq's and tutorials, others I've got from other various pages on the net.

Comments

Popular posts from this blog

haproxy on Centos 7 with SELinux

Setting up haproxy and varnish with reference to the configuration from these sites: http://sharadchhetri.com/2014/12/20/how-to-install-varnish-4-version-on-centos-7-rhel-7/ https://www.upcloud.com/support/haproxy-load-balancer-centos/ And finally can access plone on the server. But when I check the haproxy status, only client1 can be accessed. All other clients were down with general socket error, permission denied. Googling a bit I finally found out it was due to SELinux. Refer to this page: http://stackoverflow.com/questions/26420729/haproxy-health-check-permission-denied With the solution from that page, I installed policycoreutils-python and tried to run the command given: semanage port --add --type http_port_t --proto tcp 8081 But that command failed with the error that the port was already defined. When I looked it up using: semanage port -l | grep 8081 It belonged to some other type (transproxy_port_t). When I tried to delete the type using: semanage port -d -t transpro…

Installing Centos 7 on HP G7 Server

When I first initially tried it, the installer cannot detect any local hard disk to install to. After much googling found out that it was because a certain driver for the Smart Array Controller is no longer available on Centos 7. To allow for use of the new driver on old hardware, you need to enable the option. Once the DVD has booted and on the first menu screen, highlight the first option and then press tab which would bring you to a command line where you can add additional parameters to boot. Add the following parameters: hpsa.hpsa_allow_any=1 hpsa.hpsa_simple_mode=1 And then press enter to boot. You should now be able to install as you wish. After installation, on the first boot, make sure at the menu, press 'e' to edit the parameters and add them again. Then once booted, go to /boot/grub2/grub.cfg to permanently add the parameters to the menu. Refer to http://serverfault.com/questions/611182/centos-7-x64-and-hp-proliant-dl360-g5-scsi-controller-compatibility and it&#…

Me and my sleep apnea

I have been suffering from sleep apnea for quite a few years already. It started to show when I was still with OSCC some 6 years back when I would sometimes "accidentally" sleep at my cubicle. Early on I just dismissed it as because I was growing fat (we ate a lot at OSCC.. :P and I barely went anywhere except my cubicle) and also because of babies. Oh babies.. those cute little things that keeps you awake at night so that they can be so cute and charming when your friends and relatives come over the next day. So it was dismissed. Later on I got more and more used to sleeping at work, started associating it with my lack of motivation and sometimes feeling of downright depression. And I kept growing fatter and fatter, which I assumed was the reason why I was getting more and more tired.

But then around 2 years ago a friend of mine suggested maybe I've got sleep apnea. And a few other people suggested I go to a sleep clinic and all that. Put it off for quite a while. Until…