I use Gnome Tracker quite a bit and am led to wonder whether there is currently any way to use Tracker from within emacs? That is to say; searching for files indexed by Tracker, within emacs (and consequently reading them with pdf-tools or docview). It would be one less reason to fire up the Tracker Desktop Search interface.

[ https://wiki.gnome.org/Projects/Tracker ]

  • 1
    Does it come with a command line interface? In this case, it should be relatively straight forward to write a little emacs interface. I did the same for KDE's Baloo using helm: github.com/malb/emacs.d/blob/master/… – Martin R. Albrecht Apr 30 '17 at 13:33
  • @MartinR.Albrecht, yes it does have a fairly good command line interface; the CLI is better than the GUI in a sense and what you have done there for Baloo is what I am looking for Tracker. Thanks for the nice pointer; I will try to put together something useful! – Vishal Belsare Apr 30 '17 at 20:09
  • 1
    I would love to see what you've come up with @VishalBelsare. THis would be great for me to have too! – Matt Jun 23 '17 at 4:09
  • @Matt just seeing your comment. I did not do much with Martin's suggestion, with the exception of a bare bones function which calls tracker. I will post that as an answer. – Vishal Belsare Sep 14 '17 at 22:20
  • @Matt, please see the function 'tracker-dbus-async'. While a lot more could be done, this is a little more useful than before. I want to add the FTS snippets in the display also, but I don't know enough to integrate the that information in a dired buffer. – Vishal Belsare Dec 26 '17 at 23:44

Looking at Martin's link to using baloo under KDE, the following function calls tracker's sparql query and shows the results in a new frame. A lot more needs to be done and could be added to make this really useful. The results are shown in a file URI format, and find-file-at-point works to open the documents in DocView mode. I use this mainly to use full-text search over a collection of PDF articles (and some ODT/DOCX files). More information could be displayed by modifying the sparql query. I'd love to add something akin to org-mode's hyperlink file display, i.e. return the list of files displaying just the filename and hiding the file URI in the hyperlink - would save column space.

    (defun tracker-sparql (sparql-query)
      (start-process "tracker-sparql" "tracker-sparql" "tracker" "sparql" "-q" sparql-query)
      (switch-to-buffer-other-frame "tracker-sparql")

    (defun tracker (search-term)
      (interactive "sFulltext Search String: ")
      (tracker-sparql (concat "SELECT nie:url(?f) WHERE { ?f fts:match '"
                  "' }")

(require 'dbus)

(defun tracker-dbus-async (search-terms)

  (interactive "sFulltext Search String: ")  
  ;; mapcar 'car --> mapcar 'url-file-truename --> dired cons
  (defun tracker-results-process (search-terms results)
    (dired (cons
        (concat "Tracker Search: " search-terms)
        (mapcar (lambda (x) (url-file-truename (car x))) results)

  (fset 'tracker-results-process-fix-search-terms
    (apply-partially 'tracker-results-process search-terms))

  (let ((search-query (concat "SELECT nie:url(?f) WHERE { 
                   ?f a nfo:Document . ?f fts:match '" search-terms "'
                   } ORDER BY 
                   DESC (fts:rank(?f))")))
    ;; search-query
                :session "org.freedesktop.Tracker1"

Some years ago I wrote a dired-based interface to tracker results. It's not polished, but in case it is of any use, you can find the code here: https://www.emacswiki.org/emacs/Tracker

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.