Skip to content

Commit

Permalink
New script auto_read_buffer.py: marks buffer as read when switching away
Browse files Browse the repository at this point in the history
  • Loading branch information
kindrowboat committed Mar 5, 2024
1 parent 2db7f4a commit 953ee3d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions python/auto_read_buffer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
import weechat

SCRIPT_NAME = "auto_read_buffer"
SCRIPT_AUTHOR = "Stef Dunlap <[email protected]>"
SCRIPT_VERSION = "1.0"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Automatically marks a buffer as read upon switching away"

# Global variable to store the current buffer
current_buffer = None

# Callback for the buffer switch signal
def buffer_switch_cb(data, signal, signal_data):
global current_buffer
# If there is a previously focused buffer, mark it as read
if current_buffer is not None:
weechat.buffer_set(current_buffer, "hotlist", "-1")
# Update current_buffer to the new buffer
current_buffer = signal_data
return weechat.WEECHAT_RC_OK

# Callback to update current_buffer when script loads
def buffer_opened_cb(data, signal, signal_data):
global current_buffer
current_buffer = signal_data
return weechat.WEECHAT_RC_OK

if __name__ == "__main__":
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
# Hook into the buffer switch and buffer opened signals
weechat.hook_signal("buffer_switch", "buffer_switch_cb", "")
weechat.hook_signal("buffer_opened", "buffer_opened_cb", "")

0 comments on commit 953ee3d

Please sign in to comment.