Linux Blog

thinkpad_handler ACPI Script for Lenovo T61 hotkeys

Filed under: Shell Script Sundays — at 2:54 pm on Sunday, January 18, 2009

Lenovo T61 Thinkpad_Handler ACPI hotkey

This weeks shell scripting article showcases the modifications I have made to the thinkpad_handler script that normally resides in /usr/lib/acpid on an OpenSuse distribution. For any one not using a Lenovo T61 this may or may not be useful, however anyone interested in shell scripting can take a look at the file and see the simplicity of shell scripts that are used in production environments.

Here is my modified thinkpad_handler script

One of the reasons I chose to post this was because an OpenSuse upgrade broke my brightness keys support, so I figured it would be another good place to back it up while providing a reference. My modifications are very minimal at the moment, I still have a lot of work to do.

Here are my minor modifications:

Line 102 to add support for suspendon Fn+F4

Line 127 to eject /dev/cdrom on Fn+F9

I used to have a special script for Fn+F8 which enabled me to toggle support for the touchpad and track point mouse. Until I find that script I’ll endure excruciating mental anguish every time I accidentally hit the touchpad. I’ll have to make an update to this script once I change all of the other hotkeys for OpenSuse on the Lenovo T61. I should also probably upgrade to OpenSuse 11.1 and see if that makes a difference in the keyboard shortcuts.

Until next week, happy scripting!

Suspend Scripts for the Toshiba Tecra M2

Filed under: Quick Linux Tutorials,Shell Script Sundays — at 12:15 am on Sunday, March 30, 2008

As you may know if you are a regular reader I own a Toshiba Tecra M2. One of the things that annoyed me was I had to turn the brightness up every time my computer came out of standby mode. A fix for this is to adjust the brightness every time the computer comes out of standby mode.

The script is intended to be run under cron. I have mine set up to suspend after 5 minutes of the lid being closed.

if [ $(cat /proc/acpi/button/lid/LID/state | sed 's/state:      //') == "closed" ]; then
VAR=$(cat /proc/acpi/toshiba/lcd | sed ‘s/brightness:              //’ grep -v levels);
sudo su -c “echo mem > /sys/power/state”;
if [ $VAR -eq 1 ]; then
elif [ $VAR -eq 7 ]; then
if [ $ACTION == "ADD" ]; then
VAR=$(($VAR + 1));
VAR=$(($VAR – 1));
sudo su -c “echo brightness:$(echo $VAR) > /proc/acpi/toshiba/lcd”;

I run this with the following cron entry:

*/5 * * * * sh

The script first checks the current brightness. If the brightness is currently 1 or 7 it adjusts the mathematic operation so that when the laptop is opened the brightness is adjusted. Basically if the brightness is one, it adds one. If the brightness is 7 or any other value it subtracts one. This is currently working out quite well for me. I don’t know how useful this is to any body else, unless you happen to have a Toshiba that is doing the same thing but it should give you a good overall idea of how to perform basic mathematic operations in bash.

My Linux Laptop – Toshiba Portege 4010

Filed under: Linux Hardware — at 9:48 am on Monday, November 26, 2007

Linux Blog - Toshiba Portege 4010 Linux LaptopAlong with my desktop I also have a laptop that is in dire need of an upgrade. It is a Toshiba Portege 4010. Although its age and its specifications (or lack of) it is still a decent ultra portable laptop. The battery life is great (4-6 hours) and its very light weight. Here are the specs:

CPU: 933MHz Pentium M
Ram: 512MB Shared
HD: 100GB Seagate 5400RPM
Media: CD-RW/DVD Combo Drive.
Network: Integrated 10/100 & Orinoco B Wifi.

I like its slim line style and cool features like the SD Card Reader, Firewire, Infrared and Toshiba Select Bay. But unfortunately I’ve not been able to get the SD Card or Infrared to work. The video card is also lacking, its a Trident Cyberblade and it doesn’t have very good support. I have to run X in VESA frame buffer mode which isn’t as bad as it sounds but without tweaking it is unable to play DVD’s.

The Toshiba ACPI extras work really well in conjunction with fnfxd. Brightness, Volume, Screen Change and Lock Screen are the only short cuts I set up. The system also suspends to disk & ram with no problems.

I also run Slackware 12 on my laptop and have trimmed it down to boot Linux faster and provide better battery life. It boots to login in about 30 seconds. The picture above is a picture I took in the kitchen. The desktop is XFCE from Slackware-current, click on the image to view more photos of my Toshiba Portege 4010.