Sunday, October 31, 2010

Ubuntu 10.10 on a Tablet PC: HP 2730p

If you have one of these cool Tablet PC's, you probably have a Windows operating system installed on it.. Don't you think that it is time to switch to a Linux distribution?.. And that was exactly what I had been thinking for a quite time.. I got bored of all Windows applications and its neverending problems.. Additionally, I'm the kind of person who is not able to use Windows Vista =) Sooo big time!..

First of all, there is always some risks to take.. because it is difficult to be sure, if everything will function properly or not.. Well, I thought of the worst case which is using that Tablet PC as a normal laptop PC without tablet functionalities =) Ok, this is still a big risk, but anyway I decided once and went for it..

Am a fan of Ubuntu, so I wanted to install Ubuntu 10.10(latest version for now) on HP2730p.. Everything went well, Ubuntu installation was completed in 15-20 minutes.. I didn't have any driver problems, so I was in the worst case now =)

After googling around, I found some nice softwares for Tablet PCs:
  • Cellwriter: It's a grid-entry natural handwriting input panel.. And I can say that it works like a charm.. After spending 5-10 minutes for the training part, it recognizes quickly your handwriting..
  • Xournal It's an application for notetaking, sketching, keeping a journal using a stylus. It's also a very nice application that you can use for taking notes.
I also configured Gimp and InkScape by enabling tablet input devices such as stylus, eraser and cursor; which is described in Ubuntu Community page.

Everything was fine, but I realized that I had some problems related to screen rotation.. because as an example, while reading an e-book, it is better to rotate the screen.. Googled about it, many solutions many scripts.. tried many of them.. some worked but not completely.. then, I combined some solutions and finally had that feature working..

I suppose that you have "wacom-tools" package installed, if not please install it first.. Then, type on a terminal:

$ xinput --list

You'll have an output similar to that one:

⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ HID 04b3:3107 id=10 [slave pointer (2)]
⎜ ↳ PS/2 Generic Mouse id=12 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=13 [slave pointer (2)]
↳ Serial Wacom Tablet stylus id=15 [slave pointer (2)]
↳ Serial Wacom Tablet eraser id=14 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ CKA7240 id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=11 [slave keyboard (3)]
↳ HP WMI hotkeys id=16 [slave keyboard (3)]

Important entries are represented as bold text.. Now, we will use this information to rotate the screen and related tablet input devices.. I modified these two scripts written by "Justin Linuturk Phelps", to have screen rotation functionality for my case..

1. laptopmode.sh
#!/bin/bash

xrandr -o normal && xsetwacom set "Serial Wacom Tablet stylus" Rotate none && xsetwacom set "Serial Wacom Tablet eraser" Rotate none
exit 0

This mode is your normal mode that you can use without tablet pc functionalities..

2. tabletpcmode.sh
#!/bin/bash

xrandr -o right && xsetwacom set "Serial Wacom Tablet stylus" Rotate CW && xsetwacom set "Serial Wacom Tablet eraser" Rotate CW
exit 0

This mode is your tablet mode that you can use with a screen rotation..

Replace bold texts, with the outputs that you get when listing inputs..

After saving these two files as scripts(with .sh extension), move them to /usr/local/bin folder and then, type in a terminal:
/usr/local/bin$ sudo chmod +x laptopmode.sh
/usr/local/bin$ sudo chmod +x tabletpcmode.sh

Now, these scripts are executable by the user.. It is easier to create application launchers, instead of running scripts from a terminal..
1. Right click on your Ubuntu panel, and choose "Add to Panel"..
2. Double click on "Custom Application Launcher", as a name type: "Laptop Mode" and as the command type: "laptopmode.sh". You can also change the icon of your custom application.
3. Click ok.

Do the same thing for "Tablet Mode" application launcher..

Finally, you have two icons on your panel that you can use to switch from Laptop Mode to Tablet Mode and vice-versa.. Hope this helps.. Thankfully, I made a good choice and it works perfectly.. Thanks to everyone who submitted useful information on web...

6 comments:

Czarodzi said...

Thanks for putting this info out here. All the tips worked, and one thing I could add is from http://alice-at-ubuntu.blogspot.com/ to make use of the jog dial.

nadinima said...

thanks Czarodzi =)

Peyu said...

Thanks for your information! I use your scripts to do rotation only with one script. First it detects the screen rotation state (normal or right), and then it rotates according to the state. With this, you can bind a multimedia key with gnome shortkeys, so it will rotate to right if the screen rotation is normal and to normal if it's right.

Here it is:

#!/bin/bash
nameStylus="Wacom ISDv4 93 Pen stylus"
nameEraser="Wacom ISDv4 93 Pen eraser"
nameTouch="Wacom ISDv4 93 Finger touch"

originalrotation=$(xrandr | grep 'LVDS connected' | gawk '{print $4}' | sed -e 's/(//')

case $originalrotation in
normal )
echo "original orientation normal"
echo "setting to right"
xrandr -o right && xsetwacom set "$nameStylus" Rotate CW && xsetwacom set "$nameEraser" Rotate CW && xsetwacom set "$nameTouch" Rotate CW
exit 0;;
right )
echo "original orientation right"
echo "setting to normal"
xrandr -o normal && xsetwacom set "$nameStylus" Rotate none && xsetwacom set "$nameEraser" Rotate none && xsetwacom set "$nameTouch" Rotate none
exit 0;;
esac

andrew said...

to peyu:
very nice idea to set the names of the stylus, eraser and touch at the beginning. i have three different tablets (none perfect) and the script is thus easy to adapt!

thank you
andrew

CPUDoctor said...

I'm very new to scripting in Linux, but I just combined an auto rotation .sh from the Ubuntu.org forums with your original script and it worked for me. Hopefully this will help at least one other newbie trying to get there HP 2730p to run independent of the "man".

"autorotatedisplay.sh"

FIRST LINE BELOW
#!/bin/bash
# Daemon to automatically rotate the screen
#
# Traps:
# signal QUIT (3) delete temp files
# signal TERM (15) delete temp files

tempfile=/tmp/ROTATION_$$
touch $tempfile

# set traps
trap 'rm -f $tempfile; exit' 0
trap 'rm -f $tempfile; exit' 3
trap 'rm -f $tempfile; exit' 15

# begin rotation loop

old="0"
while true; do
if [[ -e /sys/devices/platform/hp-wmi/tablet ]]; then
new=`cat /sys/devices/platform/hp-wmi/tablet`
if [[ $new != $old ]]; then
if [[ $new == "0" ]]; then
xrandr -o normal && xsetwacom set "Serial Wacom Tablet stylus" Rotate none && xsetwacom set "Serial Wacom Tablet eraser" Rotate none
elif [[ $new == "1" ]]; then
xrandr -o right && xsetwacom set "Serial Wacom Tablet stylus" Rotate CW && xsetwacom set "Serial Wacom Tablet eraser" Rotate CW
fi
fi
old=$new
sleep 1s
fi
done
LAST LINE ABOVE

And I found the following on www.ivankristianto.com that I'm going to use so it runs at boot.

"You can run your script on boot process in Ubuntu by adding it to /etc/init.d/rc.local file. Look the steps below.

1. Open /etc/init.d/rc.local file with this command:

vim /etc/init.d/rc.local

2. Add your script that you want to run on boot process there, for example:

sh /home/ivan/iptables.sh
echo 'Iptable Configured!'

3. Save the files. And your script will run on boot process."

Hope it works for everyone!

Safdar Ali said...

Nice post with helpful details. I really appreciate your info. Thanks for sharing. tablet pc