Attila Oláh

SRE @ Google Zürich

  • 19 Mar 2011

    Compositing in awesome

    A while ago I wrote two widgets for awesome. Later on I’ve added a little more look&feel to my awesome desktop.

    Compositing

    Very easy, via xcompmgr. I don’t like the huge default shadows (nor pretty much any of the default settings), so I start it from my rc.lua like this:

    awful.util.spawn("nautilus -n")
    awful.util.spawn("xcompmgr -c -C -f -F -D 2.5 -l -2 -t -2 -r 2 -o 0.25")

    Note that I need to start nautilus before running xcompmgr, otherwise tha background won’t word. Passing -n to nautilus will get rid of the desctop icons. Now I get to see the GNOME desktop background instead of my awesome background image, but it’s easy to change using the gconf-editor.

    A shiny new GTK engine

    While there, I also set up a new GTK engine. For a while I was using the Aurora GTK engine, but I wanted something simpler. Then I stumbled upon the Equinox GTK engine. Simple and nice. The tooltips are very similar to my awesome’s color theme. The buttons are smaller, good for laptop screens. With the light shadows and fading provided by xcompmgr, this engine looks great and works really well with awesome.

    Awesome WM widgets GTK Equinox theme

    Neutral Plus cursor theme

    This is probably the best looking cursor theme in awesome. It’s very similar to the default X cursor theme, so it is unnoticable if an app doesn’t support Xcursor and falls back.

    Easy to install, just add this to your ~/.Xresources:

    /* Cursor theme: */
    Xcursor.theme: Neutral_Plus
    

    Color theme & font settings for urxvt

    My ~/.Xdefaults looks something like this:

    /* Fonts: */
    URxvt*font:             xft:Bitstream Vera Sans Mono:pixelsize=12:autohith=true:antialias=true
    URxvt*boldFont:         xft:Bitstream Vera Sans Mono:pixelsize=12:bold:autohint=true:antialias=true
    URxvt*italicFont:       xft:Bitstream Vera Sans Mono:pixelsize=12:italic:autohint=true:antialias=true
    URxvt*bolditalicFont:   xft:Bitstream Vera Sans Mono:pixelsize=12:bold:italic:autohint=true:antialias=true
    /* Colors: */
    URxvt*colorBD:          #ffffff
    URxvt*foreground:       #b2b2b2
    URxvt*background:       #000000
    URxvt*color0:           #303030
    URxvt*color1:           #b21818
    URxvt*color2:           #18b218
    URxvt*color3:           #b26818
    URxvt*color4:           #1818b2
    URxvt*color5:           #b218b2
    URxvt*color6:           #18b2b2
    URxvt*color7:           #b2b2b2
    URxvt*color8:           #686868
    URxvt*color9:           #ff5454
    URxvt*color10:          #54ff54
    URxvt*color11:          #ffff54
    URxvt*color12:          #5454ff
    URxvt*color13:          #ff54ff
    URxvt*color14:          #54ffff
    URxvt*color15:          #ffffff
    URxvt*underlineColor:   #b26818
    /* Borders: */
    URxvt*externalBorder:   0
    URxvt*internalBorder:   0
    /* Scrolling: */
    URxvt*saveLines:        12000
    URxvt*scrollBar:        false
    URxvt*scrollTtyKeypress:true
    URxvt*scrollTtyOutput:  false
    URxvt*scrollstyle:      plain
    URxvt*secondaryScroll:  true
    /* Misc: */
    URxvt*loginShell:       false
    URxvt*urgentOnBell:     true
    URxvt*fading:           30
    URxvt*shading:          15
    URxvt*transparent:      false
    
    • programming
  • 26 Feb 2011

    Python exception weirdness

    This may have been obvious to others, but I have just found out that in Python, when Exceptions get raised, they are converted to strings. That is:

    >>> class C(object):
    ...     __str__ = lambda s: '<C: str>'
    ...     __repr__ = lambda s: '<C: repr>'
    
    >>> c = C()
    >>> exc = Exception(c)
    
    >>> exc
    Exception(<C: repr>,)
    
    >>> repr(exc)
    'Exception(<C: repr>,)'
    
    >>> str(exc)
    '<C: str>'

    And now comes the interesting part:

    >>> raise exc:
    Traceback (most recent call last):
    ...
    Exception: <C: str>

    The traceback displays the Exception class’s name (__class__.__name__), and the parameters passed when instantiating the exception, converted to string (str())! The same thing happens in both Python 2 and Python 3.

    The thing is, I’d expect repr() instead of str(). But good to know how it works. If I want to see consistent output in both pdb and tracebacks, I just need to use classes where str(obj) == repr(obj), that is, obj.__str__ is obj.__repr__.

    • programming
  • 12 Feb 2011

    2011 a][rtsprint Vienna

    The artsprint was a one-week Python/Pyramid/Node sprint at the ]a[ Academy of Fine Arts, Vienna. 27 Participants were mostly BDA people, with the addition of some other Python enthusiasts.

    Buttons, yay!

    We’ve been working on a stack of libraries that most of use on a daily basis, focusing mainly on writing documentation, fixing tests, and converting the whole stack from repoze.bfg to Pyramid.

    And we even had a button machine.

    As a result, we:

    • released Plumber 1.0 (an alternative to mixin-based extension of classes)
    • updated Node, Yafowil (and its widget libraries) and cone.* to Pyramid
    • improved the documentation of the stack
    • set up a buildbot to run periodical & on-demand unit-tests and code checks
    • worked on agx
    • had some productive discussions
    • met new friends & did some key signings
    • spent some quality time at the Metalab
    • had loads of fun in Vienna!

    Metalab in Vienna Metalab in Vienna. Picture: Wikipedia.

    • programming,
    • travel
  • 29 Jan 2011

    2011 Startup Weekend Brussels

    The Startup Weekend seems great so far. Running surveys, advertizing, planning a business, playing the Kinect, beer, mandarins, lots of interesting people, and planning various cow usage.

    Startup Weekend logo

    So far not much coding though. I’ll just have to make up for it next week at artsprint.

    • travel
  • 22 Jan 2011

    Merging mkv files

    A while ago I was looking for a way to merge two separate .mkv files (left and right views of a stereoscopic, 3D movie) into one file, to get a side-by-side or top-bottom view. Since back then I didn’t get any answer on SuperUser I’ve got an answer, I figured I might just look into it myself, google it, read a few man pages, and then write it down for the rest of the world.

    I’m not encouraging anyone to download pirated films. But, if you do have the movies, and they are in separate files, but you want to watch them on a 3DTV or a PS3 that can only play side-by-side, single-file 3D movies, you’ll end up merging your files.

    If you just want to know how to merge these files using the GUI, I’m not going to write it down here, as there exists a very detailed tutorial about this over at Ameic.net. Go read that if you want to do this using the GUI.

    If you’d rather do it in the command line though (which would allow you to create a batch to process all your movies later, nice the process while you’re working on the computer, and ler it rock while you’re away), read on.

    Here’s what you’re going to need:

    • mkvtoolnix
    • ffmpeg
    • avisynth

    mkvtoolnix is a free, open source tool. In Gentoo, you can get it from Portage. ffmpeg is also available for Gentoo. You can find out more about Avisynth on their home page.

    $ sudo emerge -at mkvtoolnix

    Note that if you build it yourself, there’s also an --enable-qt option, but for some reason a qt use flag does not exist in the ebuild. Also, I don’t build ffmpeg here as I already have that on my system.

    Next thing you’ll need to do is extract the audio you want. Use eac3to to do so:

    $ eac3to video-left.mkv sound.ac3

    Update 1

    As Marcin mentioned, you can extract the autio simply using ffmpeg, you don’t need eac3to:

    $ ffmpeg -i video-left.mkv -acodec copy audio.ac3

    Next thing you’re going to do is extract the video streams of both left and right files, and convert them to side-by-side view. To do so, you’ll need to generate an .avs file that looks like this:

    videol=DirectShowSource("/path/to/video-left.mkv")
    videor=DirectShowSource("/path/to/video-right.mkv")
    video=StackHorizontal(videol, videor)
    BicubicResize(video, 1920, 1080)

    Name this file convert.avs, then process it with ffmpeg like this:

    $ ffmpeg -i convert.avs -vcodec libx264 -b 7500000 -bt 7500000 -y video-sbs.h264

    Now merge the audio and the video:

    $ mkvmerge -o result.mkv --default-duration 0:24000/1001fps video-sbs.h264 audio.ac3

    The resulting result.mkv file can now be played on a 3DTV or a PS3. You can now remove the temporary files:

    $ rm sound.ac3 video-sbs.mkv convert.avs

    Update 2

    I’ve just got an answer on SuperUser. In short, here’s how to do it with GStreamer:

    $ gst-launch-0.10 \
        filesrc location=MVI_0735L.MOV ! decodebin2 name=Left \
        filesrc location=MVI_0735R.MOV ! decodebin2 name=Right \
        Left.  ! videoscale ! ffmpegcolorspace ! video/x-raw-yuv, width=1280, \
                 height=720 ! videobox border-alpha=0 right=-1280 ! queue ! mix. \
        Right. ! videoscale ! ffmpegcolorspace ! video/x-raw-yuv, width=1280, \
                 height=720 ! videobox border-alpha=0 left=-1280 ! queue ! mix. \
        Left.  ! decodebin2 ! audioconvert ! audiopanorama panorama=-1.00 ! \
                 queue ! addaudio. \
        Right. ! decodebin2 ! audioconvert ! audiopanorama panorama=1.00 ! \
                 queue ! addaudio. \
        adder name=addaudio ! faac ! avmux. \
        videomixer name=mix ! ffmpegcolorspace ! x264enc ! \
        avimux name=avmux ! progressreport name="Encoding Progress" ! \
        filesink location=out.avi
    • programming
  • 04 Dec 2010

    Two simple widgets for awesome

    The two widgets next to the system tray:

    Awesome WM widgets Awesome WM widgets

    Battery monitor

    This one is pretty simple, based on this wiki page: (requires acpitools):

    The nice thing about it is that it changes its color dynamically (and linearly). 0% battery = #FF0000, 100% = #00FF00.

    CPU temperature monitor

    Based on the same code, looks very similar to the battery widget:

    Update

    I’ve updated the temperature monitor to work without acpitool. Now instead of relying on legacy files in /proc/, it uses the new ACPI interface provided by /sys/ files.

    I have also replaced the battery monitor with the gnome-power-manager applet, as it is more powerful and consumes less on-screan real estate. Start it from your rc.lua like this:

    awful.util.spawn("gnome-power-manager")
    • programming
    Source
Previous
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
Next
Attila Oláh //
atl@google.com