From b1825390b854d9251dd18304b8efb62b8107cd7c Mon Sep 17 00:00:00 2001 From: airclay Date: Fri, 3 Sep 2021 11:04:56 -0500 Subject: [PATCH] WIP --- systrayUpdater.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/systrayUpdater.py b/systrayUpdater.py index 178530f..a24b843 100755 --- a/systrayUpdater.py +++ b/systrayUpdater.py @@ -13,7 +13,7 @@ from PyQt5.QtGui import * from PyQt5.QtWidgets import * # Available Updates count holder -Nupd = [] +#Nupd = [] avail = "" # Use config.yml file to allow for compatibility with @@ -32,17 +32,23 @@ def count(): p1 = subprocess.Popen(cmd, stdout=subprocess.PIPE) p2 = subprocess.Popen(['wc', '-l'], stdin=p1.stdout, stdout=subprocess.PIPE) output = ((p2.communicate()[0]).decode()).rstrip('\n') - digit = str(output)+" Updates" - global Nupd - Nupd.append(digit) + #digit = str(output)+" Updates" + #global Nupd + #Nupd.append(digit) global avail - avail = Nupd[-1] + #avail = Nupd[-1] + avail = str(output)+" Updates" # Run system update def update(): cmd = [ term, opt, 'sudo', 'pacman', '-Syu'] subprocess.Popen(cmd) +def newText(event): + count() + option1.setText(avail) + tray.setToolTip(avail) + # Initially populate available updates count count() @@ -67,6 +73,7 @@ tray.setVisible(True) menu = QMenu() option1 = QAction(avail) option1.triggered.connect(update) +option1.triggered.connect(newText) menu.addAction(option1) # To quit the app @@ -78,13 +85,9 @@ menu.addAction(quit) tray.setContextMenu(menu) # Update the labels for available updates count -for i in Nupd: - option1.triggered.connect(lambda bVal, menuItem=avail: addLabel(bVal,menuItem)) - option1.setText(avail) - tray.setToolTip(avail) - -def addLabel(self, menuItem): - print(menuItem) - +#for i in Nupd: +# option1.triggered.connect(lambda bVal, menuItem=avail: newText(bVal,menuItem)) +# option1.setText(avail) +# tray.setToolTip(avail) app.exec_()