11

Sometimes I need to reboot my linode, which includes my IRC client, weechat, running in tmux. When I do this, I prefer to save all the buffers that are running and rejoin them. I was under the impression that:

 /layout save
 /save

Would store the appropriate information and

 /layout apply

Would... well apply it. Unfortunately, while it correctly places new channels, it does not in any way rejoin the ones I was connected to before. I understand that I can manually add a list of channels to autojoin, for each network, but if I have to do that tedious process each time I need to close and reopen weechat... well that would be a drag at the very least.

Any ideas? I am sure I've done this before.

Frew Schmidt
  • 1,221
  • 3
  • 16
  • 28

3 Answers3

16

Okay, after asking around in the freenode #weechat channel a bit I finally got this:

  • Download the autojoin.py script to ~/.weechat/python/autoload
  • Run /python autoload to load the script
  • Run /autojoin --run to store the channels to join
  • Run /layout store to store the order of the channels
  • Run /save to save your settings to a file

Next time you start weechat and connect to a server the channels you were connected to when you did these steps will be joined for you.

alexjj
  • 23
  • 4
Frew Schmidt
  • 1,221
  • 3
  • 16
  • 28
  • what version of weechat are you on, as debian stable is *way* behind current, and the wording of your question does not mention using an old version of weechat? Not that it a big deal, but just a dated method/harder. – demure Apr 22 '14 at 02:14
  • Is it that much harder though? You install the script with wget instead of another command, and you use /python instead of /script. While I understand that many don't see the benefit of using packaged software, this works for both old *and* new versions. So why not? – Frew Schmidt Apr 22 '14 at 12:40
  • One of the big things with the `/script` command, is you can keep your scripts up to date with minimal effort; it will tell you that there are new versions, and you can update right from the interactive buffer. No reason to go back to the days of irssi, and update/install by hand ^_- – demure Apr 23 '14 at 03:28
  • Yeah, that's legit. Although in this case I still think it's overkill, given that the script in question was last updated 5 years ago. – Frew Schmidt Apr 23 '14 at 13:06
  • 2
    I'm on Weechat 1.0.1, and I needed to call `/layout store` instead – Joost May 04 '16 at 07:51
  • This works great until you join a channel requiring authorization with a nickserver, and the client joins the channel before the nickserv can finish authorization. – ipatch Jan 19 '19 at 17:05
2

Here is how you can automate the other answer such that your buffer layout is saved to disk every hour:

  1. Get the cron.py user script:

    • Run /script (e.g. in the weechat.core buffer)
    • Type cron, press Enter in the buffer which was just opened
    • Select cron.py via cursors, type i and press Enter for installation.
  2. In the weechat.core buffer, execute the following command:

    /cron add 0 1 * * * * core.weechat commands /autojoin --run;/layout store;/save
    

    This adds an hourly cron job running the commands the other answer suggested. Note that the commands are separated by ; without trailing spaces! Execute /cron help for more information.

  3. Test this by first executing /cron list, remembering the number of the cron job you just added (e.g. 001), and then running /cron exec 001.

ComFreek
  • 581
  • 2
  • 7
  • 24
1

WeeChat 3.5 (released on 2022-03-27) has introduced a built-in /autojoin command. If you are running version 3.5 or above, the autojoin.py script mentioned in Frew's answer is no longer needed. The updated steps are as follows:

  1. Run /autojoin apply to set the currently joined channels in the autojoin option.
  2. Run /layout store to store the order of the channels.
  3. Run /save to save your settings to a file.

The next time you start WeeChat and connect to a server, the channels you were connected to when you did these steps will be joined for you.

ntwk
  • 11
  • 1