Open file with gpicker and mlocate

gpicker is a convenient tool for selecting files. Yesterday I remembered that it supports the gathering of data from the mlocate database and decided to setup a convenient opening files from the mlocate database using gpicker and gnome-open. To start you need to know where the base mlocate in your system. The path can be found on the man page locate(1) or via a call locate -h:

$ locate -h | grep "\.db"
      /var/lib/mlocate/mlocate.db)

This is enough to bring all together:

$ gnome-open `gpicker -t mlocate --eat-prefix="" /var/lib/mlocate/mlocate.db`

Option --eat-prefix means strip prefix to make paths relative.

It remains only to set up a hotkey in metacity (e.g. via gconftool-2(1)):

$ gconftool-2 --search-key-regex run_command_\\d+
  /apps/metacity/global_keybindings/run_command_1 = <Super>c
  /apps/metacity/global_keybindings/run_command_2 = <Super>f
  /apps/metacity/global_keybindings/run_command_3 = <Super>s
  /apps/metacity/global_keybindings/run_command_4 = <Super>x
  /apps/metacity/global_keybindings/run_command_5 = <Super>d
  /apps/metacity/global_keybindings/run_command_6 = <Super>v
  /apps/metacity/global_keybindings/run_command_7 = <Super>a
  /apps/metacity/global_keybindings/run_command_8 = disabled
  /apps/metacity/global_keybindings/run_command_10 = disabled
  /apps/metacity/global_keybindings/run_command_11 = disabled
  /apps/metacity/global_keybindings/run_command_12 = disabled
  /apps/metacity/global_keybindings/run_command_9 = disabled

Choose free number and assign it to the command and hot-key.

$ gconftool-2 --type string --set /apps/metacity/global_keybindings/run_command_10 '<Super>g'
$ gconftool-2 --type string --set /apps/metacity/keybinding_commands/command_10 'sh -c "gnome-open `gpicker -t mlocate --eat-prefix="" /var/lib/mlocate/mlocate.db`"'

Pick files with gpicker, mlocate and gnome-open

Also you can create local mlocate database for particular directory:

$ updatedb -o mlocate.db -U .
$ gpicker -t mlocate mlocate.db

To use mlocate you need to install gpicker 2.1 (tarball, deb-i386, deb-amd64)

  1. gpicker repository
  2. gpicker releases