Pages

Sunday, February 28, 2010

Learning Python to make an applet in Gnome

Last week while using my Windows 7 partition, out of habit I hit "ctrl+alt+R arrow" which in Linux changes to the right virtual desktop,but; in Windows 7 it rotated my screen from landscape to portrait. I thought that was cool, and that it would be great for reading ebooks. I set off looking for an applet to make my screen rotate like that in Linux.  I had no luck in finding one, that does not mean it is not out there I just could not find one. I decided maybe I could make one mostly because of Paul Grahm in his book "Hackers and Painters" . He talked about writing code like sketching, That made perfect sense to me, that line demystified the idea of writing code to me. Of course that does not mean I will be good at it, it just mean I feel like I can give it a try. A day later Jono Bacon put a challenge to write an application by March 4th and post it to his blog.
 I was like what the hell I will give it a go, I am not sure what i am doing qualifies as an app, it will hopefully be an applet when I am done.


I went on and figured out what command I needed to rotate the screen right which is "xrandr -o right" and to get it back is "xrandr -o normal", you can also use left and inverted as options. I can run those in terminal to achieve what I want. Ultimately I want a applet on the panel that I can click a drop down menu or toggle a button. The menu would have four options, normal,right,left and inverted, this an image of my first try. Now I have to learn how to  make the selected options run the different commands







Below are images of my first succesfull try at getting a  button to kind of work, below is normal before I pressed and the second image after. 

 


The problem is I have not figured out how via a button press, to switch back.  Making an on off button, were "on" would rotate to portrait, "off" would be back to normal.  The only other issue with this way is it only gives two options, unlike the menu that would allow for all four. Well back to the sketch pad.