Skip to content

Instantly share code, notes, and snippets.

@edsantiago
Created April 5, 2015 18:31
Show Gist options
  • Save edsantiago/f45ef3743cfe8c5d4931 to your computer and use it in GitHub Desktop.
Save edsantiago/f45ef3743cfe8c5d4931 to your computer and use it in GitHub Desktop.
Simpleminded tool to cycle through weechat buffers layout options
# -*- perl -*-
use strict;
use warnings;
weechat::register("cycle-buffers", 'Ed <weechat@edsantiago.com>', "0.1",
"GPL3", "one-shot tool for testing buffers.pl configurations",
"", "");
weechat::hook_command("cycle-buffers", "", "", "", "", "cycle_buffers", "");
my @positions = qw(top left); # For our purposes, top==bottom && left==right
my @fillings = qw(horizontal vertical columns_horizontal columns_vertical);
my $pos_index = @positions;
my $fill_index = @fillings;
sub cycle_buffers {
my ($data, $buffer, $args) = @_;
if (++$fill_index > $#fillings) {
$fill_index = 0;
if (++$pos_index > $#positions) {
$pos_index = 0;
}
_set_buffer('position', $positions[$pos_index]);
}
my $which_option = ($positions[$pos_index] =~ /top|bottom/
? 'top_bottom'
: 'left_right');
my $fill_value = $fillings[$fill_index];
_set_buffer("filling_$which_option", $fill_value);
weechat::print("", "$positions[$pos_index] $fill_value");
return weechat::WEECHAT_RC_OK;
}
sub _set_buffer {
my ($option, $setting) = @_;
weechat::command("", "/mute /set weechat.bar.buffers.$option $setting");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment