/usr/share/weechat/python/alternatetz.py is in weechat-scripts 20111030-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | # -*- coding: utf-8 -*-
#
# Chmouel Boudjnah <chmouel@chmouel.com>
# License: GPL3
#
'''
Display Different time in buffer.
Just put [alternatetz] on your bar items to add it.
'''
import weechat as w
import pytz
import datetime
SCRIPT_NAME = "alternatetz"
SCRIPT_AUTHOR = "Chmouel Boudjnah <chmouel@chmouel.com>"
SCRIPT_VERSION = "0.1"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Display Alternate Time from different TimeZone"
# script options
settings = {
"timezone" : 'US/Central',
"timeformat" : "%H:%M",
}
def alternatetz_item_cb(*kwargs):
tzname = w.config_get_plugin('timezone')
tz = pytz.timezone(tzname)
return datetime.datetime.now(tz).strftime(w.config_get_plugin('timeformat'))
def alternatetz_timer_cb(*kwargs):
w.bar_item_update('alternatetz')
return w.WEECHAT_RC_OK
if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
SCRIPT_DESC, '', ''):
for option, default_value in settings.iteritems():
if not w.config_is_set_plugin(option):
w.config_set_plugin(option, default_value)
w.bar_item_new('alternatetz', 'alternatetz_item_cb', '')
w.bar_item_update('alternatetz')
w.hook_timer(1000*60, 60, 0, 'alternatetz_timer_cb', '')
|