Fixing keyboard layouts in Ubuntu. Scarier than it seems.

At the moment of writing this post there is an open bug in Ubuntu, still active in 11.04, that makes your keyboard layout revert to whatever GDM wants. Apparently this is caused by GDM failing to synch with the preferences of the session, so if you change your layout (even if you delete the previous one) the change will be reverted next time you login. There seems to be no fix coming soon, so this magic incantation might work if you have this problem:

sudo dpkg-reconfigure keyboard-configuration

This will ask you a lot of questions about your keyboard, good luck guessing. It kind of reminds me the Windows 95 install process, in which erring the keyboard layout meant it was probably easier to just format and reinstall everything all over again. With some luck, next time you reboot your Ubuntu will actually remember your keyboard preference. If not, just take this as an opportunity to learn a foreign language.

Having keyboard problems? You may also be interested in learning how to activate tildes and accents for a USA keyboard layout in Ubuntu.

Advertisements

Starting Ubuntu in console mode

Like it or not, Ubuntu is so easy to install that even for servers is very comfortable to just mount the iso and create as many virtual machines as you may need. Sometimes you already have an iso for Ubuntu, but are too lazy to download the server version. For those occasions you can either decide to waste precious RAM running a GUI for a server that will never need it, or you can remove all traces of the graphical login. Like this:

sudo update-rc.d -f gdm remove

This will remove GDM from the startup scripts, meaning you can still fire up the graphical interface (*) if you want, but it will start Ubuntu without loading any graphics stuff. This is very useful to save on RAM, startup time and processing power, which even if not that useful for a desktop machine is incredible beneficial when you have several virtual machines running in a single physical server.

(*) More precisely, if you have users that need it. Remember though, if it can’t be done in console mode, it ain’t worth doing.

http://www.makarras.org/2008/06/17/gandalf/


DIY gnome applets

We all know Gnome, and similar GUIs, are there only as a fancy console multiplexer, but even so it’s useful to have widgets in your menus or dockbars to display useful data, like the release date of DNF (*). Gnome has a limited amount of applets from which you can choose, and most of them are crap or limited in their customization. You can always create your own widgets, but that’s a pain in the ass for lazy people like me. Fortunately we lazy people can now use something an order of magnitude more useful than widgets in Gnome : we can use console commands!

Using something called Compa you can add a meta-widget, that will display the output of any CLI program. This means, of course, that you have all the power of the console to use in your custom made widgets. Need to check your laptop’s battery? No need to search for a widget anymore, just cat /proc/acpi/battery/BAT0/state. Need to check the weather? Just wget your favorite forecast page and parse it with grep, sed an awk. OK, maybe that’s a little bit too much.

Once more this proves that anything can be done in console mode – and whatever you can’t isn’t worth doing anyway.

(*) Wow, this article has been written a LONG time ago!


Activating tildes and accents for a USA keyboard layout in Ubuntu

Wow. This time the title of the post may actually be longer than its contents. How do you enable accents and tildes in Ubuntu? You need it to type cool characters like á, Ó or ñ (hey, my name has one of these!).

If you are on Windows I think you have to install a new map, and then guess where the key would be. Or use an alt+something magic spell. In Ubuntu, it works by default you just need to add a compose key, Go to System > Preferences > Keyboard > Options > compose key position, select right alt (or whatever you fancy), there you go, now it works. Try it by typing alt + ‘ + a.


I thought we had deprecated regedit

Guys, I thought we had already agreed on this a long time ago. Windows registry sucks. It’s a pain in the ass.

Why TF is regedit still used in Gnome? I’d switch to KDE, if only I wasn’t so lazy.


Redshift: Cool your monitor

I’ve been trying Redshift the last few days. It’s a really cool (pun intended) and simple program. It just sits there all day long, doing nothing. Yeap, it’s just one more pointless thing on your ps -ef list, up until noon, when it comes to life: it will adjust your monitor’s temperature, gradually, from a cool color to a warmer color.

Say what?
I know what you are thinking. “Why the hell did I eat so much cake?”. And probably something like “WTF? Monitor temperature? Mine is running cool, k thx bye” too. The monitor temperature (color temperature, to be more accurate) is the percieved temperature of an object emiting light at the specific wavelength of that color:

So, a blueish color means a higher temperature, and it’s the natural ambience light color you see during the day. Towards the night the color temperature begins too cool down towards a more orange color. This is the temperature Redshift changes.

So what?
Fair question. After a couple million years our brains got used to seeing a hot color temperature during the day (do I have any reader that old?) so staring at a blue monitor all day will keep you awake all night long, the theory being that switching its temperature towards a reder color will help you sleep at night.

Does it work?
Probably not, but that doesn’t make it any less cool (pun not intended). I think if you fine-tune this app to your sleeping hours it may be of some use, because otherwise you’ll get a very dark screen at 5pm (don’t you people know the timezone in Argentina is FOOBAR’d).


Ubuntu: Dual screen still FUBAR’d

I’m quite sure I have written about this before but I’m too lazy to search for the article right now. Well, dual screens in Ubuntu still sucks. Much less than ever before, granted, but it still works quite bad. In my specific case the whole desktop is shown, in both monitors (which by itself is a huge improvement over previous versions) but the working area is clipped to the notebook’s monitor size. Not nice.

To fix this problem (more like hacking it away, actually) I keep a handy bash script in the top left corner on my desktop:

xrandr --output HDMI-2 --right-of HDMI-1 --mode 1680x1050 --rotate normal

Also, as I have two nice rotable monitors at work it’s nice that now Ubuntu supports actually rotating the picture displayed in the monitor (thanks Ubuntu for coming up to speed… with windows 98, that is). Obviously I keep another script for this, as it doesn’t really work by default:

xrandr --output HDMI-1 --left-of HDMI-2 --mode 1680x1050 --rotate left
xrandr --output HDMI-2 --left-of HDMI-1 --mode 1680x1050 --rotate normal

Even though I love bashing Ubuntu (and bash) I’m quite confident most, if not all, of this issues will be gone in future versions of the OS.


Changing default file associations in gnome

It’s been a long time since I posted a Linux related tip. Not in the mood I guess… well, this is one which really annoyed me, until I found out how easy it is: I hate some of the default file associations in gnome. Movieplayer, for example, is a horrible choice. Breaking and devolving with each new distro release, I have decided to settle with vlc as my default movie player, yet I couldn’t easily change the default file type association. After fiddling around with the thingy in gnome resembling a regedit (ugh) I found out the easy way:

* Right click the file for which you want to change default associations and click properties
* Select “open with” tab
* …
* Profit!


Nice Ubuntu fonts + Vim Tip

manuscrito It’s not unusual to hear someone complain about Ubuntu fonts. Apparently they are ugly. I guess that depends very much on a personal opinion, however not everyone knows there are alternative fonts in the common repositories (I think multiverse even has non-free fonts ported from Windows).

Someone recommended me Inconsolata as a nice programming font (it’s monospaced). I’m using it right now and it’s not bad. Let’s see how can you install it:

sudo apt-get install ttf-inconsolata

incoshow

Easy and it looks even better when used with gVim. You can go to Edit > Select font to change the font preference, however this won’t set a new default for the next time you start gVim. To do this we need to add it to the .vimrc, and again, to do this we need to know the font’s name.

Type “:set guifont?” to see the font’s name. In my case it’s “Inconsolata Medium 14” (I changed size and type). Now add the following to your .vimrc:

if has('gui_running')
     set guifont=Inconsolata Medium 14
 endif

Notice I added a backslash before the spaces, otherwise Vim will try to parse Medium and 14 as separated parameters to “Inconsolata”, which obviously won’t understand. Have fun with your new fonts.


Ubuntu: Dual monitors

There’s nothing better than feeling like a super villain by having a dual monitor setup. OK, three may be better, you probably couldn’t hold back the evil laughter, but my laptop won’t support three screens.

dilbert

Fortunately, in Ubuntu JJ having a dual screen setup is a breeze. Just plug the two monitors and hope it works. Of course, it may not. If that’s the case you can go to System > Preferences > Screen for a nice GUI, which will let you select each screen’s resolution and position. Nothing better for productivity than having your monitors swapped, or even better, flipped upside down.

Well, sometimes “Screen Preferences” won’t work either, too bad. In that’ case you’ll have to get dirty with xrandr. It’s not too difficult but it’s console based (you’re not scared of the console, are you?).

Though the man page for xrandr is a little bit intimidating at first you’ll just have to do it once, so I won’t write about using it, I will just copy & paste a script I keep in my desktop to fix the screen whenever it brakes (my lapop tends to foobar my screen when being docked or undocked, not sure why)

xrandr --output HDMI-2 --right-of HDMI-1 --mode 1680x1050 --rotate normal

I am sure you can figure out the rest on your own – enjoy the dual screen setup!