Thursday, March 25, 2010

Download trailers from iTunes

I just don't want to visit http://trailers.apple.com every time I want to know about new movies, instead I would like to automagically have those files downloaded to a directory. I created a small script for this purpose.

First, visit the link above (just to learn your way around Apple's trailer site) select a movie and and choose a resolution. You usually have 3 HD options on a movies' trailer page: 480p, 720p and 1080p.
Right-click on the specific Resolution button and select Copy Location.

With the movies' URL copied and pasted, here's is an example for the movie "Wild Grass":

$ wget -U "QuickTime/7.6.2 (qtver=7.6.2;os=Windows NT 5.1Service Pack 3)" --referer=http://trailers.apple.com/movies/sony/wildgrass/ http://trailers.apple.com/movies/sony/wildgrass/wildgrass-tlr1_h720p.mov


No magic here except the User-Agent string. If you don't provide the proper user agent (means: lying that we are a Quicktime player), you won't get the movie file but only an .html file. The referrer is just here for the safety's sake, omitting it won't cause any problem.

Saturday, February 13, 2010

How to speed up a GNOME panel's autohide animation

The whole thing started when I installed Cairo-Dock but wanted to keep my top GNOME panel for a few exotic settings like starting VPN (or for those things I can do blindfolded). I set the panel to Autohide, but the speed it appeared and disappeared was very slow, and I wanted to change it.
There are lot of good advice on the net, but all of them was based on using gconf-editor. Turned out, gconf-editor sucks.

Okay, it is still beta or what, but it simply fails to load all .xml files up from ~/.gconf parent dir, which I don't feel as a technological challenge.

If you ever happened to delete/create/delete-again/create-again a few GNOME panels, and now you have only 1 panel on your desktop, the only thing uncertain, is its name.
Mine is "bottom_panel_screen0", and it is not in gconf-editor's list. To find it easily (meaning "few typing, less thinking") I set my panel's height to a crazy 149 pixel and did a full search on the ~/.gconf directory with some help from 'grep'. BUT, if you are to issue this command, wait about a minute or drink a coffee after setting that 149 in the panel properties. It needs 'bout a freakin' minute to get this data written back to file.

$ find ~/.gconf -name "*.xml" -exec grep 149 {} \;

Now you have the file, you can modify those values inside it. You may find that there are no values associated to certain parameters like 'unhide_delay', 'hide_delay'. Those parameters are set as default elsewhere, but you can still override them here.
You could edit the .xml file itself with your preferred text editor, but gconftool-2 seemed to be the nice way of modifying parameters.

4 parameters that matter:

enable_animations

If you set it to 'false' the panel will pop up in a fraction of a second. When it is true, the panel will appear animated. I like it set to false.

$ gconftool-2 --set /apps/panel/toplevels/bottom_panel_screen0/enable_animations --type bool "1"


animation_speed

Defines the speed of animations, if that is turned on. Possible values are: fast, medium, slow. If you set the parameter to some gibberish, the last settings stays active. If you have a slow video card, speed may seem sluggish.

$ gconftool-2 --set /apps/panel/toplevels/bottom_panel_screen0/animation_speed --type string "fast"


unhide_delay

If you placed your mouse cursor where the panel should appear, this is the amount of milliseconds the system waits before the panel pops up. This works even with disabled animation. I suggest to keep it high to avoid unwanted popups if your mouse cursor wanders to the activation area.

$ gconftool-2 --set /apps/panel/toplevels/bottom_panel_screen0/unhide_delay --type int 1000


hide_delay

If you moved your mouse cursor away from the panel, this is the amount of milliseconds the system waits before the panel disappears. This works even with disabled animation. I suggest to keep it low to make the panel disappear as fast as possible.

$ gconftool-2 --set /apps/panel/toplevels/bottom_panel_screen0/hide_delay --type int 200