Sunday, April 12, 2015

weechat for xchat refugees.

As I was looking for ways to improve my screen real estate. I started looking for alternative irc clients to the graphical one I was using (xchat).

So I began to research different clients (ones that could be run from a terminal) and started a personal selection process.

My research lead me to two clients (irssi and weechat) and in the end I settled on weechat.
  • Note: This post is not to explain why I chose which client (I may do that in another post) however, this post is to document my move from xchat to weechat and how I made it feel similar to what I was used to.
I was inspired by Dennis Kaarsemaker's post on irssi for xchat refugees, and thus how I got the title for this post.

With that said, the weechat getting started guide is quite good, for any one starting with IRC or moving to the weechat client.

One of the hardest thing to understand (or find information on) about terminal based irc clients is what what each component of the main layout is or stands for.

Weechat in and of its self did not make this easy, however once you know where to look (the weechat users guide, on screen lay out), you quickly figure it out. In short, by default weechat gives you a chat area and 4 primary bar's (interactive areas). If you try and relate this to xchat its everything except the channels / servers (networks) list that you see on the left by default.

So out the door, weechat gets you fairly close to the default xchat layout with out having to do anything (this is nice if your looking to make a simple transition).

However while the title, input and nicklist bars are simple to understand/ decipher their content in the status bar left me baffled for some time. While its simple to understand the point of the status bar its contents were not clean until I looked up the configuration for weechat.bar.status.items.
/help weechat.bar.status.items
Option "weechat.bar.status.items":
  description: items of bar, they can be separated by comma (space between items) or "+" (glued items); special synta "@buffer:item" can be used to force buffer used when displaying the bar item
  type: string
  values: any string
  default value: "[time],[buffer_last_number],[buffer_plugin],buffer_number+:+buffer_name+(buffer_modes)+{buffer_nicklist_count}+buffer_zoom+buffer_filter,[lag],[hotlist],completion,scroll"
  current value: "[time],buffer_number+: +buffer_name,[lag],completion,scroll"
As you can see from the output I have changed my status bar to fit my needs, as I don't need or like all the default items. You can do the same, however the reason for explaining this again is to give you a reference for the default layout.

For someone used to xchat the channels/servers (networks) list will likely be important. To solve this, I went to the weechat plugin infrastructure and found 2 plugins (scripts), that build this list and keep it sorted in a similar way to xchat.

The buffers.pl script builds the channels/network (servers) list automatically and simply displays it to you. Installing it is quite simple, as it is with most plugins.
cd ~/.weechat/perl/autoload; wget https://weechat.org/files/scripts/buffers.pl
The next critical plugin to this layout (xchat conversion) is the autosort.py script that arages the channels/servers in alphabetical lists in the same way xchat does. Installing it is the same as the buffers.pl script above.
cd ~/.weechat/python/autoload; wget https://weechat.org/files/scripts/autosort.py
  • Note:  I find it easiest to restart weechat to pick up the changes, however I know (and I use), alternative methods to reload scripts / plugins.
The only other change I made to weechat was to make 2 setting modifications so that the channels/servers list is without numbers and is indented (similar to xchat).
/set buffers.look.show_number off
/set buffers.look.indenting on
And with that, you have a terminal based weechat client that looks and feels like xchat.

Because F11, maps to full screen (for most thing) and F12 is my hot key for the Gnome Dropdown Terminal I also make the following change to my weechat.conf file:
    diff weechat.conf{,_old}
    < meta2-23;3~ = "/bar scroll nicklist * -100%"
    < meta2-23~ = "/bar scroll nicklist * b"
    < meta2-24;3~ = "/bar scroll nicklist * +100%"
    < meta2-24~ = "/bar scroll nicklist * e"
    ---
    > meta2-23~ = "/bar scroll nicklist * -100%"
    > meta2-23;3~ = "/bar scroll nicklist * b"
    > meta2-24~ = "/bar scroll nicklist * +100%"
    > meta2-24;3~ = "/bar scroll nicklist * e"
    With this change I make the configuration a little more useful, by mapping alt+F1[1|2] to be the scroll for  the nick bar, as opposed to only being able to see the top or bottom.

    Another nice part about weechat is that plugins, like the hilight plugin,
    are not needed because weechat can use regular expressions or denote phases in its highlight setting.
    Option "weechat.look.highlight":
      description: comma separated list of words to highlight; case insensitive comparison (use "(?-i)" at beginning of words to make them case sensitive), words may begin or end with "*" for partial match; example: "test,(?-i)*toto*,flash*"
    One thing that is lacking from weechat that xchat has is gnome integration, with notifications. To be fair to weechat, as this is a terminal tool, the primary notification method is the terminal beep.

    To get such a gnome or GUI pop-up notification, I recommend using the lnotify.py (requires notify-python) plugin/script because of its simplicity.
    •  Note: on a Fedora system you can get this by running: 
    # sudo yum install notify-python.x86_64
    One issue I had with it was that Fedora does not have a 'weechat' icon, by default.

    Instead of making one (or finding one), I simply used one of the standard gnome icon names to set the plugins.var.python.lnotify.icon option (I use mail-unread), for the plugin, so that libnotify supply an image (instead of a blank space) sending notifications.

    I was even able to find, a way to start weechat, so that it looks / feels like a stand alone GUI application, within gnome! 
    To do this you can follow Gnome Desktop Files Developer's Guide, or you can simply create a file like the one below, and place it in /usr/share/applications.
    [Desktop Entry]
    Type=Application
    Encoding=UTF-8
    Name=WeeChat
    Comment=WeeChat GUI
    Exec=gnome-terminal --hide-menubar -e weechat
    Icon=application.png
    Terminal=false
    What this does is starts, a gnome terminal, and weechat within it. By hiding the gnome menu bar, the terminal and weechat start to look like any other gnome application. 
    With these simple modifications, I was able to quickly transition from xchat to weechat, and the following shows a side by side comparison of the transition. 

    Real Estate - Optimizations for Fedora / Linux.

    A long time ago, I wrote a post about setting up my move to Linux and some of the tools I was using / learning. Since I wrote that post, I have had a lot of time, to really learn various things about Fedora,and the gnome (window manager).

    The most important lesson I feel I have learned in 2 years, is that the tools you choose are important.
    Well Duh!
    What I mean by this is that, over the last 2 years, I have had to change the way I work. In my job supporting RHEL and JBoss, I had a fairly well defined job role and because of this my tools could be generic or fairly oversimplified.

    As I transitioned roles into supporting OpenShift and Cloud Products such as OpenStack, I had to become more mobile -- relying less on my "desktop" setup (with 3 monitors) and more on my "laptop" (with a single 15 inch screen).

    In this transition I learned a lot about Screen Real Estate and how the tools you choose to do your day to day work can affect your performance.

    In a lot of ways, downsizing to a laptop (solely) can be hard, however it does not have to be a productivity killer.

    Gnome 3(the default window manager in Fedora) already has a lot of space saving concepts built in. For example Workspaces allow you to organize your work or tasks on the screen in such a way that you can quickly switch between whatever item needs your focus.

    While this is great in my humble opinion it's simply not enough. To give you an idea of what I mean, consider the following:
    1. I need a web browser (often takes a full screen, due to the number of tabs I have open). 
      • I use this for things like reading email, research, ticketing system, etc.
    2. I need a terminal (often takes a full screen, applications stopped following the 80 character rule)
      • I use this for server management, log review, text editing, etc (this list could be a post in and of itself).
    3. I need some way to communicate
      • IRC -- often takes a full screen, simply so I don't lose my mind.
    4. Other tools (that require a full screen):
      • Remote Support Client
      • WireShark  
    With this in mind, you can quickly see I generally get to 4 (or more) work spaces quite quickly. The concept works great if your not getting interrupted and don't have a need to switch between them all the time. It's simply just not effective in my opinion.

    Back in my move to Linux I highlighted two tools that started my thought process to improve this situation. The tools were TMUX and the Gnome Drop Down Terminal.

    With the Gnome Drop Down Terminal I get to remove one of my work spaces (or hide it), so that I can stay on the work space (or whatever work space I happen to be on) and switch directly to a terminal. In short my terminal is only every quick short cut away (not potentially 2+ short cuts away).

    With a terminal only ever a shortcut away, a terminal multiplexer like Screen or TMUX make it simple to have multiple terminals within 2 keyboard shortcuts, no matter what I do.

    However even with these tools I potentially still have 2+ work spaces, and this is why I say the tools you choose are important. Let's focus on my last required work space (the one I use for IRC). If the tool is generic or fairly oversimplified (like Xchat, or any GUI IRC client), something designed for the masses, you often have to compromise screen real estate.

    Now I am not trying to pick on Xchat or GUI clients, however when it comes to thick clients or FAT applications, when your on a laptop or a limited screen real estate environment, these simply slow / hurt productivity.

    So the final major change I made was to move from a GUI based IRC client to a terminal based IRC client.
    Again because I can get to any terminals with in 2 keyboard shortcuts, no matter what I do, it does not matter how many other optional GUI based applications I have open, because my required items are only every 2 keyboard shortcuts away.

    These tools allow me to take full advantage of my limited real estate, while allowing me to expand out (provided I choose the right/most effective tools).
    • Note: From the tools I listed above, I have more or less been able to move to 1 (most of them time) work space, as Wireshark can be replaced by tshark (a command line version of the GUI application), however this has quite a steep learning curve.