Linux Tutorial Irssi

From WebOS Internals

Revision as of 02:51, 17 October 2009 by Punzada (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Linux Tutorial - Irssi

Update 09/17/2009

I have managed to get the BitlBee service working with irssi for full AIM, MSN, Yahoo and Jabber support. I shall be doing my best to update this wiki with the best methods to get this working and configured easily and securely as soon as possible.

This Document Assumes the following

You have followed the procedure to Access Linux on the device and have enabled the Optware repositories and software Portal:Accessing_Linux

You have installed the Terminal application Application:Terminal


Once these procedures are done you should have access to:

The Optware software repositories through ipkg-opt

The Terminal Application through the WebOS (should load, be the root user, and function)


Installation

Within the Terminal application use the following command:

ipkg-opt install screen irssi perl

This command will automatically download GNU Screen and irssi as well as any necessary dependencies.

Note: GNU Screen is *not* necessary for irssi to function, it only provides further functionality to be able to close the Terminal application if desired, keep irssi running in the background and reattach to it. Also, I have found that running irssi within a screen session gives irssi all its various colors while running natively within the terminal app leaves it mono-colored.


Usage

In order to run irssi you simply need to type irssi into the Terminal application at the shell prompt and once hitting enter(return) it will load.

However this is NOT RECOMMENDED as by default the Terminal Application is loaded as the root user and you should avoid using internet facing applications as the root user if it is not necessary (some IRC networks such as EFnet will go as far as to instantly disconnect you if it detects you are connecting to their servers as root).

Once the Terminal Application is opened you may change to the user you set up when completing the steps to Access Linux via the su command

example:

root@castle:/var/home/root# su myuser
myuser@castle:/var/home/root$

from here you can simply enter irssi and hit return and it shall load.

Basic Commands

/connect ircserver

This will connect you to an irc network ex: /connect irc.freenode.net will connect you to the freenode network.

/join #channel

This will join the requested channel, ex: /join #webos-internals

Sym+n Will move to the 'next' window within the irssi interface Sym+p Will move you to the 'previous' window within the irssi interface

You can directly jump to a window (numbered in irssi) by hitting Orange Key+Space+Number.

GNU Screen History & Basics

If you're like me and you want to always keep your irssi session active as well as have the colors available to you a good solution is to use GNU Screen.

For those that don't know, screen acts as a window manager for terminal applications. Screen allows you to run multiple applications in a single terminal session, switch between the applications freely as well as being able to detach from it entirely, and reattach to it later while having those applications run in the background. Many consider screen to be one of the most important tools available for any type of command line work or administration - is is very powerful and very flexible, feel free to read up on it's customization and abilities to further enhance your experience with it.

Screen Usage

To start using screen it is very simple, follow the instructions above but before switching to your local user to run irssi, first type screen and hit enter

You will be greeted with screen's opening text, letting you know that it is running, and the GPL license, simply press the space bar here and you will be taken back into the prompt and it will appear as if you're back to where you started.

From this point on, follow the instructions above to change into your user that is not root, and open irssi like normal.

You will see commands listed as such: Sym-A C

This key combination is important because it means 'Press and hold Sym, then hit A, release both and hit C'

This is how GNU Screen functions and is vital to it's usage, the example above creates a new window with a fresh terminal session.

Attach / Detach

In order to detach from your screen session use the command Sym-A D

Once a session is detached you may close out of the terminal app and any applications running within your screen session will continue to run.

In order to reattach to a session you left running, load the Terminal Application again and type the following at the command prompt and hit enter: screen -r


Screen Commands To Know

Sym-A C - Create a new window/terminal session

Sym-A N - Change to next window/terminal session within the current screen session

Sym-A P - Change to previous window/terminal session with the current screen session

Sym-A D - Detach from current screen session

Bitlbee for Multi-IM

BitlBee is an IRC daemon that you can run to connect to basically all of the most popular IM protocols: XMPP/Jabber (including Google Talk), MSN Messenger, Yahoo! Messenger, AIM and ICQ.

As of now we are able to install bitlbee on the linux subsystem, run it in daemon mode (I wasn't able to get it started with xinetd - will be investiating this further), launch it from a script when we wish to connect and set irssi to automatically connect, identify and load all of your IM accounts at once.

The following procedure is how I have set mine up and there may be a sleeker/easier solution down the line. Try to think of this procedure as more "proof of concept" then "ready for the general public"


first to install the necessary files (must be performed as root or privledged user with sudo from within the terminal application):

ipkg-opt install screen irssi bitlbee perl

Configure Bitlbee

The only file that absolutely needs to be tweaked is located at /var/opt/etc/bitlbee/bitlbee.conf

RunMode = Daemon

User = myuser

ConfigDir = /home/myuser/

(note - replace myuser above with the user name set up when installing optware as shown above) edit the configuration file mentioned with your editor of choice as root (vi, nano, or copy it over and copy back with winscp - whatever works for you) make sure any of those values that are leading with a # have it removed otherwise the value will not be set and it will be seen as a comment.

Startup Script

This script will load the daemon on-demand (may even be better this way as using less resources when you don't want to IM) and will automatically put the shell to your username instead of root (so you can use irssi more securely off the bat)

Create a file called "im" (without quotes) in your /var/home/root directory with the following:

#!/bin/sh
#load bitlbee daemon and automatically load screen with a regular user session
/opt/sbin/bitlbee
screen su myuser

You may now run this script at any time by opening up the terminal app and typing ./im

Configure Bitlbee for your IM clients

Running the 'im' script that you have now made will bring you to a prompt featuring your username such as

myuser@castle:/var/home/root$

Important Note In order for these changes to take effect the filesystem must be mounted as writeable, to do that as root user (or through sudo) please use the following command

mount -o remount,rw /

and please remember to change it back to read-only when you're finished by doing

mount -o remount,ro /

From your user shell, load up irssi.

Once loaded you can connect to the bitlbee daemon by doing /connect localhost

Move to the second window (sym+n or orange key+space+2) and you will be at the bitlbee control channel &bitlbee

You can have a flushed out description (and possibly understanding) of the following procedure Here - I am simply going to sum up the commands quickly. Note ignore all < > 's within the commands fill this with the respective needed values.

While on the bitlbee control channel:

Global Registration Password (you will input this single password and bitlbee will automatically log in to any IM accounts you set up)

register <password>

Add an IM account to the service:

account add <protocol> <username> <password> [<server>].

oscar is the protocol used by ICQ and AOL. For MSN use msn, for Yahoo use yahoo and for Jabber use jabber)

For oscar, you need to specify the IM-server as a fourth argument (for msn and yahoo there is no fourth argument).

For AOL Instant Messenger, the server name is login.oscar.aol.com. For ICQ, the server name is login.icq.com.

Repeat this as many times as needed for any IM accounts.


Configure irssi to automatically connect to Bitlbee

Important Note Please make sure the above procedure to make the filesystem writable was done or these changes WILL NOT BE SAVED.

Now that we have set up the start up script, configured bitlbee with our IM services of choice, now we will make it so that when irssi loads it will automatically connect to the bitlbee daemon and identify with it so you can immediately begin IM'ing.

Perform the following commands while in irssi

/NETWORK ADD -autosendcmd "/^msg &bitlbee identify password" Bitlbee

(please replace password in the command above with the one you set for your global Bitlbee password)

/SERVER ADD -auto -network Bitlbee localhost 6667

Final Setup & Thoughts / Running

At this point you should be entirely set up with bitlbee and irssi. Make sure you set your filesystem back to read-only (see above). A good test would be to restart your pre entirely after setup and perform the following procedure.

To get to a fully functional irssi w/IM protocols through bitlbee is only a three step process:

1. Load up terminal application

2. at the prompt type

./im

3. at the user prompt that loads, type

irssi

and there you are, enjoy multiple IM protocol chats natively on your webos device.

If you are a new user to screen it's easy to get lost in multiple embedded screen sessions and such, if you find yourself loading multiple copies of the bitlbee daemon and need them closed (or you're done with your IM sessions and want to conserve as much battery as possible) simply run the following command and it will kill the service:

pkill bitlbee 

Configuration/Tweaks

Both irssi and GNU Screen are very rich applications with a plethora of scripts, customization and usage options that only a very small percentage of are covered in this document. If interested please search and find how you may be able to adjust them to fit your specific needs (and if you find anything worthwhile feel free to add it to this wiki!)

For information on irssi please visit their startup documentation http://irssi.org/documentation/startup

This site provides information that will help you in automating irssi to do tasks like autojoin set servers and channels and automatically identify your nickname with services.

Known Issues

When first loaded irssi tends to not properly format to the whole screen and a simple rotation to let the terminal rotate to the side and back to standard typing position will fix it (you will see the characters slowly refresh during this process)

Even with Screen running you can lose connection if the wifi radio turns off when the screen does, see http://www.webos-internals.org/wiki/Patch_webOS_Keep_Phone_Awake_While_in_Remote_Session

Terminal-irssi.jpg

Personal tools
Google AdSense