Posts Tagged ‘linux’

Ubuntu as an OS X TimeMachine server

August 19th, 2012

One of the best features of Mac OS X is TimeMachine, a ridiculously easy to use backup system. The downside to TimeMachine is you either have to use an external hard drive or buy Apple’s TimeCapsule backup hardware.

Turns out there’s a third option — use a Linux PC as your backup server.

With Ubuntu Linux 12.04, I highly recommend following this guide, which explains the safest route. Keep in mind it’s completely unsupported by Apple, of course, so if your backups are overwritten with My Little Pony pictures, don’t go complaining to the Genuis Bar.

A couple notes on the guide:

  • Most users can safely ignore the part about Shorewall settings.
  • The guide glosses over user-level security. You could use your normal user account for backups, but you should consider setting up a special user account just for TimeMachine. That way if someone hacks into your Mac, they’ll only have access to your backups and not your entire Linux PC.

Using an Evoluent VerticalMouse 4 on Linux

April 10th, 2012

Evoluent’s VerticalMouse 4 is one of the better ergonomic computer mice I’ve used. It’s comfortable, it doesn’t take much getting used to, and the price isn’t unreasonable.

While it works great on Windows and Mac, the same can’t be said for Linux. The button mappings cause some truly odd behavior, particularly with the scroll wheel.

Fortunately, there’s a quick fix.

First let’s play with xinput to make sure the settings are what you want. The following command will print out a list of input devices on your system:

xinput list

There should be a line that looks something like this:

Evoluent VerticalMouse 4 id=10

The important thing here is the ID number, which in this case is 10. It will vary from one computer to the next.

Now we can assign a new button mapping. I like to keep it simple, so this will only activate the left and right mouse buttons (on either side of the scroll wheel) and will set the scroll wheel to scroll and act as middle click. If you want a different setup, I recommend reading this and this and playing with these values in xinput until your mouse does what you want.

xinput --set-button-map 10 1 3 0 4 5 0 0 0 2 0 0

Note that I bolded the first parameter: as you may have guessed, that 10 is whatever ID you found above.

Got it working? Good. Thing is, xinput will only temporarily set your mouse buttons. Once you reboot, they’re gone.

To make these changes persist we need to create an Xorg settings file. First we’ll need the USB ID of your mouse. The following command will list all the USB devices on your system:

lsusb

One of them should look kinda like this:

Bus 004 Device 004: ID 1a7c:0191 Evoluent VerticalMouse 4

The funny text I bolded is the device ID. (Again, it will likely be different on your system.) Now you can create a config file for your mouse. Note that this works on Ubuntu, perhaps your distro stores configuration files elsewhere.

sudo touch /usr/share/X11/xorg.conf.d/90-evoluent.conf
sudo gedit /usr/share/X11/xorg.conf.d/90-evoluent.conf

Copy and paste the following into the file, remembering to swap out your mouse’s USB ID and the button mapping string (if you changed it.)

Also, note that the button mapping string does NOT start with the device ID you used above; that was only for xinput.

Section "InputClass"
Identifier "Evoluent"
MatchUSBID "1a7c:0191"
Option "ButtonMapping" "1 3 0 4 5 0 0 0 2 0 0"
EndSection

Easy, right? Well okay, not at all. The lack of a good mouse configuration UI is a nasty oversight on modern Linux systems. Someone needs to make one.

How to setup Rhythmbox 2.95 as an Ampache client

April 2nd, 2012

Ampache, for those who don’t know, is a personal streaming music service. It lets you play your MP3s anywhere there’s an internet connection.

You don’t need anything special to play music via Ampache, just a web browser. But certain music applications integrate full Ampache support, which means you can browse all your MP3s from within the app.

On Linux, I use Rhythmbox to play music. There’s an Ampache client for it, but it’s not as easy to install as it should be with newer versions of Rhythmbox.

Here’s what worked for me.

  1. If you have not done so, on your Ampache server set permission to allow XML RPC (Manual is here for complex setups.) For the most basic setup, log into Ampache as an admin. Click the Admin button, then “Add ACL.” In the box that pops up, enter the following:
    • Name: [whatever you like]
    • ACL Type: RPC
    • Start: 0.0.0.0
    • End: 255.255.255.255
    • User: All
    • Remote Key: [leave this blank]
    • Level: Read

    Now hit “Update.”

  2. Make sure Rhythmbox is not currently running.
  3. Install or upgrade to Rhythmbox 2.95 (or 2.96) if you don’t have it already. For Ubuntu Oneiric, you can grab it off this PPA.
  4. If you don’t have it, install Subversion. Check out the code for the Ampache plugin:

    svn checkout http://rhythmbox-ampache.googlecode.com/svn/branches/for_rhythmbox-gtk+3/ rhythmbox-ampache-read-only

  5. Copy the files.

    cd rhythmbox-ampache-read-only/
    mkdir ~/.local/share/rhythmbox/plugins/ampache
    mv * ~/.local/share/rhythmbox/plugins/ampache

  6. Run the installer.

    cd ~/.local/share/rhythmbox/plugins/ampache
    sudo python setup.py install

  7. Now open Rhythmbox.
    • Go to Edit -> Plugins
    • Check the box next to “Ampache Library”
    • With Ampache Library selected, click “Preferences”
    • Enter your server info here.
    • Now close the dialog and double-click Ampache in the Rhythmbox sidebar.

It may take some time to sync with your server, but once it does you should be good to go. Personally I find this plugin to work a lot better than the Amache plugins for Amarok and Banshee, but your mileage may vary.

Updated Aug 2012

Programming in Vala

January 18th, 2011

As some of you may know, I work for an open source software non-profit called Yorba. Our best known product is Shotwell, a photo management application that’s similar to Picasa or iPhoto, but created for Linux. It’s the default photo app these days in both Ubuntu and Fedora.

What many of our users don’t know is we don’t develop our software in C or C++… we use Vala.

So what the hell is Vala?

The cool thing about Vala is that it’s a fully compiled, statically typed OOP language designed to be built for Gtk applications. The syntax is very similar to Java or C#, but the garbage collection is based entirely on reference counting. In other words, you get the simplicity of a modern language with the speed of a fully compiled program. Vala bindings are already available for Gtk, Gdk, GLib, Gee, and many other libraries. Or you can create your own bindings when needed by creating a Vapi file. There’s a documentation program, Valadoc, which generates pretty HTML documentation for your classes.

The entire Vala package is available under an LGPL license, which is a free software/open source license. You’ll never have to worry about Microsoft or Oracle stepping on your toes.

Here’s the “Hello World” app from the Vala tutorial.

class Demo.HelloWorld : GLib.Object {
    public static int main(string[] args) {
        stdout.printf("Hello, World\n");
        return 0;
    }
}

Save your file as hello.vala. You can compile from the command line with:
valac hello.vala
Now watch closely… the Vala compiler actually just creates a .c file! It’s what’s called a “source compiler” in that it converts source code from one language to source code in a different language.

Next, valac automatically invokes GCC to compile the .c file into an executable binary.

Run your demo code with:
./hello

Simple, huh?

Vala syntax includes the language constructs you’d expect in 2011, including:

  • interfaces
  • single inheritance
  • non-nullable variables
  • foreach loops
  • delegates
  • signals
  • reflection
  • built-in multidimensional arrays
  • type inference

There’s plenty more sample code and tutorials on Gnome’s Vala site.

Documentation for some of the most common library bindings is available at Valadoc.org.

Okay, ready for the bad news? Despite being a relatively feature-complete language, there’s really no perfect IDE for Vala yet. If you’re used to powerful graphical debuggers, class browsers, and jumping around the code like in Eclipse and Visual Studio, you’re out of luck.

The only Vala IDEs at the moment are:

  • MonoDevelop: A great start, but for the features it’s rather heavy.
  • Valide: I was never able to get this one to even compile! But the screenshots look promising.
  • Valencia: This is Yorba’s GEdit plugin, which provides only barebones Vala functionality on top of GEdit, including jump to definition and autocomplete.

So there you go, that’s Vala. It’s still a young language, but it takes away the headaches of developing Gtk apps in C, and it doesn’t have the uncomfortable legacies of C++. Give it a shot!

5 things Windows does right

June 6th, 2010

We’ve all heard a lot of bad news about Microsoft over the past decade, especially the past few years. Security problems, broken hardware drivers, annoying interface changes, confusing security features, etc.

It’s gotten to the point where it’s tough to think of anything good about Windows, aside from the fact that “it’s there” and there’s a lot of games for it.

But I see some good things about Windows where Microsoft has done the right thing, and done it consistently. Let’s look at those.

1. Backwards compatibility

Let’s say you’re running a business. You have a very important application that’s 20 years old, no longer supported, and there’s no budget to upgrade. What to do?

Well if it was written for Windows (or even Microsoft’s previous operating system, DOS) there’s a good chance it still works perfectly fine today. In fact, if it doesn’t require any special hardware, it’s basically guaranteed to work. This saves you a lot of money on hiring people to write a new application.

Backwards compatibility is a key feature of Windows. Even on a 64 bit Windows 7 machine, you can run applications designed for 32-bit Windows 2000 by design.

I’m not sure if it’s more strange that Microsoft considers this a mandatory feature, or that Linux and Apple don’t bother. There’s certainly no technical reason NOT to support old applications, so this is definitely something Windows gets right.

2. Forwards compatibility

With the latest Visual Studio you can still write applications for Windows 2000 out of the box. Although the underlying architecture of Windows has changed quite a bit over the years, the core APIs are binary compatible.

Sure, it takes some effort to avoid the convenient new APIs introduced in XP and Vista, but it’s by no means impossible.

3. Free Service Packs

Whereas Apple charges for small upgrades to the OS, Microsoft gives them away for free in the form of service packs. These upgrades are designed to change as little as possible under the hood, but bring in new features, new applications, and security updates.

And while some service packs have presented problems, Microsoft has usually been quick to fix these issues with incremental patches through Windows Update (aka Microsoft Update.)

4. Hardware drivers

Something most Windows users don’t even notice — when they work — is hardware drivers. Windows consistently ships with an amazing array of hardware drivers for just about everything. The major complaints tend to be printers and WiFi, where the manufacturer may need to supply something specific.

But this is one area where Windows really shines compared to the competition. On Linux, hardware drivers can be impossible to find or tricky to install. Linux users often encounter issues with graphics *cough* ATI *cough*. Apple avoids the problem entirely by shipping only custom hardware; an easy solution that bypasses the issue.

5. Multimedia and server in one OS

Linux is optimized for use as a server. Mac OS is optimized for multimedia.

But Windows? It does a pretty good job at both, out of the box, without (much) configuration. Somehow they’ve optimized the timing in the kernel to allow for both. This is not as trivial as it sounds.

Multimedia requires processing a rapid fire of tiny pieces of information. Servers require processing large chunks of information at unpredictable intervals. It’s not easy to adjust your timing to do both, but Windows pulls this off without a hitch.

Conclusion:

Windows isn’t all bad! Microsoft goes out of their way to make Windows a stable, consistent OS that runs a wide variety of applications. Keep this in mind next time a UAC prompt makes you want to put your fist through your monitor.

Fixing Linux when it “gave up waiting for a root device”

January 26th, 2010

Recently I was installing Kubuntu 9.10 (also known as Karmic Koala) when my system refused to boot. I was informed that my system had “given up waiting for a root device.”

But there’s a simple solution!

I suspect many of you may be in a similar situation and that’s why you’re here. Let’s first consider the “gave up waiting for root device” error.

What does it all mean? Well, your boot loader was trying to see if your main hard drive (i.e. “root device”) was starting up. But guess what? It didn’t start — probably because it wasn’t there.

“But I didn’t take it out!” you exclaim, because you’re not stupid enough to take your hard drive out of your computer and then be surprised when it doesn’t work.

No, the problem is because your computer couldn’t find your drive.

You’ve got to fix the boot loader, and you have two options. If you’re lucky like me, your computer drops to a “Busy box” shell on this type of error. This is a sort of bare minimum shell that does just enough to get your computer running. If this happens, you’ll see some instructions on the screen regarding Busy box.

Use Busy box to access your drive
Here’s what to do if you’re using the Busy box command line:

  1. Create a new folder to mount your hard drive.
  2. mkdir /drive

  3. Mount your hard drive to the folder you just made.
  4. mount /dev/sda1 /drive

  5. In my example, my hard drive was located at /dev/sda1 and I suspect this is pretty normal. Your drive may be sda2, sdb1, sdd0… who knows! It may take a few tries. If you guessed the number incorrectly, you can always try again by unmounting and then going back to step 2. Here’s how you unmount your drive:

    umount /drive

  6. Make your hard drive the root so we can fix it.
  7. chroot /drive

From here you can use nano, emacs, or vi to fix your problem. Skip below for more info.

Without Busy box
If you’re not lucky enough to get Busy box prompt, you can always boot off of a Linux Live boot CD. The regular Ubuntu install CD can be used in live boot mode, as can Knoppix. When you boot off of that CD you’ll be taken to a full-fledged Linux environment where you can fix your problem in the same way. Your hard drive should be easily accessible, probably with a nice GUI and everything. Just open the drive and you’re ready to go.

What to do next
If you have a similar problem as me, the official Ubuntu 9.10 KarmicUpgrades doc has a resolution.

Otherwise, try Googling around some more. It’s probably a very similar boot loader issue that can be fixed easily once you’ve completed the above steps.