Friday, September 2, 2011

Rotate Lenovo X60 tablet PC screen with a single button in Ubuntu 11.04

oh, unix: Rotate tablet PC screen with a single button in Ubuntu 11.04

Ah, I finally got this to work. I had originally posted a comment on this blogger's post asking for help because I didn't get what to do with everything and where to put it. I never heard back but, eh whatever, I understand as I am pretty busy myself. They even posted a couple of links which they used to develop this shell script and how to get the desktop button launcher to work.

[SOLVED] trying to write a script for screen rotation with xrandr... - January 25th, 2011 - http://ubuntuforums.org/showthread.php?t=1675299

[SOLVED] How do I add my script to the Unity launcher bar? - March 5th, 2011 - http://ubuntuforums.org/showthread.php?t=1700605

I still couldn't figure it out. I think I needed some screen shots and/or just wasn't familiar enough with the terminology/what was going on. (The more I looked at it the more it started to make sense, especially after messing with it in GNOME classic.)

Anyways, I first just switch DEs to Ubuntu Classic and used the GNOME classic interface. I then create a application launcher and added it to the menu, something pretty easy and straight forward in Ubuntu classic/GNOME 2.

You could also use the post I just added on the GNOME classic menu indicator in Unity where the app button should be available from where you originally put it in with the GNOME classic desktop or I guess you cold use the indicator in Unity to do it too.
So as I was trying to figure out how to do this in Unity, as it kept bugging me in the back of my mind because a) I like Unity, especially if it is the future of Ubuntu, and b) it bugs the crap out of me when I can't understand or get something wrong and it won't leave me alone until I figure it out, I came across a couple of more links in google from typing in "adding applications to the unity toolbar" because I knew I was close with the GNOME application. I then went back and looked at the script and .desktop file written by the blogger and it all fell together. One way you could go about it, which I didn't but almost did is from this link using the gconf-editor: Add Favorite Applications to Ubuntu Unity Launcher in Ubuntu 11.04 Natty Narwhal - http://www.liberiangeek.net/2011/04/add-favorite-applications-ubuntu-launcher-11-04-natty-narwhal/
Arranging Applications on the Launcher To arrange applications on the launcher in Unity 2D, press Alt-F2 on your keyboard, then type the command gconf-editor and select gconf-editor program to open.
I then found this link, which was really helpful, on askUbuntu.com: How can I edit/create new launcher items in Unity by hand? - http://askubuntu.com/questions/13758/how-can-i-edit-create-new-launcher-items-in-unity-by-hand I was about to follow the selected answer post, the first, but someone commented to follow the one below it, the second and most voted. This one is much easier and more simple, I think.
This is a method without editing config files and without root privileges. First create the Launcher on the Desktop (only temporary) - right click your desktop - select Create Launcher... - create the custom Launcher as you want to.
Now you got the launcher on the Desktop. If you are satisfied with it, get it in the Launcher Panel: - Open your Home Folder. Press Ctrl + H to show hidden files if necessary. - Browse to .local/share/applications - Drag and drop your Launcher from Desktop to that folder. - Now drag and drop your launcher from .local/share/applications to the Launcher Bar on the left on your Screen. - You can now delete your custom Launcher on the Desktop if it's still there. That's it.
The blogger's script file is (sorry, as I haven't added syntax highlighting to my blogger post, will do later): TabletRotation.sh This Gist brought to you by GitHub.
#!/bin/bash rotation=`xrandr --query --verbose | grep "LVDS1" | awk '{print $5}'` if [ $rotation = "normal" ] then xsetwacom set "Serial Wacom Tablet stylus" Rotate half xrandr -o inverted else xsetwacom set "Serial Wacom Tablet stylus" Rotate none xrandr -o normal fi
RotateButton.desktop This Gist brought to you by GitHub.
#!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Type=Application Terminal=false Icon[en_US]=/usr/share/icons/gnome/256x256/devices/video-display.png Exec=/path/to/script/TabletRotation.sh Name[en_US]=Rotate Tablet PC Screen Comment[en_US]=Toggles Tablet PC rotation Name=Rotate Tablet PC Screen Comment=Toggles Tablet PC rotation
My big flaw was missing this. You need to copy your path to where you located your file by right clicking and selecting properties. So change this:
 Exec=/path/to/script/TabletRotation.sh 
Here is a screen shot of my button on the Unity toolbar.
One thing about the script is that the buttons on the round arrow pad are not inverted. Will try to fix and post about that later.

No comments:

Post a Comment