Similar problem here - eg. I once almost failed a course because I decided that writing a computer game for a Lisp competition is much more fun. I get A's in courses I care about, which is a suprising minority, and learn some of the rest while procrastinating, in completely different order than university would like.
At the same time though, I'm constantly working on side projects. Currently, I'm building an autonomous tricopter, because I thought it'd be cool to build. Last semester, I wrote a webapp to handle an event we were having. Previous semester, I was working on a way to control my room from my computer (still working on that, just not as intensely). These all easily answer "Why am I doing this?" (tricopter: because it's cool. Webapp: Might be able to make money from this [Note: didn't make any money from it ): ]. Computer-controlled room: It's cool, and it allows me to be incredibly lazy.)
I know that I'm not an idiot, I should be getting As, and I do get As in the classes that genuinely interest me. Unfortunately, at least 75% of the classes I take don't interest me, so I get lost in trying to answer "why am I even bothering with this?"