Thursday, December 8, 2011

Graphical connection to a Mac from Linux

For my lab work, I have developed an (almost) cross-platform program based on Qt4 that help us analyze our data. One of the motivations to use Qt was the ability to port the program to other platforms, and in particular MacOSX (half of my team uses them). After installing the required development tools using MacPorts (mind you, the MacOS version of the development tools, not the X11 one), I was able to compile and run the program without a single code change on my bosses' Mac. But here come problems: several things do not work the same way in Mac and in Linux (whereas it should, I think), so additional tweaking and debugging will be necessary.

This is where the problem comes in: I don't own a Mac and don't intend to, so I need to connect to my bosses' Mac in order to perform testing. How can I connect to a Mac display ? X11 connection won't work, since my application is a Mac application and not a X11 one. I had him turn on screen sharing (the most basic tick box), which sets up a VNC server on the Mac. Unfortunately, when I connect using the command-line VNC clients available for debian, ie vncviewer (from the packages xvnc4viewer or xtightvncviewer), I get the following problems:

~ vncviewer chrismac

VNC Viewer Free Edition 4.1.1 for X - built Mar 10 2010 22:31:05
Copyright (C) 2002-2005 RealVNC Ltd.
See for information on VNC.

Wed Dec  7 10:40:41 2011
 CConn:       connected to host chrismac port 5900
 CConnection: Server supports RFB protocol version 3.889
 CConnection: Using RFB protocol version 3.8
 CConnection: No matching security types
 main:        No matching security types

The good news is that remmina is able to connect graphically, although for me it required that I set the display depth to 24 bits (else it seems to connect, but the connection dies immediately). Great, I'll be able to debug, then...

Edit: after a while, I found out that remmina had some drawbacks when connecting to a Mac, such as, at least in my case, a weird problem with Shift: once I hit Shift, I'm never able again to type in lowercase characters, which is quite painful. I tried also Vinagre, who handled that better (but had some quite painful freezing moment), so I must say that I finally found a client I'm happy with: gtkvncviewer.

Tuesday, June 7, 2011

Record sound currently playing to file using ALSA

I've been wondering for a long time about how to record sound which is currently being played on the computer. I know the ALSA framework is powerful enough to do that, and today just proved me so (at least to some extent). It turns out that it's pretty trivial using the file PCM plugin; all you need is a stanza like this in your $HOME/.asoundrc file: {
    type file
    format wav
    slave.pcm front 
    # my main PCM is called front
    file output.wav

Afterwards, you can use this save PCM with the tools that understand it, such as aplay or mplayer:

~ aplay -Dsave stuff.wav
~ mplayer -ao alsa:device=save stuff.wav

(for xine users, you may want to have a look at the audio.device.alsa_front_device configuration element).

Funnier, though, is the possibility to use it with programs that don't provide such an easy way to change that, (say, the flash player in a browser ?) via the use of the default PCM specification in $HOME/.asoundrc:

pcm.!default save

After that, all programs using the default PCM will save the sound they play as a save.wav file in their current directory - but nothing stops you from specifiying an absolute directory. Better yet, you may apparently use pipes in stead of the file name, à la popen.

Simply impressive...

... that's what I think of the work of the FTP Team. Three uploads to NEW in one day, all of which processed in less than half a day. Truly impressive !

Many thanks to them !

Tuesday, April 26, 2011

Newer xorg, missing mouse features and xinput

Recent versions of xorg have seen changes in defaults for the behaviour of mice/touchpads, such as third button emulation or edge scrolling suddenly not working anymore. What is worse now is that the corresponding entries in the xorg.conf are now ignored... Wait, wait, don't go flaming the Xorg maintainers, but keep on looking rather. This is where I found out about xinput, the new way to customize/parametrize input devices for the X server. And, lets face it, it beats any customization that could have been done in xorg.conf ! Here's how to use it.

First, you'll have to install it from its own package (xinput), as it doesn't come bundled with standard X clients. Second, you can find out about the devices connected to your X server using:

~ xinput --list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ SynPS/2 Synaptics TouchPad                id=12   [slave  pointer  (2)]

It is easy to find the device you're interested in (here, say the touchpad entry). Then, you list the properties you can set/get using:

~ xinput --list-props "SynPS/2 Synaptics TouchPad"
        Synaptics Edge Scrolling (269): 0, 0, 0

The list is quite impressive, so I have only shown the one I'm interested in. You see here everything is 0, which probably explains why edge scrolling is disable (I don't have a clue what the actual numbers mean). You can finally change the properties this way:

xinput --set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Edge Scrolling"  6 6 6

This gave me back edge scrolling. I used a similar approach to enable again the third button emulation... What is neat here is that the property names are readable enough, and there's a lot of them to play with. Great !

Tuesday, March 29, 2011

Call for testers: pmount finally supports mounting image files

I've finally come up with a decent way for pmount to support mounting image files using loop devices. This has required a little more work than I thought, since I had to add support for configuration files for pmount, as loopback mounting is by essence insecure, so the support for it had to be user-configurable. I have tried hard to make the loopback mounting as secure as possible, for instance by ensuring that a user cannot bypass file permissions with it, but of course lookback mount still means that a user has read-write access to a mounted FS which can be used to exploit potential weaknesses in the kernel...

I have uploaded a new version of pmount to experimental. Comments, bug reports, exploits are welcome !

Monday, March 7, 2011

Installing a Canon Pixma MP250

I recently acquired a Pixma MP 250 printer, and as I had some difficulties with setting it up, I wanted to share this here. The printer isn't supported as such by CUPS, so I had to dig a little bit. After quite some time, I found debian packages on the Canon website there. Don't fear the mention of i386, amd64 packages are included too. This link is likely to break when the software is upgraded, you should try your luck in the drivers search page should that happen (or for other models). After installing that, CUPS find the connected printer and proposes the PPD for it. The scanner works out of the box with xsane

As a side note, Canon also provides source for the debian packages (the packaged was ITPed ages ago). However, there are some binary-only blobs and I didn't manage to get it to compile from source.

Saturday, February 26, 2011

A praise for TikZ

I have been using xfig for ages to draw figures, and I appreciate it, especially combined with a small script I wrote based on an original idea by Seb Desreux at H&K, fig2ps, that allows painless integration of LaTeX code inside xfig figures.

But recently, it seems that I've hit limitations in xfig. Mainly, if it is great when you want to produce sober figures, whenever you want to do something fancier, including shadings and the like, frustration comes in quickly (since it is purely impossible). I've spent a while looking for a decent alternative, until I had a look again at pgf, which since turned into TikZ. That was amazing. It integrates painlessly within LaTeX and is simply great to work with. Drawing complex diagrams with noes and complex relations between them is trivial. It handles moving the nodes very gracefully, and styling can be done in a CSS-like fashion (though it definitely isn't CSS), which means you can first concentrate on structure and then turn your graph into something nice, while for all the other programs I know, you have to handle both structural and stylistic aspects at the same time.

Sure enough, you need to like the command-driven approach, as mice won't come in too useful here... As a side note, I wanted to express my admiration of Till Tantau's (TikZ's author) mastery of (La)TeX: TikZ can be seen as an interpreter of a simple graphical language written in pure TeX, which is, according to my humble experience with dirty trick in TeX, is simply amazing. Many thanks, Till !

Sunday, February 6, 2011

Doxygen for Ruby, first working draft !

Quite some time ago, I complained about the lack of support of Ruby in doxygen, the ultimate code documentation generator (at least for me). Time has passed, and I had some time and motivation to look into it and write a patch. The code is now reasonably mature to be used, altough it still lacks many features, and, most importantly, testing.

That's why I pushed my git-svn private repository to github today, in order to get enough testing to integrate it into mainstream doxygen. It's current features:

  • Code structure parsing is complete in principle, it should extract all the classes/method definitions. If not, please use the tracker at github, posting a full example showing the problem.
  • It features a rdoc compatibility mode (on by default), in which it parses all comments (outside method definitions) and interprets most of rdoc's markup.
  • The inner code parsing and cross-linking is very ineffective for now; most cross-links are currently not performed. This is one thing on which I'd like to work some day... Although you're welcome to have a go at it if you wish !

You can get an opinion of how it looks on the code of ctioga2. The doxygen configuration file can be found there.

Saturday, February 5, 2011

ctioga superseded by ctioga2

First, some historical details: some 6 years ago, I discovered Ruby together with Tioga, a great library for producing plots. That immediately resulted in my first Ruby program, ctioga. But as years passed and more features were forced into ctioga, I was compelled to see my initial design mistakes, and think about a complete rewrite.

This is where ctioga2 was born, some time at the beginning of 2009. I completely stopped using the old ctioga a few month after starting to work on ctioga2, but it took ages before I finally came up with a decent enough documentation to release and announce publicly. But now, it's done, and the first public release of ctioga2 is out, still fresh !

Here are a few highlights of the differences:

  • For me, it's day and night: adding new commands is painless: I only need to create an object with the appropriate code; registering is done automatically.
  • Now, command-line switches also accept options looking like this /option value that allow many small tweaks I had never had the courage to write for the old ctioga as it was way too painful to add new commands there.
  • ctioga2 can be driven both from command-line and using command files, in the style of gnuplot, which is the reason why I call it polymorphic.
  • More importantly, I finally had the possibility (and more or less compelling reasons, to be found in a paper currently in press) to implement 3D data displays in ctioga2, in the form of color maps (that's what is shown here).
  • There are still a few things that could be done by ctioga and that miss from ctioga2, such as histograms. When I have some time and/or motivation...

In any case, you can make yourself an opinion of ctioga2 by looking at the galleries.

Enjoy !