anderstornvig.dk

Where’s your head at?

Using Mozilla Weave with Vimperator enabled in Firefox

with 2 comments

Vimperator

I’ve used Vimperator for about a year and a half now and I’m very happy with it. For those who don’t know what Vimperator is, here’s from wiki:

Vimperator is a Mozilla Firefox extension designed to provide a more efficient user interface for keyboard-fluent users. The design is heavily inspired by the Vim text editor, and the authors try to maintain consistency with it wherever possible.

I never used it because of its similarity with Vim, but simply because it makes browsing the web exactly the experience I want it to be. Highly recommendable.

Some times though, Vimperator has a hard time adjusting its philosophy to its surroundings. Take for instance the shortcut features in Web 2.0 applications like Gmail, Google Reader, etc. The solution to this has been to temporarily disable the Vimperator key bindings by pressing Ctrl-z in normal mode.

The new and fancy Mozilla Weave project is no exception.

Mozilla Weave

Weave Sync is a brand new synchronization tool, still under heavy development. You can do lots of sync stuff between Firefox browsers but I mainly just want to use it for synchronizing the tabs I have open on my laptop and my desktop computer.

So, the only way in which Weave can represent the synchronized tabs at the moment is in an option in the top menu bar, “File, Edit, …” you know. But the problem  is that this menu is gone when using Vimperator (at least in the default setting) because you can do everything with the keyboard.

The vague fix

There’s nothing fantastic about the fix. It’s just a small setting in Vimperator that makes it possible to access “History->Tabs From Other Computers” in the top menu bar. I found it in the manual (:help).

Assuming that you have installed Weave yourself and are now setting in Firefox with the Vimperator addon enabled, simply write :set go+=m to enable the top menu bar on the fly. To add the setting permanently, put “set go+=m” in your ~/.vimperatorrc.

If you want to know more of the go (for guioptions) option you can investigate the manual. It allows you to enable or disable most elements in the regular Firefox GUI.

That’s the best I can come up with. For the future I hope to see a better representation of the synchronized tabs, perhaps some button in the status bar. A feature to restore an entire session from another computer would also be cool.

Written by Anders Tornvig

July 27, 2009 at 16:46

My visit at CERN

leave a comment »

As part of my summer vacation with my parents I had the chance to swing by CERN in Geneva, Switzerland. A place I’ve been wanting to go for a long time.

CERN

If you don’t know what CERN is, here’s a quick run-down by wiki and myself:

CERN is the world’s largest particle physics laboratory, situated in the northwest suburbs of Geneva on the Franco-Swiss border, established in 1954.[1] The organization has twenty European member states, and is currently the workplace of approximately 2,600 full-time employees, as well as some 7,931 scientists and engineers (representing 580 universities and research facilities and 80 nationalities).

The Large Hadron Collider

Besides being the birthplace of the World Wide Web, the biggest and probably best known project at CERN is the Large Hadron Collider (LHC) as I mentioned in a post a while ago. The LHC is a particle accelerator designed to smash particles travelling nearly at the speed of light together to recreate the conditions present at the very beginning of the universe, the Big Bang.

ATLAS

The biggest experiment making use of the LHC is ATLAS, occupying around 2000 scientists and engineers round the globe. ATLAS is a humongous particle detector wrapped around the LHC tunnel, which detects and carefully stores (using a state of the art computer grid) what is present before, while and after a particle collision. The data generated will hopefully in the near future serve as empirical evidence proving or revolutionising old theories of physics, and lay the basis for many new ones.

My experience

I hope I succeeded in convincing you that this place is kind of a big deal, at least in the world of science. Spots for visits are popular so you’ll have to book your visit long time in advance if you want to go. We’re talking several months. For me, being only myself, about one month turned out to be enough.

Outside one of the characteric buildings of CERN above ground. The blue thingy is a huge magnet exactly like the ones used to create a magnetic field in the tunnel a hundred metres below strong enough to accelerate particles to nearly the speed of light. I apologize for the poor photo.

Outside one of the characteric buildings of CERN above ground. The blue thingy is a huge magnet exactly like the ones used to create a magnetic field in the tunnel a hundred metres below strong enough to accelerate particles to nearly the speed of light. I apologize for the poor photo.

So, Friday 24-07-2009 at 10am I went. The visit lasted for a little more that two hours.

The tour was given by an English experimental particle physicist who had been there for years helping out on some component of ATLAS. He carried a laptop, had a big hole in his pocket through which his wallet nearly fell out, wild hair and talked really fast about really complex stuff. I guess he fitted the stereotype pretty well. You could feel that he was excited about his work and the possibility of discovering something really big.

Since visitors are not allowed in the experimental areas these times, the tour was limited to a couple of films, a couple of slide shows, questions and some of the buildings above ground.

The most interesting part were definitely the lots of questions asked, mainly concerning particle physics. I was at the visit with a bunch of American and Scottish students of physics, and they managed to ask about some interesting stuff, some of it way above my humble knowledge of physics.

Topics touched were big bang, the lack of proof for the standard model, how the Higgs field gives elementary particles mass, what the Higgs boson is expected to be, the actual detection of particles, elementary particles in general, mass and how we have no idea what gravity is, matter, antimatter, black holes, the LHC, life, the universe and everything. Moreover, I was very excited to hear about the gigantic computer grid set up, primarily at CERN but also around the whole world, to support the enormous amount of data analysis necessary to achieve meaningful results from particle collision. In 2004 there were over 5000 computers in the CERN part of the grid, all set up in a center 100 meters below the surface of earth (we saw pictures). Also, hundreds employed only with monitoring that everything is working as intended. Fascinating stuff, especially because the building of it is expected to contribute greatly to the “new” World Wide Web.

Obviously, none of the topics were discussed very much in-depth because of the time frame. But it was there and once again, I felt like studying physics.

In conclusion, because I wasn’t able to see the LHC underground, (except through 3d glasses on a projector) I’d like to go back. We were told that the LHC would be turned off about once every a year in the future. During those off-periods it will be open for visitors again, and I’ll be there.

Written by Anders Tornvig

July 26, 2009 at 19:56

Posted in Science

Tagged with , , , , , , ,

Mapping multimedia keys in Linux

with one comment

By default no “extra” keys have ever worked on my Arch Linux installs. Today I made an effort for solving that and I succeeded primarily on the basis of this forum thread, this blog post, this article and Extra Keyboard Keys in Xorg on the ArchWiki. The task is simple:

Adjust the output volume on my computer when I press the multimedia keys (play, mute, volume up, volume down) on my keyboard.

How key presses are registered and handled (simplified)

So what happens on the inside when you press the keys on my keyboard? Well, each key press is recognized by the X server as an X event. When an event is registered the X server executes a routine assigned to that specific event. E.g. if the letter “k” is pressed it will simply echo a “k” to the application that is listening for keyboard input. This “application” is usually the window manager running on top of the X server and when the window manager registers the keyboard input it will pass it on to the application which has focus right now. Could be Firefox. Let’s have a small ASCII flowchart to sum up the example. Firefox has focus, runs inside the window manager and the window manager runs on top of the X server.

The user presses the key "k" inside Firefox ->
The X server registers the "k-key-pressed"-event ->
The X server passes the event to the window manager ->
The window manager passes the event to Firefox which has focus ->
The letter "k" is written into the address bar, a textarea, whatever.

Brilliant. Now, what happens if there’s no X server routine assigned to a specific X event? Nothing. This is exactly the reason why the multimedia keys does not work in my X by default on Arch Linux, thus the problem we are going to address in the following. Before that I should say that the problem is not distribution nor window manager related. You’ll encounter it on any installation where the X server is not set up properly or there’s no dummy application taking care of the specific event.

Identify keycodes for multimedia keys
Each key on your keyboard has a keycode assigned within the X server whether there’s a routine assigned for it or not. First we need to find out which keycodes Play, Mute, Volume up and Volume down have. We can do this by running xev inside a terminal instance running in X. You’ll most likely have xev already, if not then install it. When you have it running, press the four keys shortly right after each other. Look for output similar to this:

KeyRelease event, serial 28, synthetic NO, window 0x2800001,
   root 0x253, subw 0x0, time 28502634, (263,0), root:(3169,410),
   state 0x0, keycode 172 (keysym 0x1008ff14, XF86AudioPlay), same_screen YES,
   XLookupString gives 0 bytes:
   XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x2200001,
   root 0x253, subw 0x0, time 21416440, (235,1), root:(3141,411),
   state 0x0, keycode 121 (keysym 0x1008ff12, XF86AudioMute), same_screen YES,
   XLookupString gives 0 bytes:
   XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x2200001,
   root 0x253, subw 0x0, time 21417224, (235,1), root:(3141,411),
   state 0x0, keycode 122 (keysym 0x1008ff11, XF86AudioLowerVolume), same_screen YES,
   XLookupString gives 0 bytes:
   XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x2200001,
   root 0x253, subw 0x0, time 21417968, (235,1), root:(3141,411),
   state 0x0, keycode 123 (keysym 0x1008ff13, XF86AudioRaiseVolume), same_screen YES,
   XLookupString gives 0 bytes:
   XFilterEvent returns: False

These are the outputs of the four key presses Play, Mute, Volume up and Volume down and I’ve marked the parts relevant to us bold.

Map keycodes to routines for multimedia control in X
Routines for volume adjustments in X is defined by the “labels” XF86Audio*. xmodmap is a small utility that will bind any of your keys to labels by referencing them to keycodes. The procedure for setting it up is simple. Install it if necessary, then create a file .Xmodmap in your home directory and put the keycodes and labels in it. In my case (and probably also yours) the content will look like this.

keycode 172 = XF86AudioPlay
keycode 121 = XF86AudioMute
keycode 122 = XF86AudioLowerVolume
keycode 123 = XF86AudioRaiseVolume

Run

xmodmap ~/.Xmodmap

to activate it in the current session. To make it permanently start when you start X, put the command in your  ~/.xinitrc also.

Bind volume multimedia keys
All of the four keys actually works now when multimedia applications like mplayer, VLC and Rhythmbox have focus in your window manager. But the volume keys currently do not control the ALSA sound system directly (I assume that’s what your using for sound). By adjusting the volume directly in ALSA rather than your player you adjust it globally.

ALSA can be controlled by amixer (you already have amixer if you have ALSA installed), so what we want to do is bind an amixer shell command to our volume keys.

This can be done in many ways and I’m going to share three of them with you here. Two window manager (Xmonad, Awesome) specific ways and one standalone utility (xbindkeys) for doing it. The thing is, if you have key binding support in your window manager already there’s no reason to use a standalone utility for it, but if your window manager does not support or handle key bindings very well, it’s nice to have an alternative.

Xmonad window manager

The Xmonad window manager provides key binding support configurable in the Haskell configuration file ~/.xmonad/xmonad.hs. I’m going to assume that you have one of these already and just tell you what you need to add. Xmonad does not have key names for the ones we’re going to add so we have to refer to their hex value which can be found in the file /usr/share/X11/XKeysymDB. Find the three relevant volume labels and remember their value (yours are most likely identical to mine). Now, add them to the key bindings section in your Xmonad config file. I’ve added the following to my config file.

-- Alsa keyboard control
-- XF86AudioMute
, ((0 , 0x1008ff12), spawn "amixer -q set PCM toggle")
-- XF86AudioLowerVolume
, ((0 , 0x1008ff11), spawn "amixer -q set PCM 2- unmute")
-- XF86AudioRaiseVolume
, ((0 , 0x1008ff13), spawn "amixer -q set PCM 2+  unmute")

If you want you can safely change the PCM channel to ie. Master and/or maybe the lower/raise values. Reload the config file by pressing Mod+q.

Awesome window manager

Accoring to this thread, the following three key bindings should work. Add them to your ~/.config/awesome/rc.lua configuration file.

keybinding({}, "#122", function () awful.util.spawn("amixer -q sset PCM 2dB-") end):add()
keybinding({}, "#123", function () awful.util.spawn("amixer -q sset PCM 2dB+") end):add()
keybinding({}, "XF86AudioMute", function () awful.util.spawn("amixer -q sset Master toggle") end):add()

Again, feel free to change PCM and/or the lower/raise values. I haven’t tried that method myself but they look easier than what I had luck on my laptop in my Awesome days. I used these lines my Awesome config file.

table.insert(globalkeys, key({ }, "XF86AudioRaiseVolume", function () volume("up", tb_volume) end))
table.insert(globalkeys, key({ }, "XF86AudioLowerVolume", function () volume("down", tb_volume) end))
table.insert(globalkeys, key({ }, "XF86AudioMute", function () volume("mute", tb_volume) end))

They assume that you have the volume() function defined somewhere else in the config file. This function is available my Awesome config file.

xbindkeys

In fact, xkeybinds can bind your keycodes directly to your amixer commands, thus skipping the label mumbo jumbo. Very convenient. Another advantage is that it’ll work on any window manager. You only have to install it, refer it to your config file, add it to your ~/.xinitrc and you’re good to go. For now, create the file ~/.xbindkeysrc and put the following in it.

# Vol down
"amixer -q set PCM 2- unmute"
  XF86AudioLowerVolume

# Vol up
"amixer -q set PCM 2+ unmute"
  XF86AudioRaiseVolume

# Vol mute/unmute
"amixer -q set Master toggle"
  XF86AudioMute

I think there’s no reason to explain that, but still, feel free to change PCM and/or the lower/raise values.

Wrapping up

Hopefully you got it working. The same methods can be used to enable other multimedia keys. This article “Enabling the Multimedia Keys on your Keyboard” is very useful for that. Like that article I’d probably recommend the xkeybinds solution in most cases as it is very consistent, feature-full and portable. That said, Xmonad as I use for it now also does a fine job. I’ve had no problems with it, it’s easy and I like the facts that it’s integrated in my window manager. Matter of taste.

Thank you for reading.

Written by Anders Tornvig

May 16, 2009 at 17:01

X crashing with Arch, dual monitor and xorg-server 1.6.1

leave a comment »

After my recent 64-bit install I experienced some instability with X. I narrowed the problem down to: X crashes in a dual monitor setup when I hold down backspace, the arrows, maybe other keys inside any application.

The problem was a little hard to google so I threw the question at the Arch Linux Forum.

It turns out you have to install a patched version of the xorg server. Because I had some trouble figuring out dependencies, etc., here is the procedure I got working:

  1. If you don’t have yaourt installed, install it. If you don’t know what yaourt is, it is a wrapper around pacman that allows you to easily install user contributed packages from AUR. So, go ahead and install it.
  2. You may want to log of X.
  3. Perform the following and final steps. The yaourt command will take a while to execute but keep an eye on it anyway to discover it if any errors occur.
    # pacman -R nvidia xorg-server
    # pacman -S libgl
    # yaourt -S xorg-server-warnaud
    # pacman -R libgl
    # pacman -S nvidia

To you with a similar problem, I hope you will find this helpful.

Written by Anders Tornvig

May 12, 2009 at 00:24

Running Arch Linux 64-bit

leave a comment »

As the Ubuntu Jaunty fever is slowly easing off, I decided to go back to Arch Linux. I simply miss its purity compared to Ubuntu’s.

Once an Archer, always an Archer!

On the old Ubuntu setup I never quite figured a permanent solution for my dual monitor setup and since I installed the Awesome window manager RC, it has been somewhat buggy. Also, in the meantime I’ve more or less commited to another tiling window manager, Xmonad (more on that in another post), so I was planning to switch from Awesome anyway. Bottom line, time to install Arch Linux.

I won’t bore you with the installation details this time but simply say that almost nothing has changed since my post on Installing Arch Linux with Awesome. Well, maybe except for Xorg and its complications with hal. It’s not an Arch Linux specific exception, but excuse me, what a mess? I digress.

So why bother to write this post? Well, to give you a heads up on the Arch Linux 64-bit installation.

Ever since I got my Shuttle PC December 2007, I’ve not been able to make use of all of the 4GB ram available in it. Only about 3.2GB has been available in the 32-bit operating systems I’ve run. Incredibly annoying, but also a well-known and inevitable limitation. Have a look at the post “Dude, Where’s My 4 Gigabytes of RAM” on Coding Horror.

Thus, to try something new and actually take advantage of what I once paid for, I decided to install Arch64. A brief google told me what advantages and more importantly what implications I should expect.

Advantages:

Implications:

  • Flash (in pacman: flashplugin) is going to be crap
  • Java Runtime Environment (in pacman: jre) is going to be crap
  • Buggy multimedia
  • Skype, Wine, Virtualbox
  • Pacman should have 64-bit architectured versions of most which means not all packages

There’s probably a lot more on both sides. I proceded to install it, every step exactly the same as in a regular install. After that, Xorg, Xmonad, browser, text editors, IM clients, multimedia stuff, libraries, basically everything I use if not daily, then weekly.

Guess what, everything worked flawlessly as if I had installed the 32-bit version. Even pacman managed to find 64-bit architectured builds for every package I installed, not just most. Great! Haven’t tried Skype, Wine or Virtualbox yet but I’ve found multiple guides to and examples on people getting it working so I’m not worried. Also, you should have seen the smile on my face when I first fired up top and saw that I had 4GB ram available. Fantastic!

So to end this post I’ll give you the assurance I was looking in my implications/advantages-google, even though it may not be true in some cases:

For what I use my computer for, there has been no implications, only advantages in installing the 64-bit of Arch Linux. You can safely go ahead and try it out if you feel like it and have the right hardware for it.

I honestly don’t know why I waited.

Feel free to post a comment on your Arch64 experience.

Written by Anders Tornvig

May 3, 2009 at 13:08

More on the Web 2.0

leave a comment »

In relation to my last post on “Operating systems and web applications” I’d like to share with you an article I just read.

http://www.guardian.co.uk/technology/2008/sep/29/cloud.computing.richard.stallman

I can’t help but completely agree and realize that I have to go cold turkey on the web applications. Some may even say “go back in time”. Soon!

Written by Anders Tornvig

April 2, 2009 at 18:12

Posted in Tech

Tagged with ,

Operating systems and web applications

with 2 comments

Rant coming your way..!

I use a frighteningly large number of online services/applications/whateveryoumaycallthem. Gmail, Google Reader, Google Calendar, Google Docs, Dropbox, Remember the Milk, GooSync, Twitter, WordPress, Delicious and that’s probably not even all of them.

The big sinner is obviously Google. Even though I’m reluctant to admit it, they make some darn great software – too great to not use. The same is true for the other services. One innovative, beautiful web application after another.

What’s scary is that I’m so dependent on them. I get chills from just thinking about something crucial happening to Google.

But I guess Google has reach a size where reliability will never be a problem. Too many users depend on them and hopefully they are aware enough of their responsibility to not just pull the plug.

The next stage after this concern about Google just pulling the plug is the monopoly concern. Just like Microsoft took over the world through your personal computer, Google is doing it through the web. I guess it can be seen as an advantage that everything is streamlined and so on but I choose to be worried. If Google went down, the world would really just halt. Communication lost, appointments forgot, tasks undone, data gone, etc.. Disaster!

Accepting the fact that the evolution is inevitable and that I’m a sucker for Google and other web services takes me to my next subject.

Operating systems (OSs) are depreciating. I’ve said it before and I’ll say it again:

Give me a browser and a text editor and I’m ready to take over the world myself!

90 percent give or take of the time I spend on a computer I’m either in Firefox or some obscure text editor. True story.

I’m not saying that OSs are becoming unnecessary, just irrelevant for everyday work. Any modern OS can fire up a browser and a text editor, and if that’s more or less all that’s needed on a daily basis, maybe we need to rethink the entire design of modern OSs. Simplify rather than complicate them if you will.

As point of departure though, I can’t fully support this evolvement because of the statements first in this post. I’m simply not comfortable with the thought of people gullibly putting their personal data in the hands of someone/everyone else.

I would like, however, to draw a final perspective that’s not just relevant somewhere in the future, but also today. On any computer you use for regular tasks like mailing, browsing, documenting, if the OS is irrelevant, why not install an open source one for free? It’s just plain ludicrous to pay for an OS you’re not directly using. You use the applications you’re installing on the OS, and any OS can manage most of those applications, also open source ones.

If you’ve read this far, largely agreed with my points, not quite understood this open source thingy, but – sensible as you are – noted that you can get an operating system for free and free yourself from the monopoly that is Microsoft, you’re probably wondering where. My best answer to that question is www.ubuntu.com. Here you can download a free and open source operating system called Ubuntu built upon the Linux kernel. Highly recommendable.

Rant… over…

Written by Anders Tornvig

March 29, 2009 at 15:29