Protect the battery of thinkpad notebook under Fedora14

Source: Internet
Author: User
I don't need to talk about the advantages of Linux, but there are also many disadvantages. It is really difficult for me to wait for lazy people to use it. For example, my work notebook T61 has been used for three years because the RHEL5.x operating system does not have an integrated battery charging and protection module. When the battery is full, the AC power is still charging and two batteries are broken, although it is not painful for capitalists to pay, it is always uncomfortable. My friend recommended that Ubuntu have a tp_smapi module or something, which can protect the battery like windows. google gave it a hand and found that Fedora is outdated. I don't need to talk about the advantages of upstre Linux, there are also a lot of disadvantages. It is really difficult for me to wait for lazy people to use it. For example, my work notebook T61 has been used for three years because the RHEL5.x operating system does not have an integrated battery charging and protection module. When the battery is full, the AC power is still charging and two batteries are broken, although it is not painful for capitalists to pay, it is always uncomfortable. My friend recommended that Ubuntu have a tp_smapi module or something, which can protect the battery like windows. google gave it a hand and found that Fedora was outdated and did not integrate upstream. Unfortunately, it is only troublesome to do DIY.

According to the guidance of the experts, to engage in this Dongdong need to first use akmods, installed after the akmod-tp_smapi, then modprobe loaded smapi battery management module, and finally set the charging start and end threshold, the details are as follows:

Click here to download the compiled akmod module for Fedora. It does not matter if the version is low.
Unzip the package and install it using the rpm-ivh akmod-tp_smapi-0.40-1.fc11.i686.rpm. Note that this rpm requires support for kernel devel.
Call service akmods restart, and run rpm-qa | grep smapi. You can see that the rpm for F14 related to kernel has been generated and installed.
At this time, you can use modprobe-l | grep smapi to check whether the module is ready, and then modprobe tp_smapi to load the module.
Therefore, you can use the following command to set the charging threshold. BAT indicates the default battery of the notebook (BAT1 seems to be a BIOS battery, no need to care about it)
  1. # Echo20>/Sys/devices/platform/smapi/BAT0/start_charge_thresh
  2. # Echo80>/Sys/devices/platform/smapi/BAT0/stop_charge_thresh
# echo 20 > /sys/devices/platform/smapi/BAT0/start_charge_thresh# echo 80 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh


Basically, 4 and 5 must be done before you enable this function each time. Therefore, it is better to set up a service, which is started by default for ease of use (/etc/init. d/tp_smapi ):
 
  1. #! /Bin/sh
  2. #
  3. # Chkconfig:12345 21 80
  4. ./Etc/init. d/functions
  5. SMAPILOCK =/var/lock/tp_smapi_lock
  6. Start ()
  7. {
  8. Echo-n $"Starting tp_smapi service :"
  9. /Sbin/modprobe-q tp_smapi
  10. Echo20>/Sys/devices/platform/smapi/BAT0/start_charge_thresh
  11. Echo80>/Sys/devices/platform/smapi/BAT0/stop_charge_thresh
  12. Echo
  13. Touch $ SMAPILOCK
  14. Echo
  15. }
  16. Stop ()
  17. {
  18. /Sbin/modprobe-r tp_smapi
  19. Rm-f $ SMAPILOCK
  20. }
  21. Status ()
  22. {
  23. Status =0
  24. If[-F $ SMAPILOCK]; then
  25. Echo"RUNNING"
  26. Else
  27. Echo"UNUSED"
  28. Status =1
  29. Fi
  30. Return$ Status
  31. }
  32. Case "$1"In
  33. Start)
  34. Start
  35. ;;
  36. Stop)
  37. Stop
  38. ;;
  39. Restart)
  40. Stop
  41. Start
  42. ;;
  43. Status)
  44. Status
  45. Exit $?
  46. ;;
  47. *)
  48. Echo"Usage: $0 {start | stop | status | restart }"
  49. Exit1
  50. ;;
  51. Esac
#!/bin/sh## chkconfig: 12345 21 80. /etc/init.d/functionsSMAPILOCK=/var/lock/tp_smapi_lockstart(){echo -n $"Starting tp_smapi service: "/sbin/modprobe -q tp_smapiecho 20 > /sys/devices/platform/smapi/BAT0/start_charge_threshecho 80 > /sys/devices/platform/smapi/BAT0/stop_charge_threshechotouch $SMAPILOCKecho}stop(){/sbin/modprobe -r tp_smapirm -f $SMAPILOCK}status(){status=0if [ -f $SMAPILOCK ]; thenecho "RUNNING"elseecho "UNUSED"status=1fireturn $status}case "$1" instart)start;;stop)stop;;restart)stopstart;;status)statusexit $?;;*)echo "Usage: $0 {start|stop|status|restart}"exit 1;;esac
After each F14 kernel upgrade, the related akmod should be re-implemented. Just write a script to solve it.
  1. #! /Bin/sh
  2. Echo'Looking for old rpms ...'
  3. ForRpm in 'sudo rpm-qa | grep smapi'
  4. Do
  5. Echo undeploying $ rpm...
  6. Sudo rpm-e $ rpm
  7. Done
  8. Echo'Installing akmod ...'
  9. Sudo rpm-ivh Co., akmod-tp_smapi-0.40-1. Fc11.i686. rpm
  10. Sudo/usr/sbin/akmods -- force
  11. Sudo service akmods restart
  12. Echo'Mod status :'
  13. Sudo modprobe-l | grep smapi
  14. Echo'Set battery thresholds ...'
  15. Sudo service tp_smapi restart
  16. Echo'Done .'
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.