Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Thursday, September 6, 2012

Make new ThinkPad's charge thresholds work in Debian/Ubuntu

Instead of Intro

ThinkPad`s have been always famous for the amazing hardware compatibility with Linux. But seems this time has gone and owners of new ThinkPad`s like ThinkPad X230, T430 and of some other may have started experiencing some uncomfortable changes. The one of the such changes is inability to use tp_smapi module to set battery thresholds.

Battery charge threshold might be important for you if you want extend the battery's health. They are used to keep batteries partially charged.

I am as an owner of brand new ThinkPad x230 run into the impossibility to load tp_smapi module for my primary Debian (Testing) GNU/Linux as well as to set above mentioned thresholds. Here will be a safe workaround to fix the regression. It must work as well for Ubuntu Linux.

For the previous versions of ThinkPad`s it was simply enough to put desired integers to /sys/devices/platform/smapi/BAT{0,1}/{start,stop}_charge_thresh files to make these thresholds work. Currently there are no such special files anymore; since tp_acpi loading is failed. At least for the newest ThinkPad`s. Fortunately there is an alternative way: to set these values directly through the kernel's ACPI subsystem not ThinkPad brand controller's interface.

There is a module called acpi_call which was originally designed for easy switching video adapters in dual graphics environments. It provides a convenient interface for sending any command to ACPI subsystem; literally "call ACPI for some request". But which command to send to request a change of charge thresholds? Actually it does not matter because you should not do it by yourself. There is a special tool called tpacpi-bat (the part of tpbattstat-applet) which will do it for you.

Solution: all steps together

The only things we need to make ThinkPad`s charge thresholds work in Debian/Ubuntu are:
  1. Install acpi_call module;
  2. Install tpacpi_bat script;
  3. Configure thresholds setting on system boot-up;

acpi_call for Debian/Ubuntu

acpi_call is not included to standard Debian/Ubuntu repositories. The only way is to build it by yourself. Since I am a bit lazy about keeping in mind that with each kernel update I should rebuild acpi_call module I decided to write a simple script which will register and install it as a DKMS module.

The script could be retrieved from my git repository. The only requirement for running it is a root permission. If some packages required to build are missing you will be notified. Run it with 'run' argument and the script will do the following for you:
  • Retrieve acpi_call sources from the main git repository;
  • Register it as a DKMS module;
  • Install acpi_module to your Debian/Ubuntu system.

tpacpi_bat

tpacpi_bat is also not included to standard Debian/Ubuntu repositories. It could be grabbed from the author's git repository. The script depends on Perl only and could be put anywhere on the system, e.g. to /usr/local/bin.

Thresholds on boot-up

To make charge thresholds set on system boot-up:
  • acpi_call entry must be added to /etc/modules
  • The following commands must be added to /etc/rc.local:
/usr/local/tpacpi-bat -v startChargeThreshold 0 N
/usr/local/tpacpi-bat -v stopChargeThreshold 0 K

where N and K are integers in percent of full battery capacity.


Enjoy! Thanks to this ThinkPad's batteries might be a bit healthy :).

Thursday, June 23, 2011

actkbd package for Debian/Ubuntu

Recently I became an owner of Thinkpad X120E laptop produced by Lenovo. The computer was supplied with no pre-installed OS so I deployed (unexpected decision, huh!) Debian GNU/Linux there. This time I decided not to use desktop "ready-to-use-out-of-the-box" environments like Gnome or KDE and give a try to build a DE I want from bricks.

The one of the tasks I have faced with is how to make ThinkPad X120E hotkeys work in Debian GNU/Linux in a uniform way - to have a single keybindings entry point; which should work in VT w/o X.org also. Some of the keys (like VolUp, VolDown, Suspend etc) can be successfully handled through acpid daemon but the rest ones (say enable/disable microphone or switch touchpad/trackpoint) can be with xbindkeys (or similar) application only.

After a short research I found an amazing application called actkbd -- a keyboard shortcut X.org independent daemon. Thanks for being dependent on evdev Linux interface actkbd allows to handle ACPI events as well. But unfortunately there have been no ready-to-use Debian (Ubuntu) package available on the Internet (*).

(*) Of course I could install it using "configure && make && make install" way but I did not want to transform my Debian GNU/Linux installation to Slackware or kind of :).

Hence I made actkbd Debian/Ubuntu package by myself. So you can download here already built actkbd package for Debian Wheezy/i386 or build it by yourself (using dpkg-buildpackage). I am not so experienced in applications debianizing but seems it works well. Please feel free to use it or even to push to Debian/Ubuntu repositories.
Sources of debian/* files are to be shared soon through my git repository.

Tuesday, March 16, 2010

How to return back buttons layout in Ubuntu 10.04

Ubuntu wants to be more user-friendly than other Linux`es. It is the fact. Each new Ubuntu release always introduces a set of features which make user's life easy. But not all these features are cool. Is the fact too.

Upcoming Ubuntu 10.04 also introduces a Mac-like approach when window-control buttons (to minimize, to maximize and to close a window) are placed on the top-left side of the window, not on the top-right. Not everyone will definitely like it. Or not all GNOME (Metacity, if be more specific) themes will be look OK in this case. Anyway there should be a way to affect on window's button layout in Ubuntu. 

So how to return it back?

Ubuntu 10.04 new theme
(the screenshot from http://news.softpedia.com/news/Ubuntu-10-04-Drops-the-Human-Theme-for-a-Fresh-New-Look-136537.shtml)

The solution is simple, but not so obvious (as usual :)). After execution of the following command in a terminal window

gconftool-2 --set "/apps/metacity/general/button_layout" --type string ":minimize,maximize,close"

all buttons responsible for minimization, maximization and closing will be shown on the right side of the windows as it was before in the previous versions of Ubuntu. It is also a fact :).