I decided recently to clean up my Debian "Sid" system, using
apt-get autoclean
,
apt-get purge `deborphan`
,
aptitude purge ~c
, and
aptitude purge ~o
.
It gained me almost two gigabytes of space.
On the other hand, it deleted several packages I had long depended on.
One of them was xchat.
I installed hexchat, the fully open replacement for xchat.
Mostly, it's the same program ... but a few things didn't work right.
Script fixes
The two xchat scripts I use weren't loading. Turns out hexchat wants
to find its scripts in .config/hexchat/addons
, so I moved
them there. But xchat-inputcount.pl still didn't work;
it was looking for a widget called "xchat-inputbox".
That was fairly easy to patch: I added a line to print the name of
each widget it saw, determined the name had changed in the obvious way,
and changed
if( $child->get( "name" ) eq 'xchat-inputbox' ) {
to
if( $child->get( "name" ) eq 'xchat-inputbox' ||
$child->get( "name" ) eq 'hexchat-inputbox' ) {
That solved the problem.
Notifying me if someone calls me
The next problem: when someone mentioned my nick in a channel, the
channel tab highlighted; but when I switched to the channel,
there was no highlight on the actual line of conversation
so I could find out who was talking to me.
(It was turning the nick of the person addressing me to a
specific color, but since every nick is a different color anyway,
that doesn't make the line stand out when you're scanning for it.)
The highlighting for message lines is set in a dialog you can configure:
Settings→Text events...
Scroll down to Channel Msg Hilight and click on that
elaborate code on the right:
%C2<%C8%B$1%B%C2>%O$t$2%O
That's the code that controls how the line will be displayed.
Some of these codes are described in
Hexchat:
Appearance/Theming, and most of the rest are described in the
dialog itself. $t
is an exception: I'm not sure what it
means (maybe I just missed it in the list).
I wanted hexchat to show the nick of whoever called me name in inverse video.
(Xchat always made it bold, but sometimes that's subtle; inverse video
would be a lot easier to find when scrolling through a busy channel.)
%R
is reverse video, %B
is bold, and
%O
removes any decorations and sets the text back to
normal text, so I set the code to:
%R%B<$1>%O $t$2
That seemed to work, though after I exited hexchat and started it up
the next morning it had magically changed to
%R%B<$1>%O$t$2%O
.
Hacking hexchat source to remove hardwired keybindings
But the big problem was the hardwired keybindings. In particular,
Ctrl-F -- the longstanding key sequence that moves forward one
character -- in hexchat, it brings up a search window.
(Xchat had this problem for a little while, many years ago,
but they fixed it, or at least made it sensitive
to whether the GTK key theme is "Emacs".)
Ctrl-F doesn't appear in the list under Settings→Keyboard shortcuts,
so I couldn't fix it that way.
I guess they should rename that dialog to Some keyboard shortcuts.
Turns out Ctrl-F is compiled in. So the only solution is to rebuild from source.
I decided to use the Debian package source:
apt-get source hexchat
The search for the Ctrl-F binding turned out to be harder than it had
been back in the xchat days. I was confident the binding would be in
one of the files in src/fe-gtk, but grepping
for key, find and search all gave way too many hits.
Combining them was the key:
egrep -i 'find|search' *.c | grep -i key
That gave a bunch of spurious hits in fkeys.c -- I had already
examined that file and determined that it had to do with the
Settings→Keyboard shortcuts dialog, not the compiled-in
key bindings. But it also gave some lines from menu.c including
the one I needed:
{N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK, 0, 0, 1, GDK_KEY_f},
Inspection of nearby lines showed that the last GDK_KEY_
argument is optional -- there were quite a few lines that didn't
have a key binding specified. So all I needed to do was remove that
GDK_KEY_f. Here's my patch:
--- src/fe-gtk/menu.c.orig 2016-02-23 12:13:55.910549105 -0700
+++ src/fe-gtk/menu.c 2016-02-23 12:07:21.670540110 -0700
@@ -1829,7 +1829,7 @@
{N_("Save Text..."), menu_savebuffer, GTK_STOCK_SAVE, M_MENUSTOCK, 0, 0,
1},
#define SEARCH_OFFSET (70)
{N_("Search"), 0, GTK_STOCK_JUSTIFY_LEFT, M_MENUSUB, 0, 0, 1},
- {N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK,
0, 0, 1, GDK_KEY_f},
+ {N_("Search Text..."), menu_search, GTK_STOCK_FIND, M_MENUSTOCK,
0, 0, 1},
{N_("Search Next" ), menu_search_next, GTK_STOCK_FIND, M_MENUS
TOCK, 0, 0, 1, GDK_KEY_g},
{N_("Search Previous" ), menu_search_prev, GTK_STOCK_FIND, M_M
ENUSTOCK, 0, 0, 1, GDK_KEY_G},
{0, 0, 0, M_END, 0, 0, 0},
After making that change, I rebuilt the hexchat package and installed it:
sudo apt-get build-dep hexchat
sudo apt-get install devscripts
cd hexchat-2.10.2/
debuild -b -uc -us
sudo dpkg -i ../hexchat_2.10.2-1_i386.deb
Update: I later wrote about how to automate this here:
Debian: Holding packages you build from source, and rebuilding them easily.
And the hardwired Ctrl-F key binding was gone, and the normal
forward-character binding from my GTK key theme took over.
I still have a couple of minor things I'd like to fix, like the too-large
font hexchat uses for its channel tabs, but those are minor.
At least I'm back to where I was before foolishly deciding to
clean up my system.
Tags: xchat, hexchat, irc
[
19:00 Feb 24, 2016
More linux |
permalink to this entry |
]
Sometimes zsh is a little too smart for its own good.
Something I do surprisingly often is to complete the filenames for my
local channel logs in xchat. Xchat gives its logs crazy filenames like
/home/akkana/.xchat2/xchatlogs/FreeNode-#ubuntu-us-ca.log.
They're hard to autocomplete -- I have to type something like:
~/.xc<tab>xc<tab>l<tab>Fr<tab>\#ub<tab>us<tab>
Even with autocompletion, that's a lot of typing!
Bug zsh makes it even worse: I have to put that backslash in front of
the hash, \#
, or else zsh will see it either as a comment
(unless I unsetopt interactivecomments, in which case I can't
paste functions from my zshrc when I'm testing them);
or as an extended regular expression
(unless I unsetopt extendedglob).
I don't want to unset either of those options: I use both of them.
Tonight I was fiddling with something else related to extendedglob,
and was moved to figure out another solution to the xchat completion
problem. Why not get zsh's smart zle editor to insert most of that
annoying, not easily autocompletable string for me?
The easy solution was to bind it to a function key. I picked F8 for
testing, and figured out its escape sequence by typing
echo
, then Ctrl-V, then hitting F8.
It turns out to insert <ESC>[20~
. So I made a binding:
bindkey -s '\e[20~' '~/.xchat2/xchatlogs/ \\\#^B^B^B'
When I press F8, that inserts the following string:
~/.xchat2/xchatlogs/ \#
↑ (cursor ends up here)
... moving the cursor back three characters, so it's right before the space.
The space is there so I can autocomplete the server name by typing
something like
Fr<TAB>
for
FreeNode.
Then I delete the space (Ctrl-D), go to the end of the line (Ctrl-E),
and start typing my channel name, like
ubu<TAB>us<TAB>.
I don't have to worry about typing the rest of the path,
or the escaped hash sign.
That's pretty cool. But I wished I could bind it to a character
sequence, like maybe .xc, rather than using a function key.
(I could use my Crikey
program to do that at the X level, but that's cheating; I wanted to do
it within zsh.) You can't just use
bindkey -s '.xch' '~/.xchat2/xchatlogs/ \\\#^B^B^B'
because it's recursive: as soon as zsh inserts the ~/.xc part,
that expands too, and you end up with
~/~/.xchat2/xchatlogs/hat2/xchatlogs/ \# \#.
The solution, though it's a lot more lines, is to
use the special variables LBUFFER and RBUFFER.
LBUFFER is everything left of the cursor position, and RBUFFER
everything right of it.
So I define a function to set those, then set a zle "widget" to
that function, then finally bindkey to that widget:
function autoxchat()
{
LBUFFER+="~/.xchat2/xchatlogs/"
RBUFFER=" \\#$RBUFFER"
}
zle -N autoxchat
bindkey ".xc" autoxchat
Pretty cool! The only down side: now that I've gone this far in zle bindings,
I'm probably an addict and will waste a lot more time tweaking them.
Tags: shell, zsh, xchat
[
21:31 Jun 15, 2013
More linux/cmdline |
permalink to this entry |
]
I use xchat as my IRC client. Mostly I like it, but its sound alerts
aren't quite as configurable as I'd like. I have a few channels, like
my Bitlbee Twitter feed, where I want a much more subtle alert, or no
alert at all. And I want an easy way of turning sounds on and off,
in case I get busy with something and need to minimize distractions.
Years ago I grabbed a perl xchat plug-in called "Smet's NickSound"
that did something close to what I wanted. I've hacked a few things
into it. But every time I try to customize it any further, I'm hit
with the pain of write-only Perl. I've written Perl scripts, honest.
But I always have a really hard time reading anyone else's Perl code
and figuring out what it's doing. When I dove in again recently to
try to figure out why I was getting so many alerts when first starting
up xchat, I finally decided: learning how to write a Python xchat
script couldn't be any harder than reverse engineering a Perl one.
First, of course, I looked for an existing nick sound Python script ...
and totally struck out. In fact, mostly I struck out on finding any
xchat Python scripts at all. I know there are
Python bindings for
xchat, because there's documentation for them. But sample plug-ins?
Nope. For some reason, nobody's writing xchat plug-ins in Python.
I eventually found two minimal examples:
this very
simple example and the more elaborate
utf8decoder.
I was able to put them together and cobble up a working nick sound plug-in.
It's easy once you have an example to work from to help you figure out
the event hook arguments.
So here's my own little example, which may help the next person trying
to learn xchat Python scripting:
chatsounds.py
on github.
Tags: programming, python, xchat, irc
[
22:13 Sep 26, 2012
More programming |
permalink to this entry |
]
As most veteran IRC users know, IRC commands generally start with a
slash at the beginning of a line. For instance, you say
/join #channel
to join a new channel, or
/me waves to everyone
to send "*akk waves to everyone" to the channel.
Great, but what if I want to start a line with a slash?
On some IRC clients, you can type two slashes, e.g.
/ /me tries
but on xchat that doesn't work -- it just complains "unknown command".
On xchat, what you need is /say:
/say /me succeeds!
Silly little tip, but I know I'll forget it if I don't record it ...
and I bet I'm not the only xchat user wondering how to do this.
Update: it turns out that sometimes in xchat you can use a double slash
with no spaces:
//me tries
which is the obvious thing to try, but it hasn't always worked
reliably for me. Try it ... but you can fall back on /say
if // doesn't work.
Tags: irc, xchat, tip
[
21:55 Feb 14, 2011
More linux |
permalink to this entry |
]