Posted by: arun on: October 25, 2009
After loosing few matches on FICS on time control, poor me realized that it’s the mouse which matters when you’ve 10-20 seconds to mate. So I got myself an usb mouse and we’ve some new adventure.
Ok, plugged in the usb mouse, checked that lsusb recognizes it. A dmesg suggested only a generic “low speed” usb device plug in. I did a X -configure but it didn’t show up my usb mouse
Few web pages suggested some cool ways to check if your mouse is recognized:
lsusbcat /dev/input/mice and try moving your mouse, if it’s recognized you’d see random output on screenNone of these worked for me. I gave up on XOrg.conf. Let’s try upgrading to Xorg input hotplugging and see if HAL does some magic. So added hal and dbus to rc.conf, pacman’ed xf86-input-evdev. Hotplugging totally disregards can replace/compliemt your xorg.conf, all inputs are added at runtime, real hotness! Well still my mouse was not working.
After pulling out hair after hair, finally I figured out the whole story (yep! I still have a few hairs left:)). Although kernel was recognizing my usb device, it couldn’t know that it was a mouse. Hence there was no device file created for the mouse in /dev/input. The missing link was usbhid (USB Human Interaction Device) module. A quick modprobe usbhid and we’re golden. The clever /me had disabled MOD_AUTOLOAD in rc.conf, and I had listed every module loaded by my system (optimization!).
Anyways hotplugging is super awesome. I enabled scroll on my touchpad this time, configuration is real easy and human readable. E.g. to disable the caps lock key, just add the following option to /etc/hal/fdi/policy/10-keymap.fdi: <merge key="input.xkb.options" type="string">ctrl:nocaps</merge>. Thanks to the arch wiki.
Update:.xmodmap causes problems with multimedia keys. Evdev is intelligent enough to guess the right names for all key codes, so commenting .xmodmap worked for me. Most of issues are caused because X detects two keyboards (thanks HAL), /var/log/XOrg.0.log is your friend. My current setup doesn’t use a xorg.conf, everything is detected by HAL, and things work OOB.
Good day!
Posted by: arun on: September 27, 2009
Add the following block into ~/.irssi/config:
ignores = (
{
level = "JOINS PARTS QUITS";
channels = ( "#archlinux", "#vim", "#powershell" );
network = "FreeNode";
},
{
level = "MODES";
channels = ( "&bitlbee" );
network = "BitlBee";
}
);
This will automatically block the level message types from the channels specified. If you prefer manual way of ignoring messages try /help ignore. On a related note, activity_hide_level is a variable which can be used to disable the notification in act bar for specific message levels. Take a look at this nice irssi config file for examples of these.
Here is a list of various message levels for reference (you can find it in /help levels):
Message levels (or in short, levels) are used almost everywhere. They describe what kind of messages we're dealing with. Here's a list of them all:
CRAP - Can be almost anything
MSGS - Private messages
PUBLIC - Public messages in channel
NOTICES - Notices
SNOTES - Server notices
CTCPS - CTCP messages
ACTIONS - Actions (/me) - usually ORed with PUBLIC or MSGS
JOINS - Someone joins a channel
PARTS - Someone parts a channel
QUITS - Someone quits IRC
KICKS - Someone gets kicked from channel
MODES - Channel mode is changed
TOPICS - Channel topic is changed
WALLOPS - Wallop is received
INVITES - Invite is received
NICKS - Someone changes nick
DCC - DCC related messages
DCCMSGS - DCC chat messages
CLIENTNOTICE - Irssi's notices
CLIENTERROR - Irssi's error messages
CLIENTCRAP - Some other messages from Irssi
And a few special ones that could be included with the levels above:
HILIGHT - Text is highlighted
NOHILIGHT - Don't check highlighting for this message
NO_ACT - Don't trigger channel activity when printing
this message
NEVER - Never ignore or log this message
Posted by: arun on: August 12, 2009
Three steps to nirvana:
set daemon 30
LOGFILE=$HOME/.logs/procmaillog
LOGABSTRACT=all
echo "foo" >> ~/mydebug.log to check control flow.BTW, I’m sure there are better ways to do this, /me had to send around 7-8 test mails to fix an issue! Feel free to share your recipe-debugging-tips.
Posted by: arun on: June 22, 2009
Few months ago, we discussed about a mail notification method for fetchmail/procmail and mutt combo. As you can see in that post, the script we wrote to handle notification was dependent on ratpoison. Well it makes life bit tough for my non-ratpoison X sessions. I thought it would be a good idea to make the script window manager independent. Enter osd.sh
The script uses osd_cat. It comes in the XOSD package for most of the unices. It is similar to the cat command for the console. It can read a file, string or the stdin and output the text onto X display. It has a bunch of config options which let you choose font, location etc. for the text. I’d recommend a RTM (man osd_cat).
Here is the code:
#!/bin/bash
# Displays a string on the screen
# Last Modified: Mon 22 Jun 2009 02:59:55 AM IST
# let osd know, we have a X running. there will be problems if this script is
# called from different user. disable acl in X in that case(use xhost +).
export DISPLAY=":0.0"
color="red"
font="-*-dina-medium-r-normal-*-16-*-*-*-*-*-*-*"
age="6"
align="center"
delay="4"
indent="0"
lines="5"
offset="0"
shadow="1"
pos="middle"
# read from stdin if no args are present
if [ $# -ne 1 ]
then
text=$(line)
else
text=$1
fi
echo $text | osd_cat --color=$color --delay=$delay --age=$age --font=$font --offset=$offset --shadow=\
$shadow --lines=$lines --align=$align --pos=$pos
This script can be used for any notification purpose. For using this with procmail, replace use the following construct in procmailrc:
:0 h
| grep "From:" | /home/arun/bin/osd.sh
This will display alerts as “From: Foo Bar ” when a new mail is received.
Enjoy!
Posted by: arun on: January 3, 2009
Well you guessed it right, the “global” command (or :g in command mode) will let you select lines that match a particular pattern globally in the file and lets you operate on the selected text. The :v operates similar to grep -v which selects all texts which do not match the pattern.
Syntax: :g/pattern/command where pattern is any regular expression, command is any vim command
Here’s the scenario which taught me the global command:
I have a file with ~29K lines. All lines must begin with “\\”. However somelines are broken into two, in which case the lines which do not start with “\\” need to be appended to the previous
line
Sample text:
\\foo\bar
\\food
bar
\\x\y
\z
Should be converted to:
\\foo\bar
\\foodbar
\\x\y\z
And we solved it this way:
:v/^\\\\/exe "normal i\<C-H>\<ESC>"
All we did was to execute a backspace(C-H) for all occurences of pattern in normal mode
Let’s end the post with a theorem:
Statement:VI is perfect
Proof: VI in roman numerals is 6. The natural numbers less than 6 which
divide 6 are 1, 2, and 3. 1 + 2 + 3 = 6. So 6 is a perfect number. Therefore, vi
is perfect.
– Arthur Tateishi
And a corollary
VIM in roman numerals might be: (1000 – (5 + 1)) = 994, which happens to be
equal to 2*496+2. 496 is divisible by 1, 2, 4, 8, 16, 31, 62, 124, and 248 and
1+2+4+8+16+31+62+124+248 = 496. So, 496 is a perfect number. Therefore, vim is
twice as perfect as vi, plus a couple extra bits of goodies.
That is, vim is better than perfect.
– Nathan T. Oelger
Have an awesome 2009!
Posted by: arun on: December 7, 2008
Problem: I have my local mail setup with mutt, fetchmail and procmail. And I would need a way to run an arbitrary script when new mail arrives and _not_ loose the mail from my inbox.
Solution: Procmail supports a nice feature called nesting. With nested blocks a procmail recipe can be assigned more than action.
e.g: Here’s a recipe to filter all my email from gmail:
:0:
* ^To:.*gmail\.com
{
:0 c
$MAILDIR
:0 h
| grep “From:” | ~/src/_scripts/ratpoison/newmail.sh
}
And the newmail.sh script
#!/bin/bash
read from
ratpoison -c "echo Mail $from"
Discussion: Here’s the breakup
*^To:*gmail.com Catch all mails which have their To: field containing gmail.com:0 c - Copy the mail into $MAILDIR:0 h – Pipe the header into grep. And pipe the output (“From:*”) into newmail scriptIf your window manager has a notification tray, you may be interested in this. New to procmail, go here.
/me is having bit overdose of cookbooks these days
Posted by: arun on: November 10, 2008
I had posted long back about a bash wrapper over youtube-dl to fetch youtube videos using your own download manager. The youtube-dl script had changed long since then. And good news is now we don’t need to change the script in any way to get the download url. So here we go!
Grab the latest youtube-dl from here
Minor update to the linux youtube-dl script:
#!/bin/bash
if [ $# -ne 2 ]
then
echo “Usage : $0 ”
echo “e.g : $0 http://www.youtube.com/watch?v=D1R-jKKp3NA steve_jobs”
else
outputfile=”.avi”
todnload=$(youtube-dl -g $1) # youtube-dl is in path, right?
echo “Got the file..”$todnload
axel -n 100 $todnload -o $2″.flv” # wget -c $todnload -O $2″.flv” .if you don’t use axel
echo “Download Completed…”
ffmpeg -i $2″.flv” $2$outputfile # get the avi file
fi
Enjoy ![]()
Thanks Jay for pointing this out!
Posted by: arun on: October 23, 2008
Lemme shout it aloud: I am a big fan of free webhosts
Until recently, one of my friends made me realize(brainwashed!) that probably I had had my part of the freebies
And its been long since I last did something php-ish, so the thought of getting hands dirty with web programming made me take this bad decision of getting a host.
And dude, choosing the right host _is_ much tougher than expected. It ate up some 10s of my sleep-hours and a few man-weekends
Finally, yesterday I gave up(damn it! set IDontCare=true) on my FindBestHost greedy approach and purchased a hosting package.
A few suggestions for those looking out for webhosts:
Hope this might save a few minutes while deciding for a webhost. Good luck!
Posted by: arun on: October 2, 2008
Sify provides a connection client(they call it BBClient) for linux. If you use bbclient on *nix, these would have hit you:
After living through these for nearly three months, yesterday the level of irritation overtook my laziness. I had to disconnect few times and everytime the client would fork a firefox. The search for alternate client began. I stumbled across a nice hack by Liet-Kynes. The hack literally dissects the sify connection mechanism
Stepped through the script and modified a few bits to get the script working in my machine. And now its release time!
Download: Sistine-20081002.tar.bz2
Usage: Login: sistine.py in | Logout: sistine.py out || Please read the README bundled in the archive.
ChangeLog:
Disclaimer: Your box might burst/fly/crawl on running the script. Don’t blame me for that. The script works normally for me btw.
License: Public domain. Bend it as you like.
I’ve tested the script in linux. It should work in windows as well if you’ve python installed.
The original code by Liet-Kyne is sistine-20070828.tar.gz. Kudos to Liet-Kyne, buddy you’re a true hacker
Update: If you’re in python 2.6, get the scripts from my github.