answered
2014-03-18 21:02:47 +0200
Hi everybody im currently using this script to include/exclude some folders by the tracker.
What i did is modify the script /usr/bin/tracker-sd-indexing.sh called during the boot process, but it can be executed at anytime.
The original file
#!/bin/bash
DEF_UID=$(grep "^UID_MIN" /etc/login.defs | tr -s " " | cut -d " " -f2)
if [ -b /dev/sdcard ]
then
if [ "$(gsettings get org.freedesktop.Tracker.Miner.Files index-removable-devices)" = "false" ]
then
gsettings set org.freedesktop.Tracker.Miner.Files index-removable-devices true
fi
if [ "$(gsettings get org.freedesktop.Tracker.Miner.Files index-recursive-directories | grep extSdCard)" = "" ]
then
gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "['&DESKTOP', '&DOCUMENTS', '&DOWNLOAD', '&MUSIC', '&PICTURES', '&VIDEOS', '/run/user/$DEF_UID/media/sdcard']"
fi
fi
systemctl --user restart tracker-miner-fs.service
My script.
First of all create 2 files:
- /home/nemo/.config/tracker/toMount
- /home/nemo/.config/tracker/toExclude
toMount file
toMountArray="/include/path"
toExclude
toExcludeArray="/excluded/path"
Backup /usr/bin/tracker-sd-indexing.sh
cp /usr/bin/tracker-sd-indexing.sh /usr/bin/tracker-sd-indexing.sh_vanilla
Edit /usr/bin/tracker-sd-indexing.sh and add the following content
#!/bin/bash
DEF_UID=`grep "^UID_MIN" /etc/login.defs | tr -s " " | cut -d " " -f2`
user=`egrep "^[[:alpha:]]+:[[:alpha:]]+:${DEF_UID}" /etc/passwd | cut -f1 -d ":"`
#add directories to be exclude or include by indexer
toMountFile=/home/$user/.config/tracker/toMount
toExcludeFile=/home/$user/.config/tracker/toExclude
################
#Check mounted and exclude propeties file
toMountFlag=0
toExcludeFlag=0
#if exist and are correct flags = 1
[ -f $toMountFile ] && . $toMountFile && toMountFlag=1
[ -f $toExcludeFile ] && . $toExcludeFile && toExcludeFlag=1
################
#Check if sdcard is mounted
sdCardFlag=1
sdCardMountPoint=""
grep "^/dev/mmcblk1" /proc/mounts >/dev/null && sdCardFlag=1
defaults="'&DOWNLOAD', '&MUSIC', '&PICTURES', '&VIDEOS'"
if [ $sdCardFlag -eq 1 ];then
echo "SD"
sdCardMountPoint=`grep "^/dev/mmcblk1" /proc/mounts | awk '{print $2}'`
#Set to true to enable indexing mounted directories for removable devices.
if [ "$(gsettings get org.freedesktop.Tracker.Miner.Files index-removable-devices)" = "false" ];then
echo "gsettings set org.freedesktop.Tracker.Miner.Files index-removable-devices true"
gsettings set org.freedesktop.Tracker.Miner.Files index-removable-devices true
fi
#add the toMount array at the end
if [ $toMountFlag -eq 1 ]; then
#toMountArray is defined on toMountFile
if [ -z "$toMountArray" ]; then
echo "gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories \"[${defaults}, '${sdCardMountPoint}']\""
gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "[${defaults}, '${sdCardMountPoint}']"
else
toMountString=""
for i in $toMountArray; do
toMountString=${toMountString}"'${i}',"
done
echo "gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories \"[${defaults}, '${sdCardMountPoint}', ${toMountString%?}]\""
gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "[${defaults}, '${sdCardMountPoint}', ${toMountString%''}]"
fi
fi
else
echo "!SD"
#add the toMount array at the end
if [ $toMountFlag -eq 1 ]; then
#toMountArray is defined on toMountFile
if [ -z "$toMountArray" ]; then
echo "gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories \"[${defaults}\""
#gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "[${defaults}]"
else
toMountString=""
for i in $toMountArray; do
toMountString=${toMountString}"'${i}',"
done
echo "gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories \"[${defaults} ${toMountString%?}]\""
gsettings set org.freedesktop.Tracker.Miner.Files index-recursive-directories "[${defaults} ${toMountString%?}]"
fi
fi
fi
#add the toexclude array at the end
if [ $toExcludeFlag -eq 1 ]; then
if [ ! -z "$toExcludeArray" ]; then
toExcludeString=""
for i in $toExcludeArray; do
toExcludeString=${toExcludeString}"'${i}',"
done
echo "gsettings set org.freedesktop.Tracker.Miner.Files ignored-directories \"[${toExcludeString%?}]\""
gsettings set org.freedesktop.Tracker.Miner.Files ignored-directories "[${toExcludeString%?}]"
fi
fi
echo "systemctl --user restart tracker-miner-fs.service"
systemctl --user restart tracker-miner-fs.service
Have you tried hidden directories(e.g .icons)? That is the way I do this on N9, but have not tried on Jolla.
zlatko ( 2013-12-29 18:57:31 +0200 )edit@zlatko Good idea. I'd expect that to work... need to check if that makes sense for all my current use-cases.
datakurre ( 2013-12-29 19:10:20 +0200 )edit@datakurre I actually tried it and it works for me - hidden dirs are not indexed by the tracker.
zlatko ( 2013-12-29 22:12:57 +0200 )editcheck out
Kontio ( 2013-12-30 00:13:28 +0200 )edit/usr/bin/tracker-sd-indexing.sh
if you feel comfortable to mess with gconf settings :-)@Kontio Thanks. It seems that using .-prefixed directories is the easiest way as long as it makes sense for the files in question :)
datakurre ( 2013-12-30 06:40:11 +0200 )edit