Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 312583 - make sys-apps/slocate battery aware
Summary: make sys-apps/slocate battery aware
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-01 10:42 UTC by Daniel Troeder
Modified: 2010-04-11 19:57 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Troeder 2010-04-01 10:42:00 UTC
I think it is very anoing if updatedb runs when I'm on battery. I don't want to remove cron globally from a battery-runlevel (and I can't expect all users to do so). So I think the cronjob could be a bit sensitive about it.

What do you think of the following modification to the slocate-cronjob?

/usr/bin/on_ac_power is from sys-power/pm-utils, what (I think) most
people have installed. If prefered we could check if sys-power/pm-utils is installed, and only then apply this patch.

--- /etc/cron.daily/slocate	2010-03-30 19:41:24.954135902 +0200
+++ /etc/cron.daily/slocate.old	2010-03-30 19:37:06.721255754 +0200
@@ -1,11 +1,5 @@
 #! /bin/sh

-if [ -x /usr/bin/on_ac_power ]; then
-    if ! /usr/bin/on_ac_power ; then
-        exit 0;
-    fi;
-fi
-
 if [ -x /usr/bin/updatedb ]
 then
 	if [ -f /etc/updatedb.conf ]

Reproducible: Always

Steps to Reproduce:
1. remove power from notebook
2. start cronjob (/etc/cron.daily/slocate)
Comment 1 Gef 2010-04-01 12:48:49 UTC
Nice idea. About its implementation, on baselayout-2.0 systems, there is also /lib/rc/bin/on_ac_power from sys-apps/openrc (which doesn't require sys-power/pm-utils) ; baselayout-1.12* doesn't looks like it has such a function.
Comment 2 SpanKY gentoo-dev 2010-04-02 09:03:42 UTC
your patch is reversed.  but anyways, as Gef points out, ive pushed Roy to export a helper function specifically for cronjobs to leverage.  that's the only thing i would use in cronjobs -- we're not going to start copying & pasting duplicate code all over the place.

the way to do things though is:
. /etc/init.d/functions.sh
on_ac_power 2>/dev/null
[ $? -eq 1 ] && exit 0
Comment 3 Daniel Troeder 2010-04-05 11:44:41 UTC
> your patch is reversed.
oops :D

Duplicate code is bad of course. Is it possible to check in an ebuild if we're on baselayout-2, and only then patch the cronjob with the three lines spanky suggests?