25/8/08

Irssi with recode and systray notification (sorta) :>

Now, you may wonder what kind of troubled childhood could ever cause such desires, but don't let your imagination run wild as you obviously have never tried to chat on a greek irc server with fellow greek nerds.

The facts:
  • last century and premature cybersex efforts gave us greeks "greeklish": greek written using plain ol' latin
  • most greek irc users still prefer to use greeklish
  • I don't
  • mIRC and Windows left us with iso-8859-7
  • I use unicode
  • I want to read and write iso greek in tab #1 (=old school geek/some other poor soul denying that resistance to unicode is futile) and in tabs #2,3,4.. I want to stick to my beloved utf8
  • xchat is known to be able to handle (some) encoding extremeties, but I haven't been able to handle xchat to do what i want. Scripts promising dynamic encoding did not work for me.
  • irssi can do that out of the box
  • X-chat has this helpful and addictive feature of blinking the systay icon when somebody writes your nick or privately messages you
I've been torn between irssi and xchat for long. I've been mean to iso users but only end up changing charsets manually on X-chat and .. well, a mess. I needed irssi, and I needed it to pretend it cares about notifications. (that did sound like some cheesy action movie line, didn't?)

So here's what I did, in case anyone, anywhere, ever, finds it useful:

(note: I'm using debian, so I won't mind with installation instructions, if you use something else, may the gods be with you)

1. Install a sweet little application that is called alltray that can put any program you want on your systray.

Here's its help menu, so that you get an idea:
alltray -h

AllTray Version 0.69

Dock any program into the system tray.

usage: alltray [options] ["] [program parameter] ["]

where options include:
--help; -h: print this message
--version; -v: print version
--debug; -d: show debug messages
--show; -s: do not hide window after start
--icon; -i : use this icon
--large_icons; -l: allow large icons (> 24x24)
--sticky; -st: visible on all workspaces
--skip-taskbar; -stask: not visible in taskbar
--no-alltray; -na: no "(Alltray)" in window title
--borderless; -x: remove border, title, frame (if not supported native)
--menu; -m: "menu text:command": add entry to popdown menu
--title; -t : show tooltip with title for seconds after song change
--geometry; -g [x][{+-}{+-}]: initial position (if not supported native)
--key; -k [Modifier:]Key: Keyboard shortcut:
Modifier="Shift", "Control", "Alt", "AltGr"
Key (Examples) = "a", "F1", "End" ...
or "Keycode" (Number) returned by the program "xev"
--notray; -nt: display no tray icon (usefull only with the "--key" option)
--nominimize; -nm: click on window close button: do not minimize back to system tray, close
--configure; -conf: show KDE configuration dialog
2. Make sure you have a way of calling your favourite terminal program and providing the command for it to execute as a parameter.

I used gnome-terminal, which fits quite nicely in my xfce and supports profiles.
-> I created a new profile, which I named "irssi" and then
-> on the "Title and Command" tab of the Profiles configuration menu I set the initial title to "irssi", and
-> checked "Run a custom command...". The custom command is, of course, irssi.
-> in "Colors" I chose the "Linux Console" palette
-> I also choosed a lame profile icon, and maybe you should, too! :P (see screenshot at the end)


3. I added a Launcher icon on my xfce panel (you can choose a desktop launcher or whatever suits you better) that
-> is called "irssi"
-> runs a custom command which is
alltray -na -s -t 5 -g 600x400+150+150 "gnome-terminal --window-with-profile=irssi --hide-menubar"
-> has a silly icon, too

Now let's see what all these options are about:

-na avoids "Alltray" being appended to the window title // seems to not work as expected in most versions, you should try version 0.70, where the default is not to show "AllTray" and the option does not exist anymore
-s does not hide the window after starting the app
-t 5 tells alltray to keep the tooltip visible for 5 seconds after a window title change. This is very important, as we'll see below.
-g 600x400+150+150 defines the newly created window's geometry (size, and position on the screen) this is the standard way of declaring a window geometry, if you need help google will have plenty

(note: alltray v 0.70 has the "key" option, which provides a keyboard shortcut for the display of the window, I haven't thoroughly tested it but it seems to not work with my X/setup)


and then we provide the command to be executed by alltray, in my case

gnome-terminal without a menu (won't be using it as a normal terminal) and a custom profile : irssi, which we defined above


This way we have irssi up and running, handy in our panel/desktop/whatever and easily accessible from the system tray. Also we have a tooltip that gives us the current window title, which is displayed
- when we put our mouse over the respective systray icon
- when this title changes

4. Next, we configure irssi to do the encoding juggling we were talking about in the beginning of this post.
(note:
This is an informative post, that is written by a person who probably has a much more coherent writing than me and covers the recode thingy. I'll go ahead and write about it, giving my very own setup.
)

If you are using debian, ubuntu or any other sane distro, recode will be available to you in irssi without any hassle. The variables we need to take a look at and/or change are the following:

  • term_charset: Just type /set term_charset and check to see that the value is UTF-8. If not go ahead and type /set term_charset UTF-8. That's the way to tweak the options in irssi, and I won't be as explicit in the rest of the text. If your terminal's encoding is not UTF-8, then you probably shouldn't be following this howto to begin with.
  • recode_autodetect_utf8: Make sure it's ON
  • recode_fallback: set it to iso8859-7 if greek is your thing, or any other encoding you may be using. This is the encoding irssi is going to fall back to, in case the characters received don't make for a valid unicode sequence. Irssi "detects" that this was not unicode your mIRC user friend just sent you, and tries to recode it to something that makes sense, what's that going to be? you name it (here)!
  • recode: ON, of course
  • recode_out_default_charset: mine is utf-8, once again. This defines, obviously, the encoding of the stuff you are going to send to other people. Choose this to be the one that is more widely used, or if you are a rude sob like me, choose this to be your favourite encoding and screw those stuck in the past. Remember, you are going to be able to have per-user or per-channel exceptions, so don't worry too much.
  • recode_transliterate: once again, set this to ON
Go ahead and /save your options, or irssi will do it in a while automatically.

5. Start populating your recode table with obnoxious other-encoding users. Let me show you mine, to give you an idea, and then I'll give an example of adding a new entry.

by hitting /recode we get our recode table:
00:00:59 Target Character set
00:00:59 bodyfluids iso8859-7
00:00:59 zafos iso8859-7
In order to add those bitches to the recode table, I had to issue the following command:

/recode add bodyfluids iso8859-7

Or if you're in a hurry or just like it as simple as it gets, just write
/recode add iso8859-7 on a query window with the target nickname.
You'll get a message confirming what just happened, and you're ready!

The same things apply to channels, too. But I'm not going to give in, just yet. I'm going to bombard them with unicode strings until they rethink about their stand on the issue :P


6. And now, to the dynamic title that's going to give us the notification part:

Install the bundled irssi scripts ("irssi-scripts" on deb*, who knows what elsewhere) and load the title script. Just type /load title.pl or /load /usr/share/irssi/scripts/title.pl and it'll do.

(note: to do it automatically every time irssi starts -from the officialy site-
A: Put them into ~/.irssi/scripts/autorun/ directory. Or better would be if you placed them in ~/.irssi/scripts/ and created symlinks to autorun directory (eg. cd ~/.irssi/scripts/autorun/ ; ln -s ../script.pl .))


From the script's comments, we get some information on the usage:


# The $vars are normal Irssi vars (docs/special_vars.txt).
# $.var does some magic, adds a space at the begining and brackets around
# the item but only if it produces output.
# Here is some examples:
# The default:
# /set title_string Irssi: [$N@$tag]$.C$.winname$.act
# Quite nice with lots of info:

# /set title_string $cumode$winname$C$.M$.act$.topic

# Nickname with usermode

# /set title_string $N(+$usermode)
And, by setting
title_string to $cumode$winname$C$.M$.act$.topic for a very informative title, or just $.act for the hilights etc (note: i finally settled with [$N@$tag] $.act ), we do indeed get the desired behaviour:

...(tata!) when we have a hilight or when someone sends us a private message, etc, the title of the window changes, and addtray displays a tooltip for 5 seconds, informing us about the new title, which is the nickname(s) that sent us a private message, and the channel(s) that our nick was mentioned. We can reproduce this any time we want (see: finishing up that thing you were doing and want to check if anyone's been interesting in chatting) by letting our mouse over the irssi systray icon!

Here are some screenshots, that probably won't help you, but will make a fool out of me and a friend or two:

the tooltip

the title indicating that I have some private message that I haven't already checked.


Now that I've written this annoyingly long post, let me inform you that you can get notifications on irssi by using libnotify, without doing all the above but by following this howto.

Cheers! (I mean.. who cares about libnotify, anyway, right??)


2 σχόλια:

Έχεις κι εσύ μια γνώμη; :>