Ubuntu Setup Guide -Tilt Control and Automatic Rotation

Posted in Life in General by aliencam | 1 Comment »

*this section has been added to the “aliencam’s Customized Ubuntu Setup Guide” page. Visit the articles page to read that article.

I just now got around to setting up automatic rotation and the accelerometer, thanks to Karol Krizka at www.krizka.net. This section of the guide is mostly copied from a few entries on this blog, as I was unable to figure out all of this stuff on my own (yes I know, I’m being lazy.)

Accelerometer

The first thing you need to do is set up the accelerometer. Doing this in Ubnutu Hardy no longer requires recompiling a kernel, which is pretty awesome.

just to make sure everything will work, in a terminal do:
sudo modprobe hdaps_ec
sudo modprobe tp_smapi

If those commands don’t return any errors, then you are in good shape.

you should then edit the kernel modules loaded on startup (if you want this to always work) to include those two.

sudo gedit /etc/modules

and add the two lines:
hdaps_ec
tp_smapi

then save and close gedit.

Test everything to make sure it is working properly

install hdaps-utils in synaptic or in the terminal with:
sudo apt-get install hdaps-utils

then run the accelerometer test by either pressing alt-F2, or running “hdaps-gl” in a terminal. Then make sure that the image reflects the actual rotation of the laptop (for example, does tilting it forward make the picture of the laptop tilt forward?). If not, go HERE and follow the troubleshooting section. Hopefully though, everything will work and you can continue on to the screen rotation.

If you don’t want automatic screen rotation, or you just want to play around with this some more, you can do things like play Neverball which is like super monkey balls (install it from the add/remove programs program, or synaptic). But I don’t know of much else (I believe the hard drive protection is not working without a recompiled kernel at the moment).

Screen Rotation

Add the python-xrandr PPA repo by opening up the “Software Sources” program and adding the following line to the “Third Party Sources” list, or by adding the line to the bottom of /etc/apt/sources.list
deb ppa.launchpad.net/displayconfig-gtk/ubuntu gutsy main

Then do:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install wacom-tools python-xrandr

Next download the atorotate.py script written by Krizka from here (sorry for posting someone else’s script, but I don’t know how to write python anyway, that’s a project for another day) and move it to /usr/local/bin. For example, if you downloaded it to your desktop the code would be:
sudo mv /home/$USERNAME/Desktop/autorotate.py /usr/local/bin replacing “$USERNAME” with your username.

Then make sure it is executable:
sudo chmod +x /usr/local/bin/autorotate.py

create a file for “tabletmode” with the command:
sudo touch /etc/tabletmode

To create files that make an acpi event for putting the tablet up and down, first do:
sudo gedit /etc/acpi/events/swivel-down
and enter into that file:
# called when tablet screen swivels down (into tablet mode)
event=ibm/hotkey HKEY 00000080 00005009
action=echo tablet > /etc/tabletmode

Then,
sudo gedit /etc/acpi/events/swivel-up

and enter:
# called when tablet screen swivels up (into laptop mode)
event=ibm/hotkey HKEY 00000080 0000500a
action=echo laptop > /etc/tabletmode

Once this is finished, you have to restart ACPI (this does not restart your computer)
sudo /etc/init.d/acpid restart

< --! Then edit /etc/gdm/Init/Default in order to get the python script to run on startup (including before login)
sudo gedit /etc/gdm/Init/Default
then before the line that reads “exit0” add:
/usr/local/bin/autorotate.py& –>
Then add /usr/local/bin/autorotate.py to your “sessions” startup menu (System > Preferences > Sessions). This will make the autorotate startup script run at login. I previously had instructions to run this before the login, but this means that it runs even in a failsafe gnome session, and it caused me many problems starting up after a crash.

Save all of your work and then run the following to restart GDM (this does log you out of your computer):
sudo /etc/init.d/gdm restart

Many thanks to the following posts on krizka.net for this information. I did not know how to do the accelerometer or screen rotation before reading these.

www.krizka.net/2008/02/13/thinkpad-x61-tablet-automatic-screen-rotation-under-linux/

www.krizka.net/2008/01/23/thinkpad-x61-tablet-tilt-detection-and-ubuntu-hardy-heron/

The only issue I have found so far is that with automatic screen rotation, you must first disable compiz graphics. If you have the CompizFusion Icon in your system tray (as I recommend below), all you need to do before you flop your screen is right-click on the CompizFusion Icon, choose “select window manager” and choose “metacity”. Then when you are through with your rotated shenanigans, simply change the window manager back to Compiz.

–aliencam

aliencam’s Customized Ubuntu Setup part VII: Ondemand CPU Govenor

Posted in Life in General by aliencam | No Comments »

The Ondemand CPU Frequency Governor automatically adjusts the CPU frequency in order to save power. It does not simply set the frequency to the lowest setting, because even if you are saving energy, the longer the CPU is in use the more power it uses. So this adjusts the frequency to complete processes as quickly as possible, so it can return to a low power state for longer periods of time, reaching longer and lower sleep levels.

Make sure all package managers are closed, open a terminal and enter each of the following in order:
sudo modprobe acpi-cpufreq
sudo modprobe cpufreq_ondemand
sudo aptitude install sysfsutils
sudo -s
echo "devices/system/cpu/cpu0/cpufreq/scaling_governor=ondemand" >> /etc/sysfs.conf

For the first two, it is good if you do not see any response from the terminal. It only responds on errors. After this, close the terminal window and reboot your computer. After the reboot right-click on the panel where you want the CPU monitor, and select “add to panel” then add the CPU Frequency Monitor. . Then in a terminal enter:
sudo dpkg-reconfigure gnome-applets
select “ok” and “yes” and bam! now every time you left-click on the CPU Frequency Monitor you can choose from the available frequencies, or the available automatic options. Remember, Ondemand is the best for battery life.

sources: http://forum.thinkpads.com/viewtopic.php?t=50949&postdays=0&postorder=asc&highlight=ubuntu&start=0
http://ubuntu.wordpress.com/2005/11/04/enabling-cpu-frequency-scaling/

aliencam’s Customized Ubuntu Setup part VI: Fingerprint Reader

Posted in Life in General by aliencam | No Comments »

Lenovo Fingerprint reader (Lenovo Thinkpad laptops only!)

I suggest that before you do this you practice a few times. You must swipe your entire finger, and it is going to have to be at a slow and uniform speed. My thumbprint swipe takes about one second. I would like to post a video of this because people seriously have a very hard time with it, however I do not currently have a video. And it would be boring. But if i ever come across a video of correct thumb swiping procedure, I will be sure to post it.

In a terminal, enter:
sudo apt-get install thinkfinger-tools libpam-thinkfinger

Once that is complete enter:
sudo tf-tool --acquire

It will then ask you to swipe your finger three times. Do this and it will count each successful/ failed swipe. You need three successful swipes to finish. Then enter:
sudo tf-tool --verify

This will ask you to swipe your finger once, and will tell you if it matches or does not match. Now you need to make sure it actually uses that fingerprint information in password situations.
sudo gedit /etc/pam.d/common-auth

and change the contents of the file to read like this:
auth sufficient pam_thinkfinger.so
auth required pam_unix.so nullok_secure try_first_pass
auth optional pam_smbpass.so migrate

It should only be changing the first line and adding something to the second line, so I did not back up. I would suggest backing up if you are not comfortable in being able to undo that easily. Save and close, then enter:tf-tool –add-user $USERNAME
tf-tool --add-user $USERNAME
replacing “$USERNAME” with your username (should be all lowercase)
(Note: I don’t know if this needs to have sudo before it or not, but I tried both and both gave me an error. However when I logged out my thumbprint worked, so for now ignore the error.)

Now when you log in or need to enter your password in the terminal for sudo or need to enter it for nearly everything else, you can either slide your finger or type your password. For things like the Synaptic Package Manager or the Add/Remove Programs, it will not tell you that swiping oyur fingerprint is an option, but it will work anyway. (it will just say “enter your password”)
This does not however work for the screensaver password or the sleep-mode wake up password. For that you will either have to actually type in your password, or follow this marginally simple guide: http://www.thinkwiki.org/wiki/How_to_enable_the_fingerprint_reader_with_ThinkFinger and go to the section titled “xscreensaver/gnome-screensaver.” This is not in this guide because I like to have to type my password after a screensaver or sleep mode, and this is after all a guide to get Ubuntu set up how I like it.

Creative Commons License