Sunday, October 21, 2012

Seeing GTK mouse cursor in KDE?

If you have upgraded to Kubuntu 12.10, you’d notice that KDM has been replaced with LightDM.  LightDM looks pretty, but somehow doesn’t play well with KDE.  One annoying issue I have noticed is that GTK applications run in KDE use GTK mouse cursor under certain circumstances.  When Chrome shows a menu, the mouse cursor changes to a GTK one and it looks jarring.  Turns out, there’s a fix for that.

1. Install LightDM KDE greeter
sudo apt-get install lightdm-kde-greeter
2. Make LightDM use KDE greeter, and all will be well again. To do that, edit the file /etc/lightdm/lightdm.conf and change the value of greeter-session.  The file will look something like this after the change.  (Boldface text is the change you’d have to make.)
[SeatDefaults]
greeter-session=lightdm-kde-greeter
user-session=ubuntu
3. Save the file and test your changes by running LightDM in test mode:
lightdm --test-mode
If LightDM doesn’t open correctly, check if you have made any typing errors in the config file.  If you cannot fix the issue, just restore the file as it was before you edited; you’ll still have the ugly mouse cursor issue, but at least your computer will continue to work.

Sunday, October 7, 2012

Map Windows (aka Super) key to Escape

Did you know I have mapped Caps Lock on my computer to open a new browser tab?  Only today I figured my Vim sessions can be a lot better if I mapped ‘Windows’ key (aka Super key) to Escape.  It can be done by adding a single line to your ~/.Xmodmap file:
! Map left Windows key to Escape.
keysym Super_L = Escape
(Okay, that was two lines, but a little comment in obscure configuration files can be very helpful.)

Also, if you don’t feel like logging out and logging back in after these changes (or if you want to try the change before touching your config file), you can run this on a terminal to have the keybinding take effect immediately:
xmodmap -e 'keysym Super_L = Escape'

Tuesday, September 11, 2012

Prettier fonts in KDE

If you’re a KDE user and have always envied Gnome for its font rendering (especially with fonts like Ubuntu and Ubuntu Mono), read on.

All you need to do is select ‘Enabled’ for System Settings > Application Appearance > Fonts > Use anti-aliasing.  Click on the Configure button and set Hinting style to ‘Slight’.  If you like ClearType style font rendering, enable subpixel rendering too.

Any program that’s opened after this change will use the new font rendering settings.  So you may want to restart your open apps or logout and log back in.

Saturday, September 8, 2012

Disabling Ubuntu menu proxy when not using Unity

Does seeing messages like this on your terminal annoy you?
** (gvim:8016): WARNING **: Unable to create Ubuntu Menu Proxy: Timeout was reached
It sure does annoy me.  Turns out, it’s because the app you’re running is trying to connect its menus to Unity’s “global menu” (or whatever that’s called).  The way to fix this problem would be to disable Unity menu proxy when you’re not using Unity.  Add this to your shell’s startup script (.bashrc, .zshrc, etc):
if [[ $DESKTOP_SESSION != "ubuntu" && $DESKTOP_SESSION != "ubuntu-2d" ]]
then
  export UBUNTU_MENUPROXY=0
fi

Friday, August 31, 2012

My zsh prompt string PS1

Every Unix user with a blog has a post about it: how they have configured their PS1 so their command prompt is almost a mini dashboard that shows everything they’d need to know.  I am no exception.  Even if this post doesn’t really help others, bragging is gratifying, so I’d go on and show how awesome my PS1 is :)

I have been using zsh for a while now, and I am quite happy with it.  I’m a sucker for colours and I was annoyed that I couldn’t take full advantage of my 256 colour terminal because I just didn’t know how to.  So I searched the web and found two good pages.  Combined with some manual-reading I had done, I cooked up my shiny new PS1:
PS1='%(?.%F{245}.%F{124})%2m %F{130}%~ %F{215}%# %f'
Unfortunately, prompt strings are never intuitive, so I’ll do some explaining.
  • %F{colour_code} sets the foreground colour to the specified colour.  Colour code is simply a number in the range 0 to 255 (assuming your terminal supports 256 colours).
  • %f resets the foreground colour to default.
  • %(condn.true_string.false_string) is a conditional expression.  If condn evaluates to true, true_string is emitted; otherwise false_string is emitted.  Like you’d expect, you can have some special strings in condn to mean interesting things.
Deconstructing my PS1
I actually started with something more simple:
PS1='%F{245}%2m %F{130}%~ %F{215}%# %f'
The prompt string starts with the machine name printed in grey.  Then comes the current working directory in a yellow/orange colour, followed by zsh’s % prompt that’s a wee bit brighter than the directory name.  But I wanted to have the exit status of the previous command in my prompt somewhere.  It’s not some information I really need, but I thought it can be a nice-to-have.  But at the same time I didn’t want this information to clutter up my prompt.

I figured I could use make use of colours to differentiate between success and failure of the previous command.  So I changed %F{245}%2m to %(?.%F{245}.%F{124})%2m.  Now, the machine name is printed in grey if the previous command succeeded, and in red if it had failed.  Thus born the prompt string that exactly fits my needs... for now.