Disabling the indexer (baloo) when on battery

I noticed that when I run my computer on battery power, the indexer does not get disabled. This consumes a lot of power needlessly and drains my battery. At the same time, I do not want to disable the indexer entirely, I just want it to run when the laptop is plugged in. Googling around, I read that this is not the correct behaviour of baloo, and that it is supposed to suspend itself when the laptop goes on battery according to a reddit post.
Is this considered a bug? Or am I missing something?

It’s something I constantly notice everytime I start up the computer. The indexer indexes file content after starting up, even though Im on battery, and even though I have not changed the files it is indexing since the last shutdown. This also seems like a bug and may be related.

I am running KDE Plasma on stable, on a Dell XPS 13 9360.

Hi!

What you can do is to create a udev rule to disable/enable the indexer when the cord is unplugged/plugged. As an example, I’ll post a rule I used to set CPU governor before I started using TLP. You just need to remove the comment symbol and change the script path for the lines you need.

[mbb@mbb-laptop ~]$ cat /etc/udev/rules.d/98-ACDC-behaviour.rules 
# Set governor to powersave and disable turbo boost on DC (handled by tlp)
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="/bin/sh /home/mbb/.bin/cpugov-powersave.sh"

# Set governor to performance and enable turbo boost on AC (handled by tlp)
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="/bin/sh /home/mbb/.bin/cpugov-performance.sh"

# Set software energy policy hint to 10 on DC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="/bin/sh /home/mbb/.bin/x86-energy-policy-power.sh"

# Set software energy policy hint to 4 on AC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="/bin/sh /home/mbb/.bin/x86-energy-policy-performance.sh"

# Set gpu max frequency to 750 Mhz on DC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="/bin/sh /home/mbb/.bin/set_gpu_frequency_power.sh"

# Set gpu frequencies to defaults on AC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="/bin/sh /home/mbb/.bin/set_gpu_frequency_performance.sh"

# Set turbo boost off on DC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="/bin/sh /home/mbb/.bin/set_turboboost_off.sh"

# Set turbo boost on on AC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="/bin/sh /home/mbb/.bin/set_turboboost_on.sh"

# Set cpu max frequency to 1200 Mhz on DC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="0", RUN+="/bin/sh /home/mbb/.bin/set_cpu_frequency_power.sh"

# Set cpu frequencies to defaults on AC
#ACTION=="change", SUBSYSTEM=="power_supply", ATTR{type}=="Mains", ATTR{online}=="1", RUN+="/bin/sh /home/mbb/.bin/set_cpu_frequency_performance.sh"
3 Likes

That’s a great idea! Although I wish this was built into KDE, but at least there’s a solution

is ~/.bin/ generally considered the right place for putting user scripts? Or was this arbitrary in your case?

Well I just realized something. It seems that everytime I upgrade packages, no matter how small of an update it is, the indexer decides that it needs to reindex everything all over again.

I’m guessing this has something to do with timeshift and snapshotting on btrfs, but I’m not sure how. I did not tell the indexer to index system files… Perhaps it’s tripping the inotify system that the indexer probably uses

It’s arbitrary. Actually, I currently put them in /usr/local/bin or /usr/local/sbin.

As for why it behaves like that, I have no clue. I don’t use the indexer nor btrfs.

that is true
~/.local/bin
is already in your $PATH

anything else you need to add to the shell environment yourself

but I do not think this is a good idea:

putting user configs into system wide directories/files …

they should stay in the users $HOME

I think it is actually preferable to place files executed by system/root that you do not want anyone to be able to modify there (in the improbable case someone modifies the .sh files on the system to trigger an attack for example). It is actually the proper place in theory when you want something available on the whole system (not only a specific user). In this case this modification calls scripts that need to be available to all users.

I found this while writing this post, it explains it all Demystifying Linux: The purpose of /bin, /usr/bin and /usr/local/bin - DEV Community, or this https://unix.stackexchange.com/questions/8656/usr-bin-vs-usr-local-bin-on-linux

1 Like

Exactly! Making them available for different users was the main reason I started to put them there. I still keep a backup copy on my home folder though.

EDIT: I put scripts with admin privileges in /usr/local/sbin and those which don’t require privileges in /usr/local/bin.

EDIT: just a note about the hierarchy in Arch, /bin and /sbin are symlinks to /usr/bin, and /lib and /lib64 and symlinks to , /usr/lib.

https://man.archlinux.org/man/file-hierarchy.7

Surprisingly, the manual refers ~/.local/bin but not /usr/local/bin. To my understanding the first is for user only scripts and the second is for admin/system wide custom scripts.