Sunday, July 7, 2013

Scripted XChat tab renaming II

Following is a slight modification to the XChat tab renaming script from 21 May. One thing that I noticed was that, if I closed a channel before running the script, the script would change the name of the server to whatever channel was missing.

In the following, the context line grabs the context for the specific channel. If the channel doesn't exist, context is set to 0. The fix is just a simple check for the status of the context variable. If it's set to 0, it skips renaming the channel.








#!/bin/bash

#following renames specific channels in XChat2

# "#192.168.2.215_docs" to "docs"

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

if [ "$context" -ne 0 ]
then

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"

fi

# repeat the above, as needed, for any other channels

The above works with my set up and no longer impacts the server names in XChat.