Barebones XMonad config for Ubuntu

After countless hours of dabbling with Xmonad, a few really weird bugs, I got Xmonad to work nicely in Ubuntu 12.04 LTS. If you haven’t used/heard of Xmonad before you should check out Xmonad. It’s a simple and beautiful tiling manager written in Haskell and is configured in Haskell. I hope this post helps someone who gave it a go but backed of due to some of the weird issues relating to window focus in Java apps.

Why

  • Kickass multi-monitor support (xinerama) with per screen workspaces.
  • Simple, minimalistic and fast.
  • Kickass WM layouts that you can configure using Haskell.
  • Amazing keyboard shortcuts to re-align windows and navigate seamlessly.

Known Issues

  • Xmonad has some window focussing issues when it comes to Java apps (hack is available which does not work on JDK7)
  • Doesn’t work well with Unity 3d, so you might have to switch to Unity 2d. Alternatively if you are using classic gnome-shell, it should work well.

How to get it

  • If you are ubuntu you can use the traditional package manager aka apt-get to install.

    sudo apt-get install xmonad
  • You should also get some application launcher(Unity dash works, but there are some performance issues). I use dmenu, it’s simplistic and works (smile)

    sudo apt-get install dmenu

Gnome Session Config

Default install of Xmonad in Ubuntu 12.04 LTS adds the necessary session for Xmonad to work with Gnome with the exception of Default-window manager and DefaultProvider-panel. You can add them by editing the /usr/share/gnome-session/sessions/xmonad.session. You add them to session config which should look something like this.

[GNOME Session]
Name=Xmonad Unity-2D Desktop
RequiredComponents=gnome-settings-daemon;
RequiredProviders=windowmanager;panel;
DefaultProvider-windowmanager=xmonad; #this would have been missing
DefaultProvider-panel=unity-2d-panel; #this would have been missing

Issue with Intellij IDEA:

There is a known issue with XMonad not being able to interact with the GUI components when running under JAVA 7, so simplest would be to run under JAVA 6 and use ICCCMFocus#setWMName “LG3D” to ensure Idea to gain focus and play nicely with Xmonad(It’s included as part of the minimalistic xmonad config.)

Minimalistic Xmonad config

import XMonad
import XMonad.Util.Run
import XMonad.Util.EZConfig (additionalKeys)
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ICCCMFocus
import XMonad.Config.Gnome
import XMonad.Hooks.SetWMName
import XMonad.Actions.DynamicWorkspaces
myManageHook = composeAll (
  [ className =? "Unity-2d-panel" --> doIgnore
  , className =? "Unity-2d-launcher" --> doFloat
  , className =? "gnome-do" --> doFloat
  ])
main =
  xmonad $ gnomeConfig { modMask = mod4Mask
               , startupHook = setWMName "LG3D"
                       , manageHook = manageDocks <+> myManageHook <+> manageHook gnomeConfig
                       , layoutHook = avoidStruts $ layoutHook defaultConfig
                       , logHook = takeTopFocus
                       } `additionalKeys` [ ((mod4Mask, xK_d), spawn "dmenu_run -b")
                                          ]

XMonad Keymap cheat sheet

A vim style cheat sheet for Xmonad is available here.

Using OSX ? Brian McKenna (ex - Atlassian) seems to have patched Xmonad to work nicely under OSX.

Review/Opinion- 2016:Obama’s America

It’s confirmed, we have proof, America will transform itself into a communist country by 2016 and Obama will serve as its most fond dictator - or so is the message of the documentary “Obama’s America 2016”. D Souza and his team attempts to walk through Obama’s past and show us how it influences his actions and policies.  First forty minutes of the documentary explores young Obama’s life, influence of his absentee father and how it shaped his thoughts (base on his  own book - Dreams from my Father). 

He follows his life back to Kenya, Indonesia, about his father’s accidental death and about his mentor who supposedly was a pro-communist. He also points out that Obama Sr. wrote a pro-anticolonial paper and suggested increased taxes upto 100%. So? D Souza who pointed out the similarities with his childhood in India, however D Souza was able to change his opinion on pro-socialistic thought processes that he grew up with, but Obama was influenced by it, even though he hardly lived with his father. He also claims that Obama was pro-seperatist when he grew up in Hawaii, with practically no-evidence whatsoever. All this, is quite a logic stretch.

Apart from these unsubstantiated personal attacks, there are so many factual inaccuracies and careful omissions to construct the innuendo. D Souza suggests that Obama sides with radical Jihadists, that he did not help a friendly regime(Hosni Mubarak, the dictator) wants to reduce military spending(which is already 5 times as much as the next country China), reduce presence of military in Iraq and Afghanistan and hand over the power to rest of the world. Hold on, that pretty much sounds ridiculous. What do conservatives want? Wage war all the time and leave the world in a state of perpetual chaos?

Apart from policies in middle east, in the debate of national debt, he claims that Obama increased the national debt significantly, with the inner lining like, “Hey, America, Obama is trying to take all your money and give it to the poor”. Everybody who does their own fact checking and does not get all the news from fox know that when Obama came into power, bush left out a 1.2 Trillion dollar / year debt and a financial crisis on top of it. All based on the conservative policies that D Souza camp argue for. 

I don’t understand the difficulty that the conservatives have in understanding Obama’s motives as he is well-meaning to the whole world except conservatives. All i can tell is America has never been or wanted to be imperialistic, pro-colonial(American Indepence from British, Hey?) and always has been a entitlement nation(Obama-care won’t make it any different. Trivia - this was first put forward by a conservative republican candidate). 

P.S At-least Obama was not caught in a private dinner video talking how he will not be the president of those 53% Americans who want all these tax cuts. Romney did call 47% of America as lazy and he won’t care about them. Now it could just be gaffe, but I couldn’t resist bringing it up.

Links:

http://en.wikipedia.org/wiki/2016:_Obama’s_America

http://en.wikipedia.org/wiki/Dreams_from_My_Father

http://www.dailykos.net/archives/003167.html

http://en.wikipedia.org/wiki/Socialism_in_India

http://reason.com/archives/2006/06/06/the-rise-and-fall-of-indian-so

http://en.wikipedia.org/wiki/India_Unbound

http://en.wikipedia.org/wiki/Independence_Day_(United_States)

http://www.youtube.com/watch?v=PyJ_k2z-nTA

http://en.wikipedia.org/wiki/Hosni_Mubarak

http://en.wikipedia.org/wiki/List_of_countries_by_military_expenditures

Git Config Hacks

TL; DR - Skip to the end of the page for a quick look at my git config file

Basic hacks

Colors in Git:

Stating the obvious, git supports colors on any ANSI terminal. You can turn on git colors using

[color]
  branch = auto
  diff = auto
  status = auto
[color "branch"]
  current = yellow reverse
  local = yellow 
  remote = green
[color "diff"]
  meta = yellow bold
  frag = magenta bold
  old = red bold
  new = green bold
[color "status"]
  added = yellow
  changed = green
  untracked = cyan

This gives nice tangy colors to your git command outputs.

Change your pretty log format:

Spice up your git log by showing relative times like (4 hours ago than 2010-20-20 10:34 PM). Also the pretty format config below will squash it into a single nicely readable line

[format]
  pretty = format:%Cred%h%Creset - %Cgreen%an -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset
  date = relative

Handy hacks

Changes made yesterday:

Git has got a handy command to see the changes that were committed yesterday. You can see it by typing

git diff "@{yesterday}"

Files changed in a each commit:

Sometimes it’s handy to look at the files changed in each commit. 

git whatchanged

Fairly Advanced hacks

For abbreviated commit log with branch and tag information add the following alias to your ~/.gitconfig

  log1 = log --pretty=oneline --abbrev-commit --decorate

To see the log with graph information and branches/tags where the commit is present, Add the folllowing alias to your ~/.gitconfig

lgn = "!f() { git log --graph --pretty=format:'%Cred%H%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --date=relative $@ | git name-rev --stdin --name-only ; } ; f"

My DotFile

For those who are interested, here is my .gitconfig file

[color]
  branch = auto
  diff = auto
  status = auto
[color "branch"]
  current = yellow reverse
  local = yellow 
  remote = green
[color "diff"]
  meta = yellow bold
  frag = magenta bold
  old = red bold
  new = green bold
[color "status"]
  added = yellow
  changed = green
  untracked = cyan
[alias]
  y = diff "@{yesterday}"
  w = whatchanged
  c = commit
  st = status
  dc = diff --cached
  co = checkout
  lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
  lgn = "!f() { git log --graph --pretty=format:'%Cred%H%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --date=relative $@ | git name-rev --stdin --name-only ; } ; f"
  log1 = log --pretty=oneline --abbrev-commit --decorate

[format]
  pretty = format:%Cred%h%Creset - %Cgreen%an -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset
  date = relative

Long way to go!

Take the case of Shanti, a silver medal winner who protected her gender identity. She was stripped of her medals and laurels when she failed gender test in Doha. Unable to work elsewhere as a coach nor find herself a federal job, the medal winner now does hard labour making as much as 4$ a day. Worse part is the constant humiliation that she has been subject too just because of what she is, rather than her achievements.

The situation is not much different for other under privileged groups. The country does not count physically challenged in national census nor keeps track of their unemployment figures. While Western countries are fighting for equal marriage rights, countries like India even fail to recognize them. Only in 2009 was homosexual consensual sex was legalised by overturning the 150 year old law. Judge in his closing statement insisted that - “It cannot be forgotten that discrimination is antithesis of equality and that it is the recognition of equality which will foster the dignity of every individual.”

A country that boasts of a civilisation nurtured by harmony for at-least a few thousand years and whose citizens who are smug about the amazing achievements that india was capable of in the past, this is a shame. Is it difficult to embrace such people with love and recognise them for what they have achieved?

Inspired by the TOI article

Update:

Looks like somebody is listening. Also GAIL has announced 1 Lakh INR as a relief fund.

Will google drive succeed?

There has been lot of fuzz around the interwebs about the launch of google drive. Google is a late entrant into the online personal file syncing business while competitors like box.net and dropbox are well established and asserting dominance. Is it just another me-too product from google is it something that google values and cherishes?


Google has asserted in the past that the concept of files is dead and how it shuttered the near complete GDrive project which provided a tight integration between the local file system and online filesystem. What led google to change it’s minds about the file syncing market? As Sundar Pitchai points out, google drive is a natural evolution of google docs and collaboration being one of its key strengths.  


By taking the concept of filesystem/drive to the App ecosystem, google is taking a bold step into a filesystem less future. Though it is counter intuitive, it enables a whole different class of applications that can be built apart from managing files. It lets you edit documents, presentations, diagrams and much more.  All of it online and the user doesn’t have to care about where the files are stored as long as they can access them.


There are tons of apps in google chrome webstore which lets you open epubs, build mind mapping graphs, video editing(these are available only on the chrome webstore) and lot more. Sooner or later, there will be apps which cover most of the stuff we do, all online and google drive could be the center of all the data that’s being fed. It’s same as the promise of iCloud, except that iCloud is geared towards native apps than web apps.


Google drive is also important to google chrome os which forces the users to shuttle files between online apps back and forth due to a lack of a shared underlying file system. Now, google drive can act like the datasource(if the apps are integrated with google drive), people can create a document in one app and continue editing in another app seamlessly. Google executives have already confirmed that google drive will be merged into chrome os in later builds.


Let’s wait and watch how this plays out for google.

Update: Google drive arrives for chrome os in developer channel.