These parameters should be set on boot time: /sys/devices/platform/smapi/BAT0/start_charge_thresh /sys/devices/platform/smapi/BAT0/stop_charge_thresh /sys/devices/platform/smapi/BAT1/start_charge_thresh /sys/devices/platform/smapi/BAT1/stop_charge_thresh Please provide an init script to set these values. I would use /etc/sysfs.conf as possible in Debian but it seems sysfsutils of Gentoo does not support that. For details, this is what I mean: http://www.thinkwiki.org/wiki/Tp_smapi#Making_the_settings_permanent_on_reboot Thanks!
Good idea i usually used /etc/init.d/local.start for this but a dedicated script seems appropriate. Especially since it can support more than one setting. The script i wrote should support more than one battery but is tested with only one. On start it will set up default values from the conf.d file. Additionally it offers a 'low' and 'high' mode. The values in the conf.d file are what i am using, i think i got the numbers for the default/low mode from the thinkwiki once.
Created attachment 269771 [details] tp_smapi-0.40-r2.ebuild ebuild based on tp_smapi-0.40-r1.ebuild
Created attachment 269773 [details] files/smapi.confd
Created attachment 269775 [details] files/smapi.initd
hello Henning, first: sorry for not getting back to you earlier, and thanks for your contribution! Your work looks excellent so far. Comments: - Your init script seems to miss licensing. Please apply "GPL v2 or later" and mention yourself as the author at the top of files/smapi.initd. I propose this specific license for compatibility with tp_smapi itself. - In function set_all I would like to see use of new variables for $1 and $2 to make the code a bit cleaner: local tstart=$1 local tstop=$2 - The defaults of 40/70 should be 30/85 if following http://www.thinkwiki.org/wiki/Maintenance#Battery_treatment My vote on 30/83 for default. - I would love to see support for /sys/devices/platform/smapi/BAT*/force_discharge through a new action "discharge". Other actions should reset force_discharge properly, too. I am looking forward to an updated version.
Created attachment 277003 [details] files/smapi.initd update to init script
Hi Sebastian, i addressed your first two points in the init script. I did not put my name in it. If it goes into the tree feel free to mention me in the Changelog. The third point is a trivial change to the default config. I am fine with the default values you suggested. I was using an older version of the thinkwiki suggestion. I did not implement the force discharge. Mainly because that is a feature i never used myself. Following the thinkwiki one should maybe discharge every 30 cycles. Looking at my thinkpads that would be once or twice a year. Then you would want to pick one of several batteries instead of discharging all of them. To sum it up, i think that would be a feature for a more generic battery tool. i.e. not gentoo specific and not an init script. If you still want to add it, go ahead.
(In reply to comment #7) > i addressed your first two points in the init script. I did not put my name in > it. If it goes into the tree feel free to mention me in the Changelog. As I did later changes myself, I added my name and added yours too, because otherwise it looks like my work only. > The third point is a trivial change to the default config. I am fine with the > default values you suggested. I was using an older version of the thinkwiki > suggestion. Alright, updated. Other changes I did: - Add modprobe tp_smapi to start() - Make high()/low()/info() require a started service - Operate on levels of absent batteries too (as that battery may be inserted later and writing the level works fine even before that) - Indicate battery presence in info() If you have any patches against the init script in the future, just re-open this bug and attach the patch to it. Thanks! +*tp_smapi-0.40-r2 (14 Jun 2011) + + 14 Jun 2011; Sebastian Pipping <sping@gentoo.org> +tp_smapi-0.40-r2.ebuild, + +files/tp_smapi-0.40-confd, +files/tp_smapi-0.40-initd: + Add init script, main work by Henning Schild (bug #346785) +
The new version of the init script in 0.40-r3 checks status1 twice instead of checking status2 as well. /etc/init.d/smapi:30 > if [ "${state1}" -ne "0" ] || [ "${state1}" -ne "0" ]; then
(In reply to comment #9) > The new version of the init script in 0.40-r3 checks status1 twice instead of > checking status2 as well. > > /etc/init.d/smapi:30 > > if [ "${state1}" -ne "0" ] || [ "${state1}" -ne "0" ]; then Sorry, but I fail to make sense of this. Please provide a patch against 0.40-r2. Thanks!
- if [ "${state1}" -ne "0" ] || [ "${state1}" -ne "0" ]; then + if [ "${state1}" -ne "0" ] || [ "${state2}" -ne "0" ]; then -^-
(In reply to comment #11) > - if [ "${state1}" -ne "0" ] || [ "${state1}" -ne "0" ]; then > + if [ "${state1}" -ne "0" ] || [ "${state2}" -ne "0" ]; then > -^- Alright, thanks. Actually I didn't expect anyone else to touch the script in the mean time. Seems like that happened. Reported error seems fixed by now: 18 Jun 2011; Tomáš Chvátal <scarabeus@gentoo.org> files/tp_smapi-0.40-initd: Fix doublechecking of one variable. state1 instead of state2. Could someone check if we allow headers like this for initscripts?