diff options
author | Tom Feist <shabble@metavore.org> | 2011-09-24 23:40:16 +0000 |
---|---|---|
committer | Tom Feist <shabble@metavore.org> | 2011-09-24 23:40:16 +0000 |
commit | f92453c4bffec2e4fd291102d53acb4adb810676 (patch) | |
tree | 829a80b7e1aad1e444c1db873f38a0e94f7c6b46 /feature-tests | |
parent | cleanup linehax a bit. (diff) | |
download | irssi-scripts-f92453c4bffec2e4fd291102d53acb4adb810676.tar.gz irssi-scripts-f92453c4bffec2e4fd291102d53acb4adb810676.zip |
added any_time.pl
adds a statusbar item called 'any_time' with a custom time
format configuration (with /set any_time_format %H:%M or whatever. Uses
standard POSIX strftime formats).
Diffstat (limited to '')
-rw-r--r-- | feature-tests/any_time.pl | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/feature-tests/any_time.pl b/feature-tests/any_time.pl new file mode 100644 index 0000000..fd00b02 --- /dev/null +++ b/feature-tests/any_time.pl @@ -0,0 +1,37 @@ + +use strict; +use warnings; + +use Irssi; +use Irssi::TextUI; # for sbar_items_redraw +use POSIX qw/strftime/; + +my $time_format; + +sub any_time_sb { + my ($sb_item, $get_size_only) = @_; + + my @time_now = localtime(); + my $formatted_time = strftime($time_format, @time_now); + + $sb_item->default_handler($get_size_only, "{sb $formatted_time}", '', 0); +} + +sub sig_setup_changed { + $time_format = Irssi::settings_get_str('any_time_format'); +} + +sub init { + Irssi::settings_add_str('any_time', 'any_time_format', '%H:%M'); + Irssi::signal_add('setup changed', \&sig_setup_changed); + + sig_setup_changed(); + + Irssi::signal_add('expando timer', + sub { Irssi::statusbar_items_redraw('any_time') }); + + + Irssi::statusbar_item_register ('any_time', 0, 'any_time_sb'); +} + +init(); |