“Slide” Animation for Guake in Compiz

As a first goal in getting my hands into Compiz’s code base, I wanted to do something simple. It came to my mind a missing eye-candy feature that I liked when I used Yakuake in KDE: the drop-down animation. This terminal was inspired, as the name suggests, in the console that Quake featured since its first editions.

Now in a Gnome environment the alternative is Guake, but for some reason it doesn’t have the drop-down animation. So I figured I would try to add it by writing a new “Slide” animation type for the Animations plugin in Compiz.

You can check out a diff with the necessary changes in this gist. As you can see, it was fairly simple: mainly writing a new animation class, hooking it up to the list of available animations, and adding the XML specification for its configuration values, from where the actual configuration classes will be auto-generated.

Once compiled and installed as we saw in last week’s post, let’s update the GConf schema:

gconftool-2 --install-schema-file=/opt/compiz-built/share/gconf/schemas/compiz-animation.schemas

Then we use CompizConfig Settings Manager (making sure to run the custom-built version of ccsm) to configure Guake to pop-up using the new animation, by using Compiz’s window-matching rules, in the Animations plugin. The basic option I saw useful to have is the direction from where the window will show up or disappear, which in this case is above.

With a similar configuration, in the Close Animation tab, we can set up how this window will disappear.

The result:

Note that the Calculator was also configured to pop-up and out using the new animation, but with different direction values.

Fun eye-candyness! :D

Batch loading and saving of values in GConf

Last week I had compiled Compiz from source, setting a different path to store its settings in GConf. While I had my Ubuntu-package version of Compiz tuned up to my taste, the values set by default for the compiled version were different, and not even the same as the package version’s settings. Despite the schemas may have changed a little from the package version to the version I’ve compiled, I wanted to give that settings a try with the compiled Compiz.

To set the settings in GConf’s /apps/compiz-1 to /apps/compiz-built-1, we’ll first backup the second branch settings, just in case:

$ gconftool-2 --dump /apps/compiz-built-1 > apps_compiz-built-1.bkp

Then we empty the values in that path, and check the result:

$ gconftool-2 --recursive-unset /apps/compiz-built-1
$ gconftool-2 --dump /apps/compiz-built-1

Finally, we load the settings in the compiz-1 branch into the compiz-built-1 branch. In this process we replace the references to the first path by the path of the second. You can dissect the first command to see the intermediate results.

$ gconftool-2 --dump /apps/compiz-1 | sed 's/compiz-1/compiz-built-1/g' > new_compiz-built-1_values
$ gconftool-2 /apps/compiz-built-1 --load=new_compiz-built-1_values

And that’s it, now the compiled version of Compiz behaves pretty much like the one from the package!

Cheers!

MKV transcoding with Mediatomb

My Android tablet has been kind of picky lately at the time of playing MKV files, which I serve through the Mediatomb UPnP MediaServer running in my desktop. For some reason, a lot of videos play with no problems, but many others don’t.

As I had tried transcoding before in my Arch notebook (though with no success due to its not-very-great CPU power), I went straight to configuring this in my Ubuntu installation. Mediatomb’s configuration file is in: /etc/mediatomb/config.xml. The first thing to do, is enabling transcoding by switching ‘no’ to ‘yes’ in the following line:

<transcoding enabled="yes">

After that, inside the <mimetype-profile-mappings> node we add the following line, indicating that we’ll be transcoding video/x-matroska files using the vlcmpeg profile:

<transcode mimetype="video/x-matroska" using="vlcmpeg"/>

The specification of the profile needs no modifications. Basically, it states that it will be using vlc to stream video transcoded by ffmpeg with the specified parameters:

1
2
3
4
5
6
7
8
<profile name="vlcmpeg" enabled="yes" type="external">
  <mimetype>video/mpeg</mimetype>
  <accept-url>yes</accept-url>
  <first-resource>yes</first-resource>
  <accept-ogg-theora>yes</accept-ogg-theora>
  <agent command="vlc" arguments="-I dummy %in --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=%out} vlc:quit"/>
  <buffer size="14400000" chunk-size="512000" fill-size="120000"/>
</profile>

However, after setting this up I found that the video played just fine, but the audio wasn’t. So I did some debugging.

When the video is playing, you can see the process in action by:

$ ps -ef | grep vlc
116      22168 21899  1 22:00 ?        00:00:37 vlc -I dummy /mnt/2TB/Videos/Movies/Pixars.BURN-E.2008.720p.BluRay.x264-VOA.mkv --sout #transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,aenc=ffmpeg,acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,mux=ps,dst=/tmp/mt_transcode_S0JKIW} vlc:quit

So issuing this call manually from bash, I could see that it was complaining about missing audio codecs, MP3 codecs to be precise:

[0x898eae0] avcodec encoder error: cannot find encoder MPEG Audio layer 1/2/3
*** Your FFMPEG installation is crippled.   ***
*** Please check with your FFMPEG packager. ***
*** This is NOT a VLC media player issue.   ***
[0x898eae0] main encoder error: Streaming / Transcoding failed
[0x898eae0] main encoder error: It seems your FFMPEG (libavcodec) installation lacks the following encoder:
MPEG Audio layer 1/2/3.
If you don't know how to fix this, ask for support from your distribution.

which issuing ffmpeg -formats confirms. In order to get this non-free codecs and googling for a way to avoid the hassle of compiling ffmpeg manually with support for this, I learned about Medibuntu:

…a packaging project dedicated to distributing software that cannot be included in Ubuntu for various reasons, related to geographical variations in legislation regarding intellectual property, security and other issues…

Following the instructions in the website, we can add their repositories to our apt sources and then install the required packages from it:

$ sudo aptitude install ffmpeg libavcodec-extra-53

With this, mp3 support is now built into ffmpeg (as the D = decoding and E = encoding flags indicate):

$ ffmpeg -formats | grep mp3
ffmpeg version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
  built on Jun 12 2012 16:52:09 with gcc 4.6.3
 DE mp3             MPEG audio layer 3

And that’s it, the audio is now playing along with the video just great. Hope it helps! : )

Building Compiz from source in Ubuntu 12.04

For a long time I’ve wanted to fiddle around with compiz’s code, but some months ago an announcement from one of the main developers suggested that the future of the project was uncertain, which got me a little down. However, a few days ago I was happy to read that the project had renewed energies, and a lot of work was being made towards quality and stability. This gave me the push I needed to finally get into it.

I recently installed the last version of Ubuntu in my new desktop PC, moving from the Arch I was running in my notebook, so the instructions that follow will apply at least for Ubuntu 12.04 (Precise Pangolin). The first thing I did was looking for the code base, which I found in Launchpad. I’m not sure if they’ve definitely moved from git to Bazaar, of if I run into the Ubuntu branch of compiz.

Anyway, after creating my Launchpad account and installing Bazaar, I configured ssh-keys for my PC and then logged in:

$ bzr launchpad-login brazzi64

Then, created my local branch from the code in Launchpad:

$ bzr branch lp:compiz

Once the code finished downloading I followed the instructions in the INSTALL, not without running into several missing dependencies in the process. This following commands should deal with them and allow compiz to build successfully (I’m using aptitude, but the same thing can be done with standard apt-get):

1
2
3
4
5
6
7
8
# install the necessary tools first
$ sudo aptitude install cmake cmake-curses-gui intltool xsltproc

# install the library dependencies for building
$ sudo aptitude install libxrender-dev libwnck-dev libgnome-desktop-dev
    libmetacity-dev libx11-xcb-dev libxml2-dev libgconf2-dev libprotobuf-dev
    libnotify-dev librsvg2-dev lcov libboost-dev libboost-serialization-dev
    mesa-common-dev libgl1-mesa-dev libglu-dev libjpeg-dev

Then we continue the process, with some tweaks. First of all, we will modify a couple of files in order to get the custom built version of compiz to store its settings in a different gconf path, avoiding conflicts with the current installation. The one installed in my running session (I’m currently using Gnome Classic instead of Unity) is in /app/compiz-1; this modification makes it store it in /app/compiz-built-1. This diff shows the necessary changes.

After applying this changes, we prepare the makefiles specifying the path where we want compiz installed:

$ mkdir build
$ cd build
$ cmake .. -DUSE_KDE4=OFF -DCMAKE_INSTALL_PREFIX=/opt/compiz-built

The only missing dependency I have left is the following, for which I couldn’t find the necessary package:

-- checking for modules 'gnome-window-settings-2.0;gnome-desktop-2.0'
-- package 'gnome-window-settings-2.0' not found

If you know how to get this dependency met, the tip will be welcome : ) This may be the reason that the output for this command reports “gnome: No” under “Optional features”, but however, compiz seems to run ok. Next:

$ make

with which the building starts. After some minutes you should see this last line indicating success:

[100%] Built target workarounds

Then we install it in our specified location (for which I need root access) just by:

$ sudo make install

Before trying to run it, we have to install the generated gconf schemas into our user session. For this:

$ find /opt/compiz-built/share/gconf/schemas -exec  
    gconftool-2 --install-schema-file={} ;

Finally, we can run compiz replacing the current running instance with the following command. It specifies LD_LIBRARY_PATH for it to load the newly built plugins instead of the ones previously installed in the system, and indicates ‘ccp’ to be loaded at start-up. This is the configuration loading plugin, which will enable compiz to read its settings from gconf and load additional plugins and their settings as specified:

# run compiz and detach it from the terminal
LD_LIBRARY_PATH=/opt/compiz-built/lib
  /opt/compiz-built/bin/compiz --replace ccp &

In order to configure this running instance of compiz, you need to run the corresponding newly created CompizConfig Settings Manager (ccsm), which will read and store the settings in the gconf path we specified at build time (/apps/compiz-built-1):

PYTHONPATH=/opt/compiz-built/lib/python2.7/site-packages
  LD_LIBRARY_PATH=/opt/compiz-built/lib
  /opt/compiz-built/bin/ccsm &

That should be it. Please let me know if you run into any issues or if I made any mistake and I’ll try to do something about it.

Thanks for reading!

Basic HTML/CSS Widget System with Qt

Since I got back into Linux, I’ve been missing a great desktop widget system like SuperKaramba, which I used some years before when my Kubuntu installation was my main OS. Since I currently use XFCE and don’t have any plans on installing the whole KDE desktop just to get SuperKaramba to work, I’m left with a bunch of alternatives that either don’t have enough development activity anymore, or require the widget developer to learn extensive APIs just to get the basic stuff done.

Wouldn’t it be cool to just write some html+css/javascript lines and get a shiny new widget laying on your desktop? In order to get the information the widget needs from the system, one could just add a couple of opening/ending tags enclosing plain shell commands which could be executed with a preset frequency, for a basic use case.

For a couple of months the idea has been itching in my head, so I thought I would give it a try, be it that I can achive a basic but functional prototype, or that I just crash against a titanium wall. Either way, I think it would be a good excuse to practice my C++, improve my modest web-developing skills and learn some new technology :)

Qt + WebKit

Looking for a way to display HTML in the desktop, I easily run into WebKit, an open source web browser engine that happens to be easily embeddable into desktop applications thanks to different libraries (WebKitGTK+, QTWebKit) that merge its functionaility into the different GUI systems. Since I heard very good things about QT, I decided I would give QTWebKit a shot… so after reading some tutorials, installing Qt-Creator and going through some basic tests, I could come up with some basic functionality:

While the application is still very basic, it already does the basic stuff: it stays on the desktop below any other window so that it doesn’t get in your way, uses real transparency so you can see your wallpaper through it, and is able to display an HTML document parsing it while it looks for bash scripts and executes them to get the outputs to insert in the coresponding place. The HTML that generates the result above is the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<html>
<body>
<div style=“background-color: rgba(70%,70%,70%,0.2);
          border-radius: 12px; height: 70px”>
<img src=“computer.png” style=“padding: 12px; float: left”/>
<div style=“padding-top: 12px; font-size: 15px;
          font-weight: bold; font-family: ‘Ubuntu’”>
    <script language=“bash”>uname -sr</script>
</div>
<div style=“padding-top: 2px; font-size: 12px;
          font-weight: bold; font-family: ‘Ubuntu’”>
    <script language=“bash”>uname -m</script>
</div>
<div style=“padding-top: 2px; padding-right: 12px; font-size: 12px;
          font-weight: bold; color: #222; font-family: ‘Ubuntu’; text-align: right”>
    <script language=“bash”>uname -n</script>
</div>
</div>
</body>
</html>

While working on this ideas, I’m also starting to learn Git. I uploaded the code in GitHub, so you can check it out here.

There a lot of things to work on, but the next in my To Do list are:

  • supporting additional delimiters like the ones used in PHP, in this case:
    <?bash bash-script-here ?>
  • specifying the run mode for the script:
    • on load: the script is only executed when the HTML is loaded
    • periodically: the script is run periodically, updating the specific DOM subtree each time with the new output
    • constant: run it on load and leave a pipe open, using the output as it is generated
  • accessing these functionalities throught JavaScript, for greater fun :D

We’ll see where this goes… comments are always welcome : ) Thanks for reading!

Pitch-shifting with GStreamer

Looking to see if there was any extension that could alter the pitch of a song in Banshee (my current favorite audio player in Linux) I found that there wasn’t any, at least at the moment. However, I learned something about GStreamer, the engine that Banshee uses for audio playing and decoding.

GStreamer happens to have some command line tools that let you access its functionality in a really fast way. Concatenating different components through an exclamation mark, you can access functionalities such as mp3 decoding, audio resampling, scaling and what I was looking for, pitch-shifting.

So, by running the following command in the console:

$ gst-launch-0.10 filesrc location=02-have_you_ever.mp3 ! \
    decodebin ! audioconvert ! pitch pitch=1.06 tempo=1.0 ! \
    audioconvert ! audioresample ! autoaudiosink

you should instantly start hearing your favorite song, pitch-shifted one step up (6% pitch) while maintaining the original tempo.

This isn’t really useful for me in this way, but it’s a good proof that the functionality can be added to Banshee. Or maybe, even a small app could be written in order to get the basic functionalities (play, pause, seek) I’d need for practicing songs that don’t use standard tunning in the guitar, along with the music :)