You’re reading diehealthy.org

My Weechat Desktop File (and its Supporting Files).

I wanted an easy (ha!) way to open Weechat in its own terminal profile.

As I’m thinking that Hexchat will eventually see removal (upstream no longer being maintained) in Debian (as it apparently is already planned to in Fedora), I decided to find a new IRC client. I don’t use IRC very much, but I like being able to without having to work too hard or do something silly like using a web client, so after looking at an apt search irc output, I first tried irssi, as I already had it installed and had probably used it a little at some point.

Irssi is solid, but after using it over a few weeks and working on configuring it to my liking, I got a bit frustrated. I don’t really know much Perl, and while it has a Python script plugin, it’s not packaged in Debian. The other thing that bugged me is while it has 24-bit color support, the theming and documentation and trial-and-error attempts suggested it’s not available everywhere. So I decided to try Weechat.

Weechat does not have 24-bit color support, but it does have 256-color support, which I decided is fine. I can write scripts in Python without needing to compile a plugin myself. And, in general, it seems a bit more modern while still being a terminal client.

The .desktop File.

One thing that Weechat doesn’t come with (at least in its Debian package) is a .desktop file that lets me easily add it to my shortcuts (the dash) in GNOME Shell. But they aren’t hard to make. It’s just a text file specifying some keys and values.

My initial motivation wasn’t a shortcut, but rather that I wanted the terminal Weechat runs in to hide its scrollbar. The scrolling is handled by Weechat, not the terminal emulator, so having the scrollbar is pointless. As I otherwise keep the scrollbar, I looked at the documentation and some search results and found the easiest way would be to use a separate profile for gnome-terminal.

The first thing to do, assuming you use gnome-terminal and want a similar setup, is to clone your profile into a new one. You can find this in the settings of gnome-terminal: right-click on your existing profile, choose clone. Now go switch the scrollbar off in that new profile, under scrolling. Easy.

But to be able to easily invoke a fresh terminal with that profile, you want something to remember it for you. You could write a shell alias. You could write a shell script. You could write a .desktop file. I went with the .desktop file, because I wanted to have a shortcut icon, but you could even do all of the above.

[Desktop Entry]
Name=Weechat
GenericName=IRC Client
Comment=A terminal IRC client.
Exec=gnome-terminal --title=Weechat --geometry=96x24 --profile=weechat -- weechat
Terminal=false
Icon=irc-chat.svg
Type=Application
Keywords=IM;Chat;
Categories=ConsoleOnly;Network;IRCClient;
StartupNotify=true
NoDisplay=false
My initial weechat.desktop file.

Most of it is boilerplate, with the important bits being the Exec line and the Icon line. First the icon. While the Debian package has an XPM file, I ended up grabbing a generic IRC client icon from an icon theme. You could do the same, leave it iconless (remove that line), or use whatever other image you wanted.

The gnome-terminal Exec line creates a terminal, sets the title, uses the profile you cloned, and then runs weechat in that new terminal. It also sets the width of the terminal to 96 characters instead of the default of 80. I do this because I keep the nickname list open in IRC channels, and having the extra width helps from keeping the chat from becoming a newspaper column.

If you were forgoing a special profile, you would change the Exec to invoke Weechat directly, but you would also set Terminal to true, because it needs a terminal to run in. As we’re running a terminal directly, a terminal doesn’t need another terminal, so it’s false in our case.

Fixing GNOME Shell’s Dash Grouping.

This is where I ended up switching to Alacritty. I decided it would be nice if GNOME Shell’s dash would mark the Weechat item as running, but instead it groups it under the gnome-terminal shortcut item. I eventually found gnome-terminal bug #7734: “Allow to create specific terminal applications”, which suggested there isn’t currently a good way to get the dash to keep it under its own shortcut. Maybe some day.

Maybe today. Enter Alacritty. (Though other terminals would also work; just not gnome-terminal.)

First, I replaced the Exec line with: Exec=scripts/weechat.sh

The full Alacritty command line did not want to work without the full path for the configuration file. The assumption of programs is that path expansions happen before the command line options are handed to the program, so you can’t put them in an Exec. Instead, you need to make a shell script and specify that. Wee!

#!/bin/bash
alacritty --config-file $XDG_CONFIG_HOME/alacritty/weechat.toml -e weechat
My weechat.sh.

In order for the GNOME Shell dash to recognize a program is open, it has to match up an ID, in this case the WM_Class or window manager class. Using Alacritty, I needed a config for it to handle the extra options, including setting that window manager class. (You can specify it in the command line, but I decided to do it in the configuration file, because I’ve already created a .desktop file and a shell script, why not an extra configuration file or two while we’re at it!) So here’s the configuration files for Alacritty:

[window]
dimensions = { columns = 80, lines = 24 }
resize_increments = true
[font]
size = 15.0
My base alacritty.toml configuration.

The dimensions line is surely redundant to the default, but the second option lets me resize the window so it won’t have a half-line or half-character. I like a larger font, so I set that too. Everything else (for now) is defaults.

[general]
import = ["~/.config/alacritty/alacritty.toml"]
[window]
dimensions = { columns = 96, lines = 24 }
title = "weechat"
class = { instance = "weechat", general = "weechat" }
My weechat.toml configuration.

The Weechat-specific configuration isn’t much more. It imports the base configuration, makes it 96 characters wide, sets the title, and sets that pesky ID so that everything works.

Phew. Who said Linux was hard to use?

For now the rest of my Weechat configuration is mostly the defaults, with a few tweaks. I have one script installed, urlgrab.py, which I use because the terminal chat line wrapping may break longer URLs, and while you can switch to the raw display mode (Alt+L), it’s easier to type /url 1 to open the URL in your web browser than all that.


news

NPR Text-Only News

Low-clutter news from National Public Radio.

Please Deposit Two Cents:

This site uses Akismet to reduce spam. Learn how your comment data is processed.