x2c - the interactive ruby compiler

The client itself is an irb shell executing commands on the client object, which has been extended to get a powerful and easy interface to playback, playlists and collections. As it is all ruby, you can easily extend its functionality, create new aliases or functions, or create you own client on top of it.

First Steps

Installation

If you want use the gem (to keep you system clean or things like that), just build it out of the gemspec and install it:

gem build x2c.gemspec
sudo gem install x2c-0.1.gem

But you also can simply copy the x2c folder somewhere on your disc and run ./x2c directly or symlink to it.

Usage

If you start x2c, you will be confronted with a short tutorial helping you with the first steps in x2c. After you finisched the tutorial and seted up the config, you can use x2c normally. You can get descriptions about functions and modules with the help command.

the design

x2c creates a new xmms client objects, and starts a new irb workspace with the client as its main object. Both client and workspace are extended to have some extra functionalities.

So all you do is calling functions with arguments on the xmms client. Therefore you must type valid ruby syntax, but it allows you to get all the power of ruby. There are 3 main objects inside the xmms client lib and inside my client:

  • the client itself: where all the function calls go. It is the interface to daemon, you can git information about the medialib and change playback with it.

  • playlists: they are play ;) and song are removed, moved or inserted

  • collections: powerful way to express media queries

  • theres also another thing called Songlist, which is used to pass around song ids

the interface

All output is formated to give you information about the objects you process and the state you are inside

understanding the output

the commandline

The commandline will show the playback status, e.g. ‘>>’ for PLAY, ‘||’ for PAUSE and ‘[]’ for STOP, and the song currently played followed by a Symbol to show you what mode you are in, dependent of the command what irb expects you to do.

In addition to that, the async module will put out ‘->’ followed by the new Song, whenever the current Song changes.

results

The results of your commands will be put after a ‘=>’. As that results will be often used for further processing, there is a variable that holds useful results. All results considered useful are marked with a trailing ‘`’ , so whenever you see a ‘`’ in front of a output, the last variable is set. You can explicitly make a result last, if you append .makelast to your command. Furthermore you can push results to the stack to pop them later. Just used (command).push to push the result, or just push to push the last result. You also can restore the prelast result with the lost command.

Results will be printed after the => in a readable way:

  • collections will show the hole tree of operations: first the operations and its options are printed, followed by its operands in the next line. Operations are shown as symbols, ‘%’ for pshuffle ‘:’ for idlist, ‘]’ for a queue, ‘>>’ for a reference, ‘!’ for complement, ‘&’ for intersection, ‘|’ for union, ‘=’ for a field equals value collection, ‘~’ for a Match, ‘>’ and ‘<’ for comparing and ‘E’ for existents of an attribute.

  • playlists show the collection on which they are based on and the list of songs. The current song will be marked with a ‘>’

  • Songlists just how there Songs

  • Arrays and Hashes show all of their members

functions calls and message passing

Message passing

All classes have gained additional functions, and messages are often passed to other classes. The client object for example will forward messages to Collections or the playlist and the last result object. Playlists itself will pass unknown functions to its current Collections. Collections will try to make itself a playlist when needed. Songlists and id-Arrays will try to be the same, just that Songlists have some extra functionality and a nicer output.

Functions

The help command uses the autogenreate rdoc to give you help about all the functions and objects. just uses the help command to get all the information.

help
help{Client}
help{Client::<Inculded Module>}
help{<command>}
help{Collection::<Inculded Module>}
...

Client Configuration

You can configure the client with the .config/xmms2/x2c/config.rb file. You first have to copy the default configuration with the setup command. Afterwords you can use the configure command to edit the file.

PS: feel free to ask me or say what you like/dislike.