Tuesday, May 21, 2013

Scripted Xchat tab renaming

Following is a shell script that will rename a specific tab in Xchat. Reason I came up with this is that Bitlbee produces some very ugly channel names in Xchat. In one of the much older, branch versions of Bitlbee, there was a function that allowed you to rename the channel. This has since gone away.

While poking around in the Xchat command set, I found the settab command which allows you to temporarily (until the next join) rename a channel. A bit of further research showed a dbus interface to Xchat. From there, it was simple.


#following renames specific channels in Xchat2

# "#" to "docs"

context=`dbus-send --dest=org.xchat.service --print-reply --type=method_call /org/xchat/Remote org.xchat.plugin.FindContext string:"bitlbee" string:"#" | tail -n1 | awk '{print $2}'`

dbus-send --dest=org.xchat.service --type=method_call /org/xchat/Remote org.xchat.plugin.SetContext uint32:$context

dbus-send --dest=org.xchat.service --type=method_call /org/xchat/Remote org.xchat.plugin.Command string:"settab docs"

The configurable bits are the two "string" entries in the line starting with "context" and the "settab docs" entry in the last line beginning with "dbus-send". Note: if you make an error in the "string" entries, the channel name for the previous call will be changed. (You'll know what I mean when it happens.)

Chain a bunch of these in a single script and you can mass rename channel tabs. Add a desktop launcher for the script and you can mass rename Xchat tabs with a single mouse click. Enjoy!