Bash: show the currently running command in the window title

I was just learning for an exam (and taking glimpses at irssi) when a thought hit me: “wouldn’t it be nice if Terminator showed the currently running command in the window’s title”.

So, I asked Google and found a pretty nice post on how to do it. At first the proposed solution resulted in some weird messages being printed, but just changing the order of a line fixed it, so here’s the working code for bash in Ubuntu Intrepid:

if [ "$SHELL" = '/bin/bash' ]
then  case $TERM in

rxvt|*term)

set -o functrace

export PS1="\e]0;$TERM\007$PS1"

trap 'echo -ne "\e]0;$BASH_COMMAND\007"' DEBUG

;;

esac

fi

Pretty nice, eh? Now, if someone’s up for a challenge: if it showed the command being executed inside screens instead of just “screen -r” that would be even greater.

Edit: And if someone knows how to get WordPress to display the messages properly that would rock.

Edit 2: I’ve just noticed that this breaks tab completion, so it’s not that nice after all.

REVU Days

What is REVU?

REVU is a website where contributors can upload new packages they’ve created for Ubuntu Developers to review and comment on them. If two Ubuntu Developers are happy with a package, it enters repositories of the current Ubuntu development version.

What are REVU Days?

REVU Days are weekly events which span over an entire day, during which Ubuntu Developers are likely to give special importance to reviewing packages from REVU. Contributors who want to get their stuff reviewed are highly encouraged to be available -and ask for reviews- on #ubuntu-motu (at irc.freenode.net) so that reviewers can easily contact them about any problems.

There haven’t been many REVU Days those last months, but they will start to happen again periodically once the development cycle for Ubuntu 9.04 (Jaunty Jackalope) starts. This brings us to the following question:

What weekday will they be?

The answer to this questions depends on you; vote now on http://ubuntuforums.org/showthread.php?t=940783!

Catching up with that other system

GNU/Linux is improving fast and can already replace Windows in almost all cases, but there are still some areas where we really have to catch up with what is currently the most used operating system. I mean, come one, we don’t even have a Blue Screen of Death!

Well, now this is no longer true. Some months ago I decided to have a go at fixing this sad issue, and here it is: the BSOD for GNU/Linux, freely available on my PPA.

This little application comes perfectly documented with a manpage and has features as important as: random selection between a bunch of real error messages, allowing to change the name of the OS to show (bsod –system=ReactOS), a realistic mode where the victim will have to type “FS” or “GNU” to quit (bsod –realistic), and the possibility to have it running in the background and pop up after a random amount of time (bsod –delayed), amongst others!

Ubiquity – Connecting the web with language

Today I’ve discovered about the existence of the Ubiquity project, but no, not Ubuntu’s installer – this Ubiquity, from Mozilla Labs, is a really curious plugin for Firefox.

Ubiquity allows you to execute web related actions by writing commands with a natural syntax, in a way somewhat similar to Gnome Do. I’m not going to show any example because I can’t find a good way to explain all of it’s potential, other than “try it yourself” (ah, and pointing to the video here).

You like it? Great; here is some good news for those of you involved with new applications packaging: Thanks to the efforts of Olivier Girardot and Jonathan Winandy there is now a “revu” command which will show you the last comment for any package and open its details page in a new tab if you press [return]. And for those who want to be notified of new comments instead of hunting them down, I remember that there are also personal/package feeds available since a while.

Writing a command and control application with voice recognition

Have you ever dreamed about controlling your PC with voice commands? Well, now you can (though only some specific actions)!

What do I need?
- A computer with Ubuntu (you can still do the same on other distributions, but this post won’t cover that).
- A microphone (a cheap one will do).
- Some application(s) which you want to control and which can be used with commands on the terminal.

Installation
Go over to my PPA and install packages julius and julius-voxforge from there.

Writing the command and control application
Follow the instructions from /usr/share/doc/julius-voxforge/examples/README to create your own grammar, and then edit the command.py file to suit your needs (the simplest configuration would be to just edit the dictionary near line 60). Finally, to execute it: julius -quiet -input mic -C julian.jconf 2>/dev/null | ./command.py

Problems
I don’t really have much experience with Julius, but if you have problems with the instructions explained here leave a comment or ping me on IRC (RainCT@Freenode) and I’ll try to help you. But first look at the examples below to ensure that you’ve done everything right :).

More?
I’m currently working at further improving those packages and getting them into Ubuntu. Also, I may write another post in the future explaining how to create your own speech corpora and acoustic models, but I can’t promise anything.

Example on how to control Rhythmbox:

* example.voca:

% NS_B
<s>	sil

% NS_E
</s>	sil

% ID
DO	d uw
COMP	k ax m p

% COMMAND
PLAY	p l ey
NEXT	n eh k s t
PREV	p r iy v
SHOW	sh ow
UP	ah p
DOWN	d aw n
SILENCE	s ay l ax n s

* sample.grammar

S: NS_B ID COMMAND NS_E

* command.py’s parse function

def parse(line):
    params = [param.lower() for param in line.split() if param]
    commands = {
        'play': 'rhythmbox-client --play',
        'silence': 'rhythmbox-client --pause',
        'next': 'rhythmbox-client --next',
        'prev': 'rhythmbox-client --previous',
        'show': 'rhythmbox-client --notify',
        'up': 'rhythmbox-client --volume-up',
        'down': 'rhythmbox-client --volume-down',
    }
    if params[1] in commands:
        os.popen(commands[params[1]])

* Usage: (Action – Verbal command)

Reproduce - DO PLAY
Pause - DO SILENCE (I didn't use "DO PAUSE" because like that it had a very high error rate)
Next song - DO NEXT
Previous song - DO PREV ("DO PREVIOUS" can't be used because VoxForge's acoustic models don't support some of it's phonemes)
Show the name of the current song - DO SHOW
Increment Rhythmbox's volume - DO UP
Decrement Rhythmbox's volume - DO DOWN

Random tip:
You can let the computer answer to your commands using either espeak “text to say” or, if you have Festival (which sounds more natural) installed, festival -b ‘(SayText “text to say”)’.

Happy hacking!

 
web development