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

net.kevxu.example

also

net.kevxu

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.

Add

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.