Filter android logcat by package name on command line

Recently, I wrote a shell script for filtering android logcat log by package name, which is a shame that it’s not a default option on logcat.

The script can be downloaded here.

Set first argument as the package name you want to match, for example




will match any application that starts with net.kevxu

The rest of arguments will be passed to adb.

Force Intel Graphics on 2012 Retina MacBook Pro (MacBookPro10,1) in Linux

If you install linux under BootCamp (emulated BIOS mode), then the only graphics card you will see is the discrete one (NVIDIA), so if you want to use Intel Graphics, you must install it under EFI mode. There are plenty of blog posts mentioned about this, so I won’t talk about it.

So the main focus here is how to switch to Intel Graphics, so that macbook can consume less battery power. Although after linux is booted up, two graphics card are available, it seems like gmux, which is used by mac to control which chip for display, is wired to NVIDIA chip. And use vgaswitcheroo to force switch to Intel chip doesn’t seem to work (others report it will only causes a blank screen).

The only way I found is to add some commands into grub, according to those two posts (Switch graphics on MacBookPro9,1 and Intel Graphics on a 2011 MacBook Pro in Linux). However, the command mentioned in those two posts don’t seem to work on my 2012 Retina MacBook Pro. After some digging, I found inside latest apple-gmux linux driver, a new way for communicating with gmux chip is used (so called “indexed” read/write) for newer models.

The way to do is following.


outb 0x7c2 1
outb 0x7d4 0x28
outb 0x7c2 2
outb 0x7d4 0x10
outb 0x7c2 2
outb 0x7d4 0x40

# Power down discrete graphics (won't work)
#outb 0x7c2 1
#outb 0x7d4 0x50
#outb 0x7c2 0
#outb 0x7d4 0x50

into one of the menuentry inside grub.cfg. During booting, you will see a blank screen until intel driver is fully loaded. However, at this point, the discrete chip is still not powered down. According to apple-gmux driver,

outb 0x7c2 1
outb 0x7d4 0x50
outb 0x7c2 0
outb 0x7d4 0x50

should power down the discrete chip, however, after adding those commands into grub.cfg, the system just won’t boot up (stuck at blank screen, probably the kernel crashed).

The only workaround I found for this problem is probably power down the discrete chip after system is fully booted up. And this C program should do the trick. Compile with gcc, and run it with sudo.

Disable internal display for chipset using i915 driver on Linux

Just found a quick way for disabling internal display on i915.

Using command modinfo i915, there will be an options called panel_ignore_lid.

According its description, panel_ignore_lid:Override lid status (0=autodetect [default], 1=lid open, -1=lid closed) (int).

So create a new file under /etc/modprobe.d name it i915.conf

Adding following:

options i915 panel_ignore_lid=-1

You are done! (Don’t forget to reboot)

Tango Dark theme for OS X Terminal

Honestly, I really liked iTerm2, it has much nicer style than the built-in Terminal app in OS X. However, it does crash a lot. So that’s why I have to switch back to the built-in Terminal app which is really stable, but don’t have any good looking built-in themes.

So I decided to port the Tango Dark theme from iTerm2 back to the built-in Terminal. I also used the same font and line-spacing as iTerm2 did, so that makes the Terminal itself really looks like iTerm2.

Here is the link

Hope you like it.

Purdue Course Parser Library

Purdue Course Parser is a Java library separated from Purdue Assistant which was an Android project I did in my freshman year.

What the library does is basically retrieve course information from myPurdue website. I am doing some rewriting and polish to the library so that it has built-in threading function by using callback style function calls. And it can process multiple course search requests simultaneously.

Here is a link to my code on github. Any help will be appreciated. Detailed description is on github too.

Running graphical application of Linux over SSH

Well, I have to admit, Lawson Computer Labs got lots of powerful Linux machines. We can use login to those machines using SSH as long as you have a purdue CS account.

Normally you can only use command line applications on those machine, not if you have X11 installed on your machines. So some basics about X11. Basically, X11 have two sides – server and client, normally they are running on the same machine. However, because of this kind of design, you can potentially make two sides running on two different machines. One way to do that is passing X11 over ssh, so X11 client is running on your machine and the server side is running on your target. And in such way, we can run graphical applications of Linux remotely.

Enable X11 passing with SSH is easy, just add “-X” flag.

So I can use following command to login to Lawson B158 machines.

ssh -X -l (username)

After successfully logged in, you can try to type firefox to fire up the browser.

Or nautilus to start the Gnome’s default file manager.

Or gnome-session to start the whole Gnome environment.

and following picture shows 3D application Blender which uses OpenGL running over SSH.