To load a kernel module in Linux you enter the following in a terminal:
Of course if you wanted to load a different module you would replace tp_smapi with the appropriate module.
You can use the 'lsmod' command to view the status of loaded kernel modules. For example:
will execute the lsmod command and search for and print all lines with the phrase 'tp_smapi' in it. The | command simply pipes/redirects the output of grep (which searches for the printed line tp_smapi)
Once the module is loaded check that you have the smapi directory:
You should see the BAT0 directory.
In a terminal execute the following commands (either as root or using sudo):
Code: Select all
echo 30 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 85 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh
To check enter the following commands:
Code: Select all
cat /sys/devices/platform/smapi/BAT0/start_charge_thresh
cat /sys/devices/platform/smapi/BAT0/stop_charge_thresh
You should see the values you set.
To get this to all happen automatically you'll need to do 2 things:
1) Get the tp_smapi module to load at boot
2) Set battery thresholds in local startup script.
Note that you will need to edit some files as root. Any text editor will be fine (I prefer vi, but nano is a little more forgiving, and gedit is good for beginners). If you don't edit via the command line (e.g. using vi or nano) but rather with a GUI text editor (e.g. gedit) you'll want to use the following command to edit
gksudo is simply a graphical sudo. You should use gksudo for applications and sudo for command-line actions. The reasons are outside the scope of this thread but pm me if you have questions.
To be safe I would backup the original files before editing (it's a good practice when editing system config files). You can do
Code: Select all
sudo cp /path/to/file /path/to/file.bak
to make a copy of the file before editing.
1) Load module on boot
Assuming the tp_smapi module loads with modprobe, you can add tp_smapi to the end of the /etc/modules file. You may want to double check this with someone (or better yet, check the ubuntu/mint forums) because my Arch Linux loads modules in a different way and I'm a little fuzzy on modules in other distros.
2) Add commands to /etc/rc.local
To set the thresholds automatically you have some options. I'm going to describe one method but know that there are several ways to accomplish the same thing.
This is where I put all of my homemade commands/scripts that I run at startup. I put them all here so that I can easily keep track of them and also so they don't get mixed in with other scripts (aka those that I didn't write and Arch Linux installed).
Backup the original rc.local file:
Code: Select all
sudo cp /etc/rc.local /etc/rc.local.bak
Now you just need to add the two lines from above to /etc/rc.local:
Code: Select all
echo 30 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 85 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh
It doesn't matter where, just as long as it is before the "exit 0" line. I would also add a comment so you know what you've done for future reference (the '#' symbol denotes a comment.
To sum up, here's what your rc.local file should look like:
Code: Select all
#!/bin/sh
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the
# execution bits.
#
# By default this script does nothing.
# Set battery thresholds
echo 30 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 85 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh
exit 0
In case Mint doesn't have this script you can create a file called rc.local in /etc, copy and paste the above code into it, save it.
Now that you have your rc.local script you need to make it executable:
Reboot and check that the script worked:
Code: Select all
cat /sys/devices/platform/smapi/BAT0/start_charge_thresh
cat /sys/devices/platform/smapi/BAT0/stop_charge_thresh
You should see the values you set.
Let me know if this worked. If not we have some other options, but we'll worry about that when we need to.