add message notification bell for textui

This commit is contained in:
Jeremy O'Brien 2024-01-25 10:14:12 -05:00
parent 8b69947098
commit 04376a9f96

View File

@ -125,6 +125,7 @@ class NomadNetworkApp:
self.peer_announce_at_start = True self.peer_announce_at_start = True
self.try_propagation_on_fail = True self.try_propagation_on_fail = True
self.disable_propagation = False self.disable_propagation = False
self.notify_on_new_message = True
self.periodic_lxmf_sync = True self.periodic_lxmf_sync = True
self.lxmf_sync_interval = 360*60 self.lxmf_sync_interval = 360*60
@ -546,6 +547,9 @@ class NomadNetworkApp:
nomadnet.Conversation.ingest(message, self) nomadnet.Conversation.ingest(message, self)
if self.notify_on_new_message:
self.notify_message_recieved()
if self.should_print(message): if self.should_print(message):
self.print_message(message) self.print_message(message)
@ -649,6 +653,11 @@ class NomadNetworkApp:
if os.path.isfile(self.conversationpath + "/" + source_hash + "/unread"): if os.path.isfile(self.conversationpath + "/" + source_hash + "/unread"):
os.unlink(self.conversationpath + "/" + source_hash + "/unread") os.unlink(self.conversationpath + "/" + source_hash + "/unread")
def notify_message_recieved(self):
if self.uimode == nomadnet.ui.UI_TEXT:
sys.stdout.write("\a")
sys.stdout.flush()
def clear_tmp_dir(self): def clear_tmp_dir(self):
if os.path.isdir(self.tmpfilespath): if os.path.isdir(self.tmpfilespath):
for file in os.listdir(self.tmpfilespath): for file in os.listdir(self.tmpfilespath):
@ -726,6 +735,10 @@ class NomadNetworkApp:
value = self.config["client"].as_bool(option) value = self.config["client"].as_bool(option)
self.compact_stream = value self.compact_stream = value
if option == "notify_on_new_message":
value = self.config["client"].as_bool(option)
self.notify_on_new_message = value
if option == "user_interface": if option == "user_interface":
value = value.lower() value = value.lower()
if value == "none": if value == "none":
@ -953,6 +966,7 @@ destination = file
enable_client = yes enable_client = yes
user_interface = text user_interface = text
downloads_path = ~/Downloads downloads_path = ~/Downloads
notify_on_new_message = yes
# By default, the peer is announced at startup # By default, the peer is announced at startup
# to let other peers reach it immediately. # to let other peers reach it immediately.