Showing posts with label HowTo. Show all posts
Showing posts with label HowTo. Show all posts

Friday, June 20, 2008

irssi notifications over Jabber (or IRC barking)

Thanks to daubers (the brains behind the XMPP doorbell) who suggested it, I now have irssi highlights sent directly to my Jabber client. Quite a handy thing since only yesterday I logged in to find several PMs awaiting me from 4 days ago.

For the base I used an existing irssi script called fnotify, which was designed to write notifications to a file. I found this script from Aaron Toponce's blog post.


mkdir -p ~/.irssi/scripts/autorun
cd ~/.irssi/scripts
wget http://www.leemhuis.info/files/fnotify/fnotify -O fnotify.pl
chmod +x fnotify.pl
ln -s ../fnotify.pl autorun/fnotify.pl
nano fnotify.pl


Change line 56 (which reads something like open(FILE, ...)) to:


open(FILE,"| sendxmpp -i me\@example.com");


Replace the JID with your own, and make sure to put a \backslash before the @ sign as above.

sudo apt-get install sendxmpp


When it is installed, tell sendxmpp what account to use for sending messages:


echo me@example.com verysecret123 > ~/.sendxmpprc
chmod 0600 ~/.sendxmpprc


Replace with your JID and password of course ;)

Now, in irssi:

/win 1
/run fnotify.pl

(switching to window 1 is necessary to see any error messages if they appear)

If it loads successfully, get someone to say your nick or send you a private message. It should appear in your Jabber client within a few seconds.

A consequence of this for me is that IRC now barks too :)

Saturday, June 09, 2007

How to recover an Ubuntu/Linux PC

People often claim that Linux is more stable than Windows. Without hard statistics, this can't really be proven. One thing I do know however, is that when things go wrong it is much easier to recover a Linux PC than a Windows one, without restarting. In this post I will explain what to do, in easy steps, to get your Linux back running as safely as possible.

1. Kill a single graphical application
If you know the problem is a single application that you have open that maybe just froze then it is simple to fix. Press Alt+F2 and type 'xkill' (without the quotes) then press enter. This runs the xkill program, and the next application that you click on will be forced to close. If you change your mind, press the right mouse button to exit from this mode.

It may be worth setting a keypress that will automatically start xkill when you need it. In Ubuntu/GNOME, go to System->Preferences->Keyboard Shortcuts

2. Restart the graphical interface
If you are still having problems, or the whole of the graphical interface is not responding, press Ctrl+Alt+Backspace. This will attempt to stop the graphical display, and then restart it. Any applications you had open will be killed.

3. Switch to a console to end the application
If this didn't work, or you know a certain program is causing the problem, you can kill that program without using the graphical interface. Press Ctrl+Alt+F1. If your PC is running, but slowly, this may take a minute. Eventually you should end up at a text login screen. Log in with your usual username and password, and wait for the prompt to appear.

If you know the name of the program causing the problems, type: killall <program name>. If it continues, you can try to force it to stop, with: killall -KILL <program name>. For system process you may get "Permission Denied" errors. Prefix the above commands with "sudo ", ie. sudo killall...

If you are not sure which program is making the PC unresponsive, use the 'top' command. It shows a list of running programs, and their name, and in the CPU column it shows how much of the computer's processor they are using up. Once you identify the application press 'q' to exit top, and use the commands above to kill the program.

If all is now working, Ctrl+Alt+F7 will switch back to the graphical interface.

4. Emergency reboot procedure
If the steps above all failed, there is one last way to reboot your computer, and it is much safer than pressing the reset button on your PC's case, or pulling out the power cable.

It is important that you type these key combinations in the correct order, allowing the PC some time to complete the command between each one. The SysRq key on your keyboard is often also labelled as "Print" or "Print Screen".

Ctrl+Alt+SysRq+R
Switches the keyboard mode.
Ctrl+Alt+SysRq+S
Writes all data to the disks, necessary to avoid data corruption, unsaved files will still be lost.
Ctrl+Alt+SysRq+E
Tries to end processes in a nice way. Allow a little bit of time before you use the next command.
Ctrl+Alt+SysRq+I
Tries to forcefully kill processes that have not closed.
Ctrl+Alt+SysRq+U
Temporarily makes the hard disks read-only, this makes it safe to reboot.
Ctrl+Alt+SysRq+B
Force reboot.

5. Surrender
If that didn't reboot your PC, press the reset switch, or pull the plug, and cross your fingers :)


If you have any other methods, tips, or feedback to share, post a comment and let me know!

Sunday, May 20, 2007

Making Scite the default editor in GNOME (Ubuntu)

For too long I was fighting with gedit, the default text editor in Ubuntu. While it is not too bad, Scite is far more powerful, and much better.

To install Scite, you can type the following in Terminal:

sudo aptitude install scite


I had the option of changing the editor associated with each of the file types in Nautilus (which is what I did on my desktop), but I was sure there must be a better way. I found it...

sudo aptitude install scite
cd ~/.local/share/applications
echo -e "[Default Applications]\ntext/plain=scite.desktop" >defaults.list
killall nautilus

Works a treat. Also, here is my Scite settings file:

line.margin.visible=1
default.file.ext=.lua
open.dialog.in.file.directory=1
check.if.already.open=1

Tip: A per-folder settings file can be created. For example, I have created a 'SciTE.properties' file in the gloox src folder, so Scite will automatically use the correct indentation for gloox, and insert spaces when I use the tab key.

Update: I found later that this only tells scite to open plain text files. If you are dealing with code (as I am) add the following lines too:


text/x-csrc=scite.desktop
text/x-c++src=scite.desktop
text/x-chdr=scite.desktop


If you want to add other file types, find the MIME type by right-clicking on a file and selecting 'Properties', the MIME type you need to know is listed there.