Simple solution would be to just right-click on the dash itself and select the specific category you want to search - Dash will be cleared automatically for that.
I've noticed that the re-opened Dash, has the previous text highlighted. Hitting backspace key allows for clearing and carrying out new searches without issues. If only we could automate doing that . . . Well, we can with application called xdotool
and a bit of scripting magic.
Install xdotool
via apt-get install xdotool
and save the following script. Its basic task is to determine whether or not the active window is Dash, and automate hitting BackSpace key to clear Dash. This is meant to run as python script_name.py
and to be launched when user logs in by adding this script to Startup Applications.
#!/usr/bin/env python
import dbus,time,subprocess,os
def run_cmd(cmdlist):
""" utility: reusable function for running external commands """
new_env = dict(os.environ)
new_env['LC_ALL'] = 'C'
try:
stdout = subprocess.check_output(cmdlist, env=new_env)
except subprocess.CalledProcessError:
pass
else:
if stdout:
return stdout
def get_dbus(bus_type, obj, path, interface, method, arg):
""" utility: executes dbus method on specific interface"""
if bus_type == "session":
bus = dbus.SessionBus()
if bus_type == "system":
bus = dbus.SystemBus()
proxy = bus.get_object(obj, path)
method = proxy.get_dbus_method(method, interface)
try:
if arg:
return method(arg)
else:
return method()
except dbus.exceptions.DBusException:
return None
def active_is_dash():
base = ['session','org.ayatana.bamf']
dbus_call = base + ['/org/ayatana/bamf/matcher', 'org.ayatana.bamf.matcher','ActiveWindow',None]
active_window = str(get_dbus(*dbus_call))
dbus_call = base + [active_window,'org.ayatana.bamf.view','Name',None]
active_name = str(get_dbus(*dbus_call))
if active_name == 'unity-dash': return True
command = 'xdotool key BackSpace'.split()
flag = None
while True:
time.sleep(0.25)
if active_is_dash():
time.sleep(0.25)
if not flag: run_cmd(command)
flag = True
else: flag = False
Best Answer
The files scope relies on two main data sources to return results:
locate
database is used to search your entire home folder.If you have chosen to encrypt your home folder, then your home folder will be an
ecryptfs
mount when you are logged in.The default configuration for updating the
locate
database in/etc/updatedb.conf
skipsecryptfs
filesystems.You can change this configuration by editing the
PRUNEFS
variable in that file, but note that this will leak the names of files in your home folder onto non-encrypted storage.Unfortunately, I don't think there is currently a solution (beside this alternative) that will let you search your files in the dash and keep their metadata private.
If you add the command
alias updatedb-home='export LOCATE_PATH="$HOME/mlocate.db" && updatedb -l 0 -o $HOME/mlocate.db -U $HOME'
you then can runupdatedb-home
periodically to update db, or add it also to.bashrc
to run it on every login.