Posts | Tags | Archive

Forcing a media refresh on Android with adb

Android will automatically perform a media refresh when an SD card is mounted.

Using adb, we can fake that event by manually sending a MEDIA_MOUNTED intent.

For example, if you wanted to run a media refresh of the entire SD card:

adb -d shell "am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard"

To refresh different directory, just change "/sdcard" to the absolute path of the directory you want to refresh.

For more fine-grained control, use the MEDIA_SCANNER_SCAN_FILE intent, which triggers a rescan of a single file.

Installing Fehlstart - A simple, quick application launcher

Fehlstart is an application launcher, much like Launchy, Quicksilver, or GNOME Do. However, where other launchers focus on adding features, Fehlstart is as basic as they come. If you want to search for files or control your media player, look elsewhere. Felhstart launches applications. Period.

Fehlstart isn't in any major repositories so it has to be compiled from source.

  1. Install dependencies
    • git, gcc, make, libgtk2.0-dev, libkeybinder-dev
    • On most systems these packages will be available through your package manager
  2. Get the code
    • git clone
  3. Compile and install
    • Navigate into the folder containing the code
    • Run make
    • Run make install (with the needed permissions)
  4. Add fehlstart to your window manager's autostart list
  5. Log out and back in to launch Fehlstart.
  6. Press the key combination <Super> + <Space> to bring up the launcher
  7. Type to search through the installed applications, then press <Enter> to launch.

Gotcha with basic HTTP authentication in Python

When doing basic HTTP authentication in Python, make sure your authentication realm is surrounded by double, NOT single quotes.


self.send_header("WWW-Authenticate", "Basic realm='/'")


self.send_header("WWW-Authenticate", "Basic realm=\"/\"")

The single quotes work with most browsers, curl, wget, and tons of other tools. However, when using Python to access the page (using urllib2.HTTPPasswordMgrWithDefaultRealm to manage authentication) single quotes don't trigger the "automatic retry with authentication" response, and instead just raise a 401 HTTPError.

© Carey Metcalfe. Built using Pelican. Theme is subtle by Carey Metcalfe. Based on svbhack by Giulio Fidente.