Image of the glider from the Game of Life by John Conway
Skip to content

Dvorak-QWERTY Irssi Script

In #utah on Freenode, there has been some active discussion lately about Dvorak vs. Qwerty. As such, ibot, a channel bot, has the ability to display text when someone enters a channel. Some of the chatters, including myself, have a join that is "encrypted". Well, not really, per se, but rather, just Dvorak text that was typed using the QWERTY layout. One such join is as follows:

>>> vontrapp
Dr, co yd. Ekrpat jrmcbiZ

Not exactly intuitive as to what is trying to be said. The only way to figure it out, is set your keyboard layout to Dvorak, and type the letters as they would appear on a QWERTY keyboard. Doing so would produce:

>>> vontrapp
How is the Dvorak coming?

As we began discussing in the channel, we thought that it would be great if we could have ibot do the decoding for us. Well, I'm not familiar with blootbot or it's scripting capabilities, so I wrote a script for Irssi that can convert any "Dvorak text" to QWERTY and vice versa. The commands to run are '/dv some text here' and '/qw some text here'. When ran, it just puts the the result in the channel in a single line, as to not flood or annoy the channel. The script does not utilize color, but that could be added easily to help identify the difference between the input and output text.

Here is the code below (no syntax highligting. Sorry). Save it as 'dvoark-qwerty.pl' in your ~/irssi/scripts/ directory, and run "/script load dvorak-qwerty.pl" in Irssi.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# dvorak-qwerty.pl
# Aaron Toponce (aaron .toponce@gmail.com)
# Decodes dvorak to qwerty and qwerty to dvorak
#
# qwerty layout (from left to right, top to bottom): _+QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?-=qwertyuiop[]asdfghjkl;'zxcvbnm,./
# dvorak layout  (from left to right, top to bottom): {}\"<>PYFGCRL?+AOEUIDHTNS_:QJKXBMWVZ[]',.pyfgcrl/=aoeuidhtns-;qjkxbmwvz

use Irssi;
use strict;
use vars qw($VERSION %IRSSI);

$VERSION = "0.1";
%IRSSI = (
        authors     =>  "Aaron Toponce",
        contact     =>  "aaron.toponce\@gmail.com",
        name        =>  "dvorak-qwerty",
        decscription    =>  "Decodes dvorak-to-qwerty and reverse",
        license     =>  "GPLv2",
        changed     =>  "$VERSION",
        commands    =>  "dvorak qwerty"
);

sub qwerty2dvorak($)
{
        my ($text) = @_;
        $text =~ y/\_\+QWERTYUIOP\{\}ASDFGHJKL\:\"ZXCVBNM\<\>\?\-\=qwertyuiop\[\]asdfghjkl\;\'zxcvbnm\,\.\//\{\}\"\<\>PYFGCRL\?\+AOEUIDHTNS\_\:QJKXBMWVZ\[\]\'\,\.pyfgcrl\/\=aoeuidhtns\-\;qjkxbmwvz/; # "
        return "'@_' to dvorak: " . $text;
}

sub dvorak2qwerty($)
{
        my ($text) = @_;
        $text =~ y/\{\}\"\<\>PYFGCRL\?\+AOEUIDHTNS\_\:QJKXBMWVZ\[\]\'\,\.pyfgcrl\/\=aoeuidhtns\-\;qjkxbmwvz/\_\+QWERTYUIOP\{\}ASDFGHJKL\:\"ZXCVBNM\<\>\?\-\=qwertyuiop\[\]asdfghjkl\;\'zxcvbnm\,\.\//; # "
        return "'@_' to qwerty: " . $text;
}

sub dvorak_decode(</span><span class=$)
{
        my ($server, $target, $text) = @_;
        return;
        my $witem = $server->window_item_find($target);
        return;
        $witem->print(dvorak2qwerty($1), MSGLEVEL_CLIENTCRAP);
}

sub cmd_dvorak(" />
$)
{
        my ($arg, $server, $witem) = @_;

        if($witem && ($witem->{type} eq 'CHANNEL' || $witem->{type} eq 'QUERY'))
        {
                $witem->command('MSG ' . $witem->{name} . ' ' . qwerty2dvorak($arg));
        }
        else
        {
                print qwerty2dvorak($arg);
        }
}

sub cmd_qwerty($$$)
{
        my ($arg, $server, $witem) = @_;

        if($witem && ($witem->{type} eq 'CHANNEL' || $witem->{type} eq 'QUERY'))
        {
                $witem->command('MSG ' . $witem->{name} . ' ' . dvorak2qwerty($arg));
        }
        else
        {
                print dvorak2qwerty($arg);
        }
}

Irssi::command_bind('dv',\&cmd_dvorak);
Irssi::command_bind('qw',\&cmd_qwerty);
Irssi::signal_add('message public', sub {dvorak_decode($_[0], $_[4], $_[1]);} );
Irssi::signal_add('message own_public', sub {dvorak_decode($_[0], $_[2], $_[1]);} );
print "%B>>%n " . $IRSSI{name} . " " . $VERSION . " loaded";

{ 3 } Comments

  1. Pat O'Hooligan using Firefox 2.0.0.1 on Windows 2000 | December 23, 2006 at 8:25 am | Permalink

    Why not to use Chinese or Russian keyboard instead? It would make the application even more useless :-)

  2. Pat O'Hooligan using Firefox 2.0.0.1 on Windows 2000 | December 23, 2006 at 8:28 am | Permalink

    To be more specific: combine a Chinese keyboard with Dvorak and perhaps with a Russian as well. That would make it slightly more difficult to decypher.

  3. Pat O'Hooligan using Firefox 2.0.0.1 on Windows 2000 | December 23, 2006 at 9:15 am | Permalink

    I just got this when I sent my 3rd comment. Very clever way to do the DOS attack of the Dvorak-Qwerty type on yourself. Congratulations:-) (See below)

    Sorry, but your comment has been flagged by the spam filter running on this blog: this might be an error, in which case all apologies. Your comment will be presented to the blog admin who will be able to restore it immediately.
    You may want to contact the blog admin via e-mail to notify him.

Post a Comment

Your email is never published nor shared.

Switch to our mobile site