Unused Cycles

June 7, 2010

All of your music anytime, anywhere, with Android and Ampache

Filed under: Ampache, Android, GNU/Linux — Kevin @ 10:44 pm

I recently bought an Android-powered phone (Motorola Droid) and love it to death. I’ll love it even more-so during the fourth quarter when the next version of Android (FroYo, or Frozen Yogurt) comes out. Google’s promised the ability to access your entire music library anytime and anywhere in the new version.

Well, I’m an impatient person, and I’ve got enough music to fill up my 16 GB micro-SD card and then some. I’ve used Ampache in the past to stream music from my laptop at home into the lab in which I was working at the time, so I figured I’d search for “android ampache”. Lo and behold, there are programs in the app market (Amdroid and Lullaby) that are able to connect to Ampache servers.

First, install and configure Ampache. If you’re running Ubuntu, instructions can be found here. If you’re running Windows, the installation may be different, but the configuration should be the same.

Next, install either Amdroid or Lullaby from the Marketplace. I prefer Lullaby, because Amdroid seemed slow and buggy to me. Enter the IP address of your Ampache server as well as your username and password where appropriate in the settings.

If you’re behind a router and you want to set up streaming outside of your LAN, you’ll have to set up port forwarding. If your ISP has you on a dynamic IP address, you may also want to check out a service like DynDNS.

Finally, if you’re on a limited data plan, you may want to set up transcoding to a lower bitrate (and you’ll have to if parts of your library are encoded in OGG or FLAC). To do this, I edited ampache.cfg.php (in /etc/ampache) to hold this information (it may already be in there, you just need to uncomment it):

transcode_m4a           = true
transcode_m4a_target    = mp3
transcode_flac          = true
transcode_flac_target   = mp3
transcode_mp3           = true
transcode_mp3_target    = mp3
transcode_ogg           = true
transcode_ogg_target    = mp3
transcode_cmd_flac      = "flac -dc %FILE% | lame -b %SAMPLE% -S - - "
transcode_cmd_m4a       = "faad -f 2 -w %FILE% | lame -r -b %SAMPLE% -S - -"
transcode_cmd_mp3       = "mp3splt -qnf %FILE% %OFFSET% %EOF% -o - | lame --mp3input -q 3 -b %SAMPLE% -S - -"
transcode_cmd_ogg       = "oggsplt -qn %FILE% %OFFSET% %EOF% -o - | oggdec -Q -o - - | lame -S -q 3 -b %SAMPLE% -S - -"

On Ubuntu, I had to install the following packages to get transcoding working properly: vorbis-tools, mp3splt, faad, lame.

That should be it.  I know it’s not as in depth as my guides usually are, but I’m strapped on time. Enjoy!

UPDATE: iPhone users can have fun too, because I’ve found out that there’s an iPhone app called iAmpache that does the same thing. I’ve tried it out on my iPod Touch and it works great over a LAN, although I can’t comment on how it’ll work on an iPhone over AT&T’s 3G.

Advertisements

May 27, 2010

Make KDE/Qt apps look consistent with GNOME apps in Ubuntu 10.04

Filed under: GNU/Linux — Kevin @ 11:26 am

Well, it’s been a while since I’ve posted, but I’m still around. I just figured out something that’s plagued me for a long time, and it turned out to be really simple.

I’ve always hated how KDE/Qt apps and GNOME/GTK apps look so different. Most people say “just use qtcurve,” but I wanted them to look uniform with the default Ubuntu Ambiance theme. Here’s a(n almost) complete solution, and it should work with Arch Linux, too (I’ll try it later today).

  1. Install System Settings (sudo apt-get install systemsettings)
  2. Go to System->Preferences->QT4 Settings and set Select GUI Style to GTK+
  3. Go to System->Preferences->System Settings, choose Appearance, and set the Widget Style to GTK+
  4. While in System Settings, download this color scheme and import it using the Import Scheme under Colors
  5. Under Fonts, I selected 96 dpi, set all font sizes to 10 (the GNOME default for Ubuntu on my computer), and turned on anti-aliasing
  6. Under Icons, select Ubuntu Mono Dark

The result is pretty consistent as you can see with the screenshot of Amarok below. One small niggle is that the file dialogs for KDE/QT apps are still QT style, but unfortunately I haven’t been able to find a program that does the opposite of KGtk (if you happen to know of one I’d be thrilled to hear about it). The fonts also look a bit different, but it may be a slight difference in the fonts “Sans” used by GNOME and “Sans Serif” used by KDE.

Hope this helps someone. Why Canonical doesn’t do this with stock Ubuntu confuses me.

April 29, 2009

Amarok 1.4 Sync with iPod Touch 2G in Linux

Filed under: GNU/Linux, iPod Touch — Kevin @ 11:22 am

Since I’ve gotten my iPod Touch 2G, I’ve been forced to use iTunes, which I never really liked. Not just because it’s proprietary, but I really never cared for the interface and how it handles playlists. While four months of iTunes usage has warmed me a bit to it, I like being able to choose what application I use, especially because running iTunes means I have to run Windows XP in a Virtualbox virtual machine. Furthermore, I prefer Amarok 1.4 on KDE’s functionality more than I do iTunes or any other music player. Thankfully, with the recent release of the 24kpwn exploit on the iPod Touch 2G which allows an untethered software jailbreak, it’s possible to use Amarok with the iPod Touch 2G!

First a bit of background. The iPod generally uses a file called “iTunesDB” to store locations and tags of all of the files on your iPod. If you put music on your iPod without it being entered into the database, the iPod software won’t recognize it and you won’t be able to play it. Over the years, people have developed support for writing the iTunesDB without iTunes; on Linux, this is specifically done using libgpod. This database was the same with every iPod, so it was easy to use a new iPod with existing music software. Even the iPod Touch 1G was compatible with libgpod (albeit in a roundabout way).

With the introduction of iPod Touch firmware 2.x, Apple decided to “obfuscate” the database so that it could no longer be reproduced. All of the software that could once sync with iPods (Amarok included) was rendered useless with iPod Touch firmware 2.x.

Thankfully, there’s a workaroud. The database obfuscation is controlled by an XML file found in /System/Library/Lockdown/Checkpoint.xml on the iPod Touch (and iPhone). As it is easy to edit that file with a jailbroken iPod Touch with OpenSSH installed, it’s a matter of changing

<key>DBVersion</key>
<integer>4</integer>

to use database version 2 instead. Version 2 of the database is — you guessed it — the unobfuscated version.

There’s one little problem. When you plug your iPod Touch into your computer and run fdisk -l, it doesn’t show up. The iPod Touch does not identify itself as a mountable drive, so you must do one of two things:

  1. Tunnel an SSH connection through USB using iTunnel (buggy, at least when I compiled from source on Arch Linux), 0r
  2. Mount your iPod Touch via Fuse over WiFi

The second method is great if you’ve got a wireless network to work from. If not, and your wireless card supports ad-hoc mode, you can set up a network just between your computer and iPod. On the other hand, if you do not have access to WiFi at all, your only option is the first, which I’ve found to be quite buggy on Arch Linux. Who knows, maybe you’ll have good luck, but I’ll continue writing this the assumption that you’re using the second method.

If you’re running a decent distribution, there should be a set of scripts called “ipod-convenience” in your repositories (it’s available in the apt repositories in Ubuntu, and Arch Linux has it available in AUR). It’s my suggestion to connect your iPod to your computer over USB as that will keep the WiFi connection from turning off when your iPod goes to sleep. After installing the scripts, edit /etc/defaults/ipod-convenience so that it holds the IP address of your iPod, then run ipod-touch-mount. It’ll ask for your password (twice) and try to mount your iPod’s filesystem at /media/ipod (make sure it exists and is writable by your user).

From there, just fire up Amarok 1.4 and set up your iPod like normal. File transfer rates depend on your card’s speed and the traffic around the local access point.

If you’re OCD like me, you like having lyrics on each of your tracks so that when you tap the music application it displays lyrics. Unfortunately Amarok does not handle this well (actually, at all).  To get it working requires recompiling Amarok. If you’re into that, then keep reading. If you’re not, then you can stop right here and either a) use gtkpod which handles lyrics and artwork (but I didn’t like how it handles audiobooks (I’m a huge Doctor Who fan and listen to Big Finish audios in my free time)), or b) forget about lyrics support.

Amarok just does not handle lyrics tags well at all. From what I can make out, it saves lyrics to its own database, not the USLT portion of the ID3v2 tag. Thus when you save the lyrics to a music file using an external program, Amarok doesn’t see it and vice-versa. You can install scripts that read and write to the ID3 tags, but even then lyrics don’t show up on your iPod.

What’s happening is that a song in a database has a lyrics flag that must be set. iTunes does this by looking at the file in question at transfer time, seeing if it has lyrics in its tag, and sets that bit in the database. Unfortunately, stock Amarok 1.4.10 does not have this capability. I’ve found a patch here for Amarok 1.4.4 that I applied manually to Amarok 1.4.10

That still didn’t quite work for me. It compiled fine, but something’s changed since Amarok 1.4.4 in the way that it checks the ID3v2 tags. The original function was looking for the lyrics themselves and returning the lyrics as a string. The way that the patch works, it doesn’t actually care what the lyrics are — it just wants to know if there are lyrics. After analyzing the changes made, I changed the method QString MetaBundle::lyrics() in metabundle.cpp to just do the following (excuse the sloppy tabbing, WordPress doesn’t handle HTML):

QString MetaBundle::lyrics() const
{
TagLib::FileRef fileref = TagLib::FileRef( QFile::encodeName( url().path() ), true );
if ( TagLib::MPEG::File *file = dynamic_cast<TagLib::MPEG::File *>( fileref.file() ) )
{
if ( file->ID3v2Tag() )
{
if ( !file->ID3v2Tag()->frameListMap()["USLT"].isEmpty());
return QString("there's something here...");
}
return QString("");
}

After recompiling and transferring a few songs, it worked! It’s not the most elegant solution, but at least you’ll get your lyrical goodness so that you can sing along to all those songs which you have no idea what they’re saying (Boom Shackalak, anyone?)

This patch only works for MP3 files, which brings me to my next (and final) point. As previously mentioned, I listen to audiobooks and I like the built-in audiobook format that iTunes uses (M4B) because it bookmarks your files. Amarok immediately recognized my M4B files as such and uploaded them to properly use the bookmarks. However, I also like to put the “cover blurb” on the lyrics tag so that when I start a new one I have a faint idea of what’s happening. Because the lyrics patch only works for MP3 files and not M4A (I tried getting it to work, but ran into an issue with Arch’s libmp4v2), you can’t have this capability. Thankfully, in looking over the iTunesDB code for Amarok, I found that if you set the genre to “audiobook” it’ll set the audiobook flag on the iPod — regardless of whether or not it’s an M4B file. What that means is that you can use regular old MP3 files as audiobooks (which gets me even further away from Apple’s proprietary junk!)

Hopefully this was a helpful post. It’s taken me a few days to get Amarok working to my tastes, but it finally is and I thought I’d share my research.

April 22, 2009

Using the Context Menu Key as a Compose Key

Filed under: GNU/Linux — Kevin @ 9:10 am

I’ve noticed over the last few months that I don’t use the “context menu” key very much. Actually, I never use it, and I find it really annoying when I’m scrolling through a webpage with my arrow keys and accidentally bump it. On top of that, I wanted an easy way to type letters with accents, so I could do things like type über or a ¢ sign without having to go to a character map.

If you’re new to Linux, what I was looking for is called a “compose key.” The compose key works like this: tap the compose key, then a modifier, and lastly the letter you want. For example, if I want an e with a grave accent, I type “compose, ` (the character next to 1), e” in that order, and voilà I get a nice è.

Now, how do you go about setting your context menu key to act as a compose key? In Linux, it’s as easy as typing

setxkbmap -option "compose:menu"

into a terminal. You’ll immediately have a compose key. Even things such as £ (compose, -, L) or € (compose, =, C) will work on a US keyboard now! A complete listing of compose key combinations is here. The only problem is, when you restart X, your settings will go away so you’ll have to run that every time you start X. You can do that one of two ways:

  1. In /etc/X11/xorg.conf, add Option "XkbOptions" "compose:menu" to your keyboard section.
  2. Add the previoius “setxkbmap” line to a startup script. For example, I’m running KDE 4.2, so I added that line to ~/.kde4/Autostart/startup.sh (chmodded so that it’s executable, of course) so that KDE will run that command every time I log in. In GNOME, it should be as easy as going to System>Preferences>Sessions.

I recommend using the second method, because it will only change the setting for your user. Who knows, perhaps other people do use the context menu key.

April 10, 2009

KDE 4.2 and Amarok 1.4 Multimedia Keys

Filed under: GNU/Linux — Tags: , , — Kevin @ 10:14 am

I just figured out something that has been plaguing me for about a week, so I figured I’d write a quick post about it.

I’d been using Amarok 2 lately because it’s integrated into KDE 4.2 fairly well. When I tried upgrading to 2.0.2, however, I had major issues with compilation, and then with databasing when it was finally compiled. That, coupled with the lack of an equalizer and other Amarok 1.4 features, convinced me to downgrade to Amarok 1.4 (which is in the Arch Linux repositories).

As previously mentioned, Amarok 2 had pretty good interfacing with KDE 4.2, including being able to use the KDE Control Menu’s Global Shortcuts. It was easy to set up my multimedia keys (play/pause, stop, next, previous) to work with Amarok 2. But after downgrading to 1.4 I lost that ability.

The solution is to open Amarok 1.4. Under settings, there is an option to configure global shortcuts. Just configure play/pause, etc., to your media keys and voila! It works great, even under KDE 4.2.

August 13, 2008

Trying out Gentoo Linux on my Dell E1705

Filed under: GNU/Linux — Tags: , — Kevin @ 10:16 am

Over the past few days, I’ve been trying to make the days pass more quickly by messing around with Gentoo Linux on my Dell laptop (which Dell finally fixed under my warranty). As a reminder, I’ve been using (K)Ubuntu for over a year, and I recently installed OpenSUSE 11.0 on my desktop, so I’m not a total newcomer to Linux.

My first reaction is that it’s definitely a more hands-on Linux distribution. I did a minimal installation using the Gentoo handbook, in which you boot from the minimal install CD and there’s really no install script. The first steps are to partition everything manually using fdisk, install Portage (the package management tool for Gentoo), and install a bare kernel which you can configure manually. And when I say bare, I mean bare naked. One must literally install everything that he or she wants on the target system – I even had to emerge iptables using Portage.

There are two options for configuring the kernel. First, one can try to configure it manually, though I had issues with ndiswrapper when I tried that, so I used the second option, emerging genkernel and using that “vanilla” kernel that supports most hardware. Maybe sometime if I get brave enough I’ll go back and try configuring my own again.

I had somewhat of a headache trying to get X installed, but that was because when I emerged Xorg it didn’t install the mouse and keyboard drivers, so I had to 1) figure out what kernel modules I had to install (xf86-input-mouse and xf86-input-keyboard) and 2) install them manually. After that, I had already installed my graphics driver so there were no issues with that from the start (amazing! I’ve had troubles with Ubuntu from the beginning where the driver would be installed but it would be using Mesa for OpenGL and not the fglrx driver). Then I had to emerge KDE. At the moment, everything is running very quickly (although I still think the default KDE look is very bland and uninteresting, so I’ll have to fool around with that later).

But not everything is going well.

I still haven’t figured out how to get sound going (I think it’s just a matter of adding my normal user to the proper group,, but that’ll have to wait until I’m done emerging some big files on Konsole so I can restart X)

  1. The keyboard is very annoying. Sometimes keys stick, even though I hardly tap them. As a result, I’vvvvvvve been having issues while typing this entry (as you can see with the extra “v”‘s and a few extra spaces which I’ve let unaltered from the original typing). This isn’t an issue with the actual keyboard, because I don’t have any problems with it in Vista (yes, I took the plunge! So far it’s nota s bad as people makeito ooooooooooooooooooooout t obe. AAnd again with the kyboard issues).
  2. I can’t get knetworkmanager working. I’ve merged it and when I run “emerge –pretend knetworkmanager” it says that it would rebuild it if I tried to emerge it again. But yet when I try to run it at the command line, it says that the command cannot be found. Furthermore, when I try to run it from the K menu, it pops up in the system tray; however, when I place my mouse over the tray icon, it immediately crashes.
  3. Konqueror has issues with displaying images and some pages properly. We’ll see if my issues with being in the wrong profile (default instead of 2008.0/desktop – see below) fix things.
  4. I haven’t been able to emerge Firefox yet, but right now I’m re-emerging cairo with the X USE flag, so I think that will fix it. (Update: I’ve gotten Firefox 3 to emerge. It looks great!)
  5. There’s no ebuild for Firestarter (my favorite iptables frontend)! Instead I’m using Guarddog, but I’ve had issues with internet connection sharing and Guarddog in the past.
  6. I’m not entirely sure that both of my CPU cores are being utilized. They’re being reported in cpufreq-info and /proc/cpuinfo, but things are still choppy. Installing Superkaramba and running a dual-core monitor reports both CPUs are always at the same percentage of usage, which leaads me to believe only one is actually being utilized.
  7. I can’t get sound working yet, at least not in KDE. It works fine at the command line with ogg123, and lsmod shows that the module that I need for my particular sound card is loaded. I’ve done a forum post on the Gentoo forums and one user noticed that I probably wasn’t using the desktop profile. I’ve changed over to this and I’m re-emerging things.
  8. More of a gripe than an issue: while the idea of compiling software is very cool, it’s sometimes a bit of a pain to wait to compile it. Although the fact that Konqueror loads as fast as lightning makes up for it 🙂

So I’m pretty happy with it, I suppose. When I’m done, maybe I’ll go through and make a list of how I got certain hardware working.

As a last thought, I took a screenshot of my desktop. Click it to enlarge.

My KDE desktop on Gentoo 2008.0

My KDE desktop on Gentoo 2008.0

June 14, 2008

Mathematica 6 and Compiz on Kubuntu Hardy

Filed under: GNU/Linux, Mathematics — Tags: , , , , , — Kevin @ 10:13 am

My school offers the software for “anybody who is on the payroll,” and we’re taught to use it pretty heavily in some of our classes (there is even a 1-credit course on Mathematica) so I went ahead and downloaded it from the department. However, even from the start I’d had some troubles. Now I’ll tell you how to fix those.

When I was running Mathematica 5, I had a nasty issue where running Beryl with XGL (on a nasty ATI card, before AIGLX was supported in the fglrx driver) in the background would make my text and most of the graphics transparent. My method of fixing this was to just put a blank terminal in the background. After the new ATI driver with AIGLX support, the problem was fixed, but now it opened three windows at startup, two of which were blank and I couldn’t close. Upgrading to Mathematica 6 brought no relief, and upgrading to Kubuntu 8.04 brought along another problem with fonts – now everything was white, and changing the color would fix it.

So, here’s the fix.

  1. Fixing fonts: Instead of typing “mathematica” into a terminal to start Mathematica 6, try using “mathematica -defaultvisual” which fixed the fonts for me.
  2. Fixing the three popup windows: The bug was reported here, but I’ll go ahead and summarize it to save you the trouble of searching through other people’s comments. First, go to “Edit->Preferences…”, which should pop up the preferences dialog. Click the “Advanced” tab on the top right and right next to “For all other option settings:” click “Open Option Inspector.” Now on the left bar, go to “Notebook Options->Window Properties” and change “Window Frame” to “Generic.” Below is a screenshot of my preferences (click to blow it up).

Click to see larger image

That’s it! Now close Mathematica and restart it to get only one window and visible fonts!

May 29, 2008

MAC Address Spoofing

Filed under: GNU/Linux — Tags: , , — Kevin @ 7:30 pm

I had always thought that spoofing a MAC address was difficult. After all, one security precaution to wireless routers is to only let certain MAC addresses into the router.

Today I wanted to spoof a MAC address, though not for illegal purposes such as hacking into a wireless network. The university that I’m working at for the summer requires that you activate ports in the research labs by sending a request to the department’s ITS people containing the MAC address of the computer you’re trying to hook up and waiting a few days. Unfortunately I didn’t have a few days because the hard drive on the computer that we used had crapped out. It’s an old computer (pre-2000) so booting a live cd of Ubuntu was out of the question. I had my laptop and needed to connect to the internet but I couldn’t connect using the dead computer’s ethernet port since my MAC didn’t match. On top of that, we were in the sub-basement of the building, so there were no Wifi points around.

Reading through the man pages for ifconfig, I found out it’s extremely simple to spoof a MAC, at least in Linux. All commands need to be run as root, so either su to root or prefix each command with sudo.

First, disable your device (mine was eth0) by using

ifconfig eth0 down

Then, enter the line

ifconfig eth0 hw ether 00:01:02:03:04:05

and of course substitute in the MAC address that you desire. Then, just do

ifconfig eth0 up
dhclient eth0

and you’re done! You’ll now connect with your new MAC. Don’t worry, your MAC will reset on the next boot.

So anyway, I was online and looked up external hard drive enclosures to see if it would be reasonable to try one out just to make sure it wasn’t the motherboard or cables that was fried. After looking, I decided to take off the computer’s cover and poke around a bit, but didn’t actually change anything other than unplugging and replugging a few cables. Next boot it found the drive! Strange, but at least I was able to make a last backup of the data on the hard drive before we replace the computer within the next few days.

May 28, 2008

Auto Gordian-Knot v2.40 in Wine 0.9.59

Filed under: GNU/Linux — Tags: , , , , , — Kevin @ 12:10 am

I’ve had some trouble in the past getting AutoGK running in Wine on Kubuntu, but it had been a while since I tried so I decided to give it a go again to see how much Wine has progressed.

The Wine HQ profile for AutoGK claims that version 2.40 runs fine on Wine 0.9.53, so I went ahead downloaded it from AfterDawn after some searching. It installed just fine, and I downloaded the DLL files suggested by this site (it’s in German but is basic enough to be able to make out). Even after doing this I was having problems – as soon as I started it, I got the errors below:

installation is corrupted. please reinstall the application

followed by,

\home\name\history.txt". file not found

After these errors it would start, but every time I tried to open an IFO file, it told me that it was unable to parse, and if I opened a VOB directly, it said it was an invalid stream.

Just by chance, I cd’d to the Wine directory where wine installed it to check out the files in the directory. After poking about for a bit, I tried one last time…and it started just fine!

Not sure what I did, I went ahead and added it to my dock (using a hi-res icon found here). I went about encoding a DVD file that I had ripped using DVDFab (which works beautifully right away in Wine!) and watched it afterwards in Kaffeine. Satisfied, I decided to encode some more.

But starting the launcher from my dock, I got the same errors as before. Confused, I tried poking around my winecfg settings and got nothing. I decided to run the program in the same setting as before, so I cd’d again to the install directory and ran it from there. It worked again! It seems that, for whatever reason, running AutoGK in Wine requires that you be in the install directory.

I wrote a very simple bash script to put on my dock icon.

#!/bin/bash
cd ~/.wine/drive_c/Program\ Files/AutoGK
wine "C:\Program Files\AutoGK\AutoGK.exe"

Save this to any directory you’d like and chmod it to 755 so that it is executable. Then run it any time you want!

If this was helpful, please drop me a line through e-mail or a comment.

UPDATE: To install AutoGK, you have to use a virtual desktop in your winecfg settings. Once you’re done installing you can remove the virtual desktop.

May 20, 2008

KDE Superkaramba Themes

Filed under: GNU/Linux — Kevin @ 11:41 pm

Well, I was hesitant at first to put time into learning even basic Python commands, but in one evening I learned enough to be able to write two themes for Superkaramba. Both are very similar: the first fetches Garfield comics, and the second fetches xkcd. I’ve uploaded them to KDE-Look.org, and they can be found here and here.

My motivation for creating them was two-fold. First, there were already a few Garfield fetchers for Superkaramba. One seemed to work only when it was the first theme opened in Superkaramba; the other didn’t resize itself for Sunday comics which are a few more panels. Second, there wasn’t an xkcd fetcher for Superkaramba, so I thought I’d make the first!

The Garfield theme does have a small “bug” if you will. The file names change from day to day, and it’s actually a predictable pattern so I’m just using this pattern for now. Unfortunately, it seems the newest comic isn’t posted right at 12:00 AM EST. In fact, it’s almost 1 AM here now, and it still hasn’t been posted. So the theme searches and searches for the file, but it’s not there. I’m not sure when it’s uploaded, but as soon as it is uploaded it should grab it and update itself. I guess the easiest way to fix this is to wait until, say 5:00 AM EST to get it. I’ll work on it soon.

The xkcd grabber, on the other hand, shouldn’t have this problem since I have it reading the newest url right from xkcd’s RSS feed.

If you enjoy them, I’d like to hear from you!

Older Posts »

Blog at WordPress.com.