Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import weechat
- weechat.register("inxi", "Flummi", "0.1", "GPL3", "Print Sysinfo in WeeChat", "", "")
- cmd_hook_process = ''
- cmd_buffer = ''
- cmd_stdout = ''
- def inxi_cb(data, buffer, args):
- """Callback for /inxi command."""
- inxi_exec(buffer, 'inxi')
- return weechat.WEECHAT_RC_OK
- def inxi_init():
- """Initialize some variables."""
- global cmd_hook_process, cmd_buffer, cmd_stdout
- cmd_hook_process = ''
- cmd_buffer = ''
- cmd_stdout = ''
- def inxi_process_cb(data, command, rc, stdout, stderr):
- """Callback for hook_process()."""
- global cmd_hook_process, cmd_buffer, cmd_stdout
- cmd_stdout += stdout
- if int(rc) >= 0:
- if cmd_stdout:
- lines = cmd_stdout.rstrip().split('\n')
- for line in lines:
- weechat.command(cmd_buffer, '%s' % line)
- cmd_hook_process = ''
- return weechat.WEECHAT_RC_OK
- def inxi_exec(buffer, command):
- """Execute inxi."""
- global cmd_hook_process, cmd_buffer, cmd_stdout, cmd_stderr
- inxi_init()
- cmd_buffer = buffer
- cmd_hook_process = weechat.hook_process_hashtable('sh', { 'arg1': '-c', 'arg2': 'inxi' }, 2000, 'inxi_process_cb', 'inxi')
- hook = weechat.hook_command("sysinfo", "Print Sysinfo in WeeChat",
- "",
- "",
- "",
- "inxi_cb", "")
Add Comment
Please, Sign In to add comment