Weechat even more configuration

This is the last post in series about using Weechat for Slack and IRC. The last major element we need to configure is notifications. I'm also going to provide some details on how to use different configurations for a work and home set-up. Some configuration of the different bars like the nicklist and buffer bar. And then provide my full configuration.

This post is part 4 of a four part series:

Weechat Notifications

There are lots of options for notifications in Weechat whether you're running it from a local system or a remote system. I'm running a Linux desktop (Ubuntu) and use weechat-notify-send by Petr Zemek. It works with both Slack and IRC where you're running Weechat locally, with a local notify-send to provide the alert. It's worth reading his original post A New Notificaiton Plugin for WeeChat.

Weechat-notify-send doesn't appear in the Scripts buffer in Weechat so we have to manually install it.

cd ~/.weechat/python
curl -O https://raw.githubusercontent.com/s3rvac/weechat-notify-send/master/notify_send.py
cd autoload
ln -s ../notify_send.py autoload/

To see and set the options from within Weechat do:

/set plugins.var.python.notify_send.*

I have the following settings:

# send notifications on highlights
/set plugins.var.python.notify_send.notify_on_highlights "on"

# send a notification if there is a private message
/set plugins.var.python.notify_send.notify_on_privmsgs "on"

# send messages on filtered (hidden) messages
/set plugins.var.python.notify_send.notify_on_filtered_messages "off"

# send a notifications from the current buffer
/set plugins.var.python.notify_send.notify_for_current_buffer "on"

# in my case I want the alert but not the content of the message.
# the easiest way to do this is to tell it to hide messages from some
# all buffers - match everything
/set plugins.var.python.notify_send.hide_messages_in_buffers_that_match ".*"

# this is the length of the message, which initially is their name
# the default is 72 chars. It can't really handle 1 or 0 so I used
# hid_messages_in_buffers_that_match instead
/set plugins.var.python.notify_send.max_length 10

# this is an odd setting - it basically means follow the rules for the current
# buffer, so it should be set to on
/set plugins.var.python.notify_send.notify_for_current_buffer "on"

# the period the notification is shown for on your screen in milliseconds
# the default is 5000 (5 seconds)
/set plugins.var.python.notify_send.timeout "2000"

# location of the icon that is used to for the notification
# default is /usr/share/icons/hicolor/32x32/apps/weechat.png
/set plugins.var.python.notify_send.icon "/usr/share/pixmaps/weechat.xpm"

# looks a bit better with the svg icon - grab it from
# https://github.com/weechat/weechat/blob/master/icons/scalable/weechat.svg
/set plugins.var.python.notify_send.icon "/home/steve/Downloads/weechat.svg"

# this is for hotlist - not sure if it fixes Notifications
# default notify level for buffers
# set to higlight if you only want hotlist on mentions
weechat.look.buffer_notify_default

In work I'm often sharing my screen to present to potential customers. I'm always fearful that some inappropriate message from a co-worker will pop-up on the screen - I've seen it happen! Consequently, I've set notifications to show for private messages, but have set it to hide the specific message with hide_messages_in_buffers_that_match, that way the icon shows but not the actual message.

Bar and Nicklist set-up

The various bars and screen elements of Weechat can be configured and their look changed. You'll find quite complex configurations in blog posts, I'm keeping it pretty simple.

The status bar is the horizontal row just above the input area. Scripts sometimes add information to this area. In the Weechat settings it is known as weechat.bar.status. To see the settings that are available do:

/set *status*

I cut down the amount of information on the bar to the minimum:

# this is my current setting with the buffer name and buffer number on the left
# additional information is the hotlist and the spelling completion and suggestions
/set weechat.bar.status.items "buffer_name:+buffer_number+ |,hotlist |,completion,[spell_suggest]"

The buffer list is the one on the left that shows the different servers and channels we're connected to. We configured this quite a lot in the first blog post. To see the various settings do:

/set *buflist*

There are some channels that have very long names:

# size of the buffer list bar on the left in characters. If set to 0 it will
# autoscale. I set it to 30 as there are very long names on Slack channels
/set weechat.bar.buflist.size_max 30

# buffer number a space and then the hotlist ones are coloured
/set buflist.format.buffer "${format_number}${format_nick_prefix}${color_hotlist}${format_name}"

Finally, the Nick list is the bar which shows the nicknames of the other people in the channel. To see the settings do:

/set *nicklist*

My settings are:

# show the Nicklist if the window is wide enough
/set weechat.bar.nicklist.conditions "${info:term_width} > 100"

# limit the size of the nicks in the bar
/set weechat.bar.nicklist.size_max 30

This is the only responsive part I use, so if the terminal window is too small it will automatically hide the nicklist rather than the buffer list. I also limit the size of the nicks that I see as I don't want the bar to take up lots of room.

Home and work chat

I like to disconnect from my work chat on the weekend and personal hobby chat during the work day. For a while I was loading and unloading IRC servers but that was annoying. More importantly the Slack plugin doesn't have the ability to easily connect and disconnect from a specific Slack workspace.

To solve this problem I run two different Weechat configurations which automatically connect to different Slack and IRC servers. To switch between them I use a different configuration directory:

weechat --dir ~/.weechat-work/

Full Configuration

Weechat doesn't like you to edit the settings in the settings files, so the best way to show the full settings is as a long list - cut-n-paste them into Weechat and then do a /save at the end. This should be every setting that I've discussed during these blog posts:

# install go.py script
# do <alt>-g <channel number> or <alt>-g <channel_name>
/key bind meta-g /go

# toggle buffer list or nick list
/key bind meta-n /bar toggle nicklist
/key bind meta-b /bar toggle buflist

# this is <alt>j/<alt>h
/key bind meta-j /buffer +1
/key bind meta-h /buffer -1

## spell checking ##
/set aspell.check.enabled on
/set aspell.check.default_dict "en_GB"
/set aspell.check.suggestions 3

# provides spelling menu with suggestions requires
# install menu.pl script and spell_menu.pl script
/set plugins.var.perl.menu.main_menu_hidden yes
# hide the menu so it doesn't take up a line
/set plugins.var.perl.menu.main_menu_hidden yes
# don't temporarily show the menu when we hit <tab> for spelling suggestions
# this stops the window moving around. Downside is we don't know that <Ctrl>x
# shuts the window without accepting a suggestion
/set plugins.var.perl.menu.active_help no


## buffer list on the left ##
/set weechat.bar.buflist.items "buflist"

## buffer list position ##
# This sets up to have buffer names under server name. To do this you have
# to run /script install autosort.py. and set irc.look.server_buffer independent
# not using this indent as it's nicer with the default
#/set buflist.format.indent "  "

# disable IRC's CTCP as they are a security risk
/set irc.ctcp.action ""
/set irc.ctcp.clientinfo ""
/set irc.ctcp.finger ""
/set irc.ctcp.ping ""
/set irc.ctcp.source ""
/set irc.ctcp.time ""
/set irc.ctcp.userinfo ""
/set irc.ctcp.version ""

## IRC colour ##
# use nick colour in the nick list bar on the right
/set irc.look.color_nicks_in_nicklist on
# close the buffer when you leave the channel
/set irc.look.part_closes_buffer on
# separate each 'server buffer' out so that the channels are shown underneath them
# this implies that you are running the autosort.py script
/set irc.look.server_buffer independent

# Don't show joins/parts for users who haven't spoken recently
/set irc.look.smart_filter on
/filter add irc_smart * irc_smart_filter *

## IRC specific ##
# reduce the amount of information someone can see
/set irc.server_default.nicks "<nickname>,<nickname>1"
/set irc.server_default.msg_quit ""
/set irc.server_default.msg_part ""
/set irc.server_default.username "<name>"

# Freenode server
/server add freenode chat.freenode.net/7000 -ssl
/set irc.server.freenode.nicks "<nickname>, <nickname>_"
/set irc.server.freenode.username "<nickname>"
/set irc.server.freenode.realname "<name>"
/set irc.server.freenode.ssl "on"

# set-up a secure SASL password for Nickserv
# assumes you did /secure passphrase <some-password>
/secure set freenode_password <mypassword>
/set irc.server.freenode.sasl_password "${sec.data.freenode_password}"
/set irc.server.freenode.sasl_username "mynick"
/set irc.server.freenode.autojoin <comma separated list of channels>

## Logging ##
# turn off logging for weechat application (core)
/set logger.level.core.weechat 0
# have it log everything for work
/set logger.level.python.weaveworks.slack.com 1
# have it log messages for irc
/set logger.level.irc 1
# location of logs - with year
/set logger.file.path "%h/logs/%Y/"
/set logger.file.mask "$plugin.$name.log"
# puts a box around the nickname in the log file.
/set logger.file.nick_suffix "]"
/set logger.file.nick_prefix "["

## Notifications ##
# using weechat-notify-send
# send notifications on highlights
/set plugins.var.python.notify_send.notify_on_highlights "on"
# send a notification if there is a private message
/set plugins.var.python.notify_send.notify_on_privmsgs "on"
# send messages on filtered (hidden) messages
/set plugins.var.python.notify_send.notify_on_filtered_messages "off"
# send a notifications from the current buffer
/set plugins.var.python.notify_send.notify_for_current_buffer "on"
# in my case I want the alert but not the content of the message.
# the easiest way to do this is to tell it to hide messages from
# all buffers - match everything
/set plugins.var.python.notify_send.hide_messages_in_buffers_that_match ".*"

# this is an odd setting - it basically means follow the rules for the current
# buffer, so it should be set to on
/set plugins.var.python.notify_send.notify_for_current_buffer on
# send ALL messages for the current buffer - we don't want this
/set plugins.var.python.notify_send.notify_on_all_messages_in_current_buffer "off"

# the period the notification is shown on your screen in milliseconds
# the default is 5000 (5 seconds)
/set plugins.var.python.notify_send.timeout "2000"
# location of the icon that is used to for the notification
# default is /usr/share/icons/hicolor/32x32/apps/weechat.png
/set plugins.var.python.notify_send.icon "/usr/share/pixmaps/weechat.xpm"
# maximum length of notification message
/set plugins.var.python.notify_send.max_length 20


## Slack  ##
# automically open threads when mentioned
/set plugins.var.python.slack.auto_open_threads true

# loads the history of buffers in the background rather than when you switch to it
# remove if there are performance problems.
plugins.var.python.slack.background_load_all_history

# don't show a typing indicator when someone is typing in a channel
plugins.var.python.slack.change_name_typing_indicator false

# these are default
plugins.var.python.slack.color_buflist_muted_channels "dark gray"
plugins.var.python.slack.color_deleted "red"
plugins.var.python.slack.color_edited_suffix 196
plugins.var.python.slack.color_reaction_suffix 058
plugins.var.python.slack.color_reaction_suffix_added_by_you blue
plugins.var.python.slack.color_thread_suffix 013
plugins.var.python.slack.color_typing_notice yellow
plugins.var.python.slack.colorize_attachments prefix
plugins.var.python.slack.colorize_private_chats false
plugins.var.python.slack.debug_level 0
plugins.var.python.slack.debug_mode on
plugins.var.python.slack.external_user_prefix *
plugins.var.python.slack.group_name_prefix &
plugins.var.python.slack.history_fetch_count 50
plugins.var.python.slack.map_underline_to _

# unclear what this does as there's no help for this setting
plugins.var.python.slack.migrated true

plugins.var.python.slack.muted_channels_activity "personal_highlights"
plugins.var.python.slack.never_away "true"
plugins.var.python.slack.notify_subscribed_threads auto
plugins.var.python.slack.notify_usergroup_handled_updated false
plugins.var.python.slack.record_events false
plugins.var.python.slack.render_bold_as bold
plugins.var.python.slack.render_emoji_as_string false
plugins.var.python.slack.render_italic_as italic
plugins.var.python.slack.send_typing_notice false
plugins.var.python.slack.shared_name_prefix %

# have shortened names internally - set to true
# doesn't show work slack properly which is slack.ourdomain
plugins.var.python.slack.short_buffer_names false

# show a plus symbol for present users
plugins.var.python.slack.show_buflist_presense true

# show names of users who reacted to an emoji next to it
plugins.var.python.slack.show_reaction_nicks true

# lengthen timeout if there are problems logging in
# had to do this a few times for very busy slack workspaces
plugins.var.python.slack.slack_timeout 80000

plugins.var.python.slack.switch_buffer_on_join true
plugins.var.python.slack.thread_messages_in_channel false
plugins.var.python.slack.unfurl_auto_link_display false
plugins.var.python.slack.unfurl_ignore_alt_text false
plugins.var.python.slack.unhide_buffers_with_activity false
plugins.var.python.slack.use_full_names false

## screen bars ##
# maximum size of the buffer (channel names) list on the left
/set weechat.bar.buflist.size_max 30

# let the input bar increase in size automatically if needed - default 1
/set weechat.bar.input.size 0

# nickname list should show but remove it if the terminal is too narrow
/set weechat.bar.nicklist only
/set weechat.bar.nicklist.conditions "${info:term_width} > 100"

# change the colour to a better contrast (default blue)
# sets to a light brown
/set weechat.bar.status.color_bg 238
# shorter bar than normal with fewer items in it
/set weechat.bar.status.items "buffer_name:+buffer_number+ \|,hotlist \|,completion,[spell_suggest]"

# the title bar at the top can resize to multiple lines if needed
/set weechat.bar.title.size 0

# set it to a better background color - default is blue
# if you set it to 'default' it uses the default background the terminal is
# set to so it gets out of the way and doesn't look like a bar.
/set weechat.bar.title.color_bg 235  # dark brown

# this is the colours that will be used in nicks
# the default is cyan,magenta,green,brown,lightblue,default,lightcyan,lightmagenta,lightgreen,blue
# works with Solarized or Black background
# remove 7 because it's the white which is my color
# remove 8 because it's the background color
# remove 11 as not distinct from 10
# unclear on dark background: 14 to 22, (15 is white which is me), 52->61
/set weechat.color.chat_nick_colors "1,2,3,4,5,6,9,10,13,22,27,28,31,34,38,40,44,48,63,69,70,75,77,80,82,92,112,128,130,138,142,148,154,161,167,173,177,180,183,184,186,209,212,215,225,226,228,247"


# colours to use for a highlighting: using it with the colorize_lines script
# sets an orange background to highlight the whole line
/set weechat.color.chat_highlight_bg 009
# sets a dark color - as we're reversing - the asterisk makes it bold text
/set weechat.color.chat_highlight *16

# default here is white for yourself - maybe use yellow
/set weechat.color.chat_nick_self white

# notify of activity in a buffer when there's a message or a highlight message
# basically ignore server activity.
/set weechat.look.buffer_notify_default message

# make the time look a darker grey - removed from the bar
# /set weechat.look.buffer_time_format "${color:245}%H:%M:%S"

# don't accidently quit: forces /quit -yes
/set weechat.look.confirm_quit on

# mouse - press <Alt> to send a URL to the terminal
# to select some text press <shift> and then select with the mouse, right click and copy
/set weechat.look.mouse on

# nicknames can only be 15 chars long
/set weechat.look.prefix_align_max 15

# if the previous line was from the same nick them don't repeat their name
# another alternative is to use an emoji 'return' symbol
# /set weechat.look.prefix_same_nick "⤷"  <-- there's a return symbol emoji there you can't see it
/set weechat.look.prefix_same_nick "⤷"

# Use a different color for offline Nicks
/set weechat.look.color_nick_offline yes

## Start-up options ##
/set weechat.startup.display_logo "off"
/set weechat.startup.display_version "off"

# stop certain plugins automatically loading as we don't need them
/set weechat.plugin.autoload "*,!exec,!fifo,!guile,!javascript,!lua,!ruby,!tcl,!xfer"

## Fast switching trigger ##
# Lets you do /<N> to jump to another buffer
# https://github.com/weechat/weechat/issues/762
/trigger add numberjump modifier "2000|input_text_for_buffer" "${tg_string} =~ ^/[0-9]+$" "=/([0-9]+)=/buffer *${re:1}=" ""

Yet more configuration

This is all the configuration that I use with Weechat. As a reminder I'm primarily using Weechat for Slack (particularly for work) and IRC as well. I'm aiming for a functional and efficient use of Weechat.

While we've covered a lot in the four posts, there's more scripts and configuration options to explore - there are lots of possibilities with Weechat! The most significant use of Weechat I haven't addressed is using a highlight monitoring (hi_mon) window and then having that window showing all the time so you can easily see whenever you are mentioned. I generally haven't gone into using Windows or creating your own keyboard shortcuts.

I use Weechat locally on Ubuntu, or I SSH into a remote system. There are some situations where you want to use Weechat as a relay and then connect an Android Weechat client or a Web one like Glowing Bear to it.

I also haven't addressed using other protocols like Matrix, Whatsapp or full multi-protocol IM (Twitter, Discord, XMPP) with BitlBee.

I hope you found the posts useful and that you're up and running with Weechat - as you can see there's plenty more things to explore ... and after that there's the whole talking to people thing!


Posted in Tech Tuesday 01 December 2020
Tagged with tech weechat irc slack