Skip to content

Commit

Permalink
added manual refresh incase user doesn't want to wait 5 min
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniofs23 committed Dec 28, 2023
1 parent db1bd3e commit 0df427c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,14 @@ def create_menu(self):
# self.indicator.set_secondary_activate_target(item_model)

# add a separator between devices and quit button
# menu_sep = Gtk.SeparatorMenuItem()
# menu.append(menu_sep)
menu_sep = Gtk.SeparatorMenuItem()
menu.append(menu_sep)

# manual_refresh incase user doesn't want to wait 5min
# or wants to check bt-battery of a newly added device
item_manual_refresh = Gtk.MenuItem("manual refresh")
item_manual_refresh.connect("activate", self.manual_refresh)
menu.append(item_manual_refresh)

# quit button
# item_quit1 = Gtk.MenuItem('quit')
Expand All @@ -77,6 +83,13 @@ def create_menu(self):
# def stop(self, source):
# Gtk.main_quit()

def manual_refresh(self, source):
GObject.idle_add(
self.indicator.set_menu,
self.create_menu(),
priority=GObject.PRIORITY_DEFAULT,
)

def update_battery_status(self):
while True:
time.sleep(300) # updates every 5 minutes
Expand Down

0 comments on commit 0df427c

Please sign in to comment.