This commit is contained in:
airclay 2021-09-03 11:04:56 -05:00
parent 20548c1e82
commit b1825390b8
1 changed files with 16 additions and 13 deletions

View File

@ -13,7 +13,7 @@ from PyQt5.QtGui import *
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
# Available Updates count holder # Available Updates count holder
Nupd = [] #Nupd = []
avail = "" avail = ""
# Use config.yml file to allow for compatibility with # Use config.yml file to allow for compatibility with
@ -32,17 +32,23 @@ def count():
p1 = subprocess.Popen(cmd, stdout=subprocess.PIPE) p1 = subprocess.Popen(cmd, stdout=subprocess.PIPE)
p2 = subprocess.Popen(['wc', '-l'], stdin=p1.stdout, stdout=subprocess.PIPE) p2 = subprocess.Popen(['wc', '-l'], stdin=p1.stdout, stdout=subprocess.PIPE)
output = ((p2.communicate()[0]).decode()).rstrip('\n') output = ((p2.communicate()[0]).decode()).rstrip('\n')
digit = str(output)+" Updates" #digit = str(output)+" Updates"
global Nupd #global Nupd
Nupd.append(digit) #Nupd.append(digit)
global avail global avail
avail = Nupd[-1] #avail = Nupd[-1]
avail = str(output)+" Updates"
# Run system update # Run system update
def update(): def update():
cmd = [ term, opt, 'sudo', 'pacman', '-Syu'] cmd = [ term, opt, 'sudo', 'pacman', '-Syu']
subprocess.Popen(cmd) subprocess.Popen(cmd)
def newText(event):
count()
option1.setText(avail)
tray.setToolTip(avail)
# Initially populate available updates count # Initially populate available updates count
count() count()
@ -67,6 +73,7 @@ tray.setVisible(True)
menu = QMenu() menu = QMenu()
option1 = QAction(avail) option1 = QAction(avail)
option1.triggered.connect(update) option1.triggered.connect(update)
option1.triggered.connect(newText)
menu.addAction(option1) menu.addAction(option1)
# To quit the app # To quit the app
@ -78,13 +85,9 @@ menu.addAction(quit)
tray.setContextMenu(menu) tray.setContextMenu(menu)
# Update the labels for available updates count # Update the labels for available updates count
for i in Nupd: #for i in Nupd:
option1.triggered.connect(lambda bVal, menuItem=avail: addLabel(bVal,menuItem)) # option1.triggered.connect(lambda bVal, menuItem=avail: newText(bVal,menuItem))
option1.setText(avail) # option1.setText(avail)
tray.setToolTip(avail) # tray.setToolTip(avail)
def addLabel(self, menuItem):
print(menuItem)
app.exec_() app.exec_()