Skip to main content

Linux: My xmonad Setup


Since I already blogged about why I think xmonad is interesting, I thought I would take the time to blog about my xmonad setup. I'd like to thank arjuna del toso for his instructions, because that's how I got started.

Start by installing all the software:
apt-get install xmonad libghc6-xmonad-contrib-dev libghc6-xmonad-dev dwm-tools feh
Now, edit /usr/share/xsessions/xmonad.desktop so that it executes "xmonad.start" instead of "xmonad".

Then create /usr/local/bin/xmonad.start:
#!/bin/bash

xrdb -merge .Xresources

gnome-settings-daemon
/usr/lib/gnome-session/helpers/gnome-settings-daemon-helper
gnome-panel &
gnome-screensaver
syndaemon -d -t

# feh --bg-scale /usr/share/backgrounds/warty-final-ubuntu.png &
# xsetroot -solid "#978989" # Lighter gray.
xsetroot -solid "#636161" # Darker gray.

# This must be started before seahorse-daemon.
eval $(gnome-keyring-daemon)
export GNOME-KEYRING-SOCKET
export GNOME-KEYRING-PID

# This is all the stuff I found in "Startup Applications".
/usr/lib/gnome-session/helpers/at-spi-registryd-wrapper &
bluetooth-applet &
sh -c 'test -e /var/cache/jockey/check || exec jockey-gtk --check 60' &
# sh -c "sleep 30; exec /usr/lib/evolution/2.26/evolution-alarm-notify"
# gnome-keyring-daemon --start
# /usr/bin/canberra-gtk-play --id="desktop-login" --description="GNOME Login"
# /usr/lib/gnome-session/helpers/gnome-session-splash
sh -c "sleep 60 && python /usr/share/gnome-panel/add-indicator-applet.py" &
nm-applet --sm-disable &
sh -c "sleep 1 && gnome-power-manager" &
sh -c "sleep 31 && system-config-printer-applet > /dev/null 2> /dev/null" &
# /usr/lib/vino/vino-server &
seahorse-daemon
update-notifier --startup-delay=60 &
xdg-user-dirs-gtk-update
# gnome-at-visual -s

exec xmonad
You might wonder how I came up with all of that. I started with the xmonad documentation. Then, I opened up "Startup Applications" when logged into my GNOME desktop in order to figure out what I wanted to recreate. Some of the things I decided I didn't need. Some of the things had to be tweaked to run outside the context of a normal Ubuntu environment.

Make the script executable:
chmod +x /usr/local/bin/xmonad.start
Now, create ~/.xmonad/xmonad.hs:
import XMonad hiding (Tall)
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.SetWMName
import XMonad.Layout.Circle
import XMonad.Layout.Magnifier
import XMonad.Layout.HintedTile

myLayout = avoidStruts $ hintedTile Tall ||| hintedTile Wide ||| Circle
||| magnifier Circle ||| Full
-- hintedTile listens to application hints, so as not to break gVim.
where
hintedTile = HintedTile nmaster delta ratio TopLeft
nmaster = 1
delta = 3/100
ratio = 1/2

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

main = do
xmonad $ defaultConfig
{ manageHook = manageDocks <+> myManageHook <+> manageHook defaultConfig

-- I used to use: avoidStruts $ layoutHook defaultConfig
, layoutHook = myLayout

-- This hack is necessary to make Java GUIs like NetBeans work. See the FAQ.
, logHook = setWMName "LG3D"
}
To test that you got the syntax right:
ghci ~/.xmonad/xmonad.hs
Note that I decided not to use xmobar, which is a text-based status bar. It's just not my thing, although you might want to read arjuna del toso's instructions and give it a shot.

Last of all, there was one more incredibly esoteric hack that was necessary. If you using xmonad + NetBeans + jVi, then using ":w" to save your file will cause NetBeans to lock up. Weird, I know. The workaround is to edit your jVi preferences to tell jVi not to handle Control-s, but rather to pass it to the IDE. That way, you can use Control-s to save your file instead of using ":w".

Make sure to read the guided tour and check the xmonad FAQ if you have any issues.

Comments

Popular posts from this blog

Drawing Sierpinski's Triangle in Minecraft Using Python

In his keynote at PyCon, Eben Upton, the Executive Director of the Rasberry Pi Foundation, mentioned that not only has Minecraft been ported to the Rasberry Pi, but you can even control it with Python . Since four of my kids are avid Minecraft fans, I figured this might be a good time to teach them to program using Python. So I started yesterday with the goal of programming something cool for Minecraft and then showing it off at the San Francisco Python Meetup in the evening. The first problem that I faced was that I didn't have a Rasberry Pi. You can't hack Minecraft by just installing the Minecraft client. Speaking of which, I didn't have the Minecraft client installed either ;) My kids always play it on their Nexus 7s. I found an open source Minecraft server called Bukkit that "provides the means to extend the popular Minecraft multiplayer server." Then I found a plugin called RaspberryJuice that implements a subset of the Minecraft Pi modding API for B

Ubuntu 20.04 on a 2015 15" MacBook Pro

I decided to give Ubuntu 20.04 a try on my 2015 15" MacBook Pro. I didn't actually install it; I just live booted from a USB thumb drive which was enough to try out everything I wanted. In summary, it's not perfect, and issues with my camera would prevent me from switching, but given the right hardware, I think it's a really viable option. The first thing I wanted to try was what would happen if I plugged in a non-HiDPI screen given that my laptop has a HiDPI screen. Without sub-pixel scaling, whatever scale rate I picked for one screen would apply to the other. However, once I turned on sub-pixel scaling, I was able to pick different scale rates for the internal and external displays. That looked ok. I tried plugging in and unplugging multiple times, and it didn't crash. I doubt it'd work with my Thunderbolt display at work, but it worked fine for my HDMI displays at home. I even plugged it into my TV, and it stuck to the 100% scaling I picked for the othe

Creating Windows 10 Boot Media for a Lenovo Thinkpad T410 Using Only a Mac and a Linux Machine

TL;DR: Giovanni and I struggled trying to get Windows 10 installed on the Lenovo Thinkpad T410. We struggled a lot trying to create the installation media because we only had a Mac and a Linux machine to work with. Everytime we tried to boot the USB thumb drive, it just showed us a blinking cursor. At the end, we finally realized that Windows 10 wasn't supported on this laptop :-/ I've heard that it took Thomas Edison 100 tries to figure out the right material to use as a lightbulb filament. Well, I'm no Thomas Edison, but I thought it might be noteworthy to document our attempts at getting it to boot off a USB thumb drive: Download the ISO. Attempt 1: Use Etcher. Etcher says it doesn't work for Windows. Attempt 2: Use Boot Camp Assistant. It doesn't have that feature anymore. Attempt 3: Use Disk Utility on a Mac. Erase a USB thumb drive: Format: ExFAT Scheme: GUID Partition Map Mount the ISO. Copy everything from