This commit is contained in:
Eric Lay 2023-12-07 18:57:10 -06:00
parent 25c6b8a8bf
commit 9955176321
4 changed files with 95 additions and 33 deletions

29
PKGBUILD Normal file
View File

@ -0,0 +1,29 @@
# Maintainer: Eric Lay <ericlaytm@gmail.com>
pkgname=systrayupdater
pkgver=0.1
pkgrel=1
pkgdesc="PyQt5 system tray applet to notify of available updates"
arch=('x86_64')
url="https://github.com/ericlay/$pkgname"
license=('GPL3')
depends=('python'
'python-pyqt5'
'python-yaml'
'python-jaraco.functools'
'pacman')
makedepends=('git')
optdepends=()
source=("git+https://github.com/ericlay/fuzzy-pkg-finder.git")
md5sums=('SKIP')
pkgver(){
cd "$pkgname"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
package() {
cd "$srcdir/$pkgname"
install -Dm755 systrayUpdater -t "$pkgdir/usr/bin"
install -Dm666 systrayUpdater.desktop -t "$pkgdir/usr/share/applications"
install -Dm755 ./*.png systrayupdater.yml -t "$pkgdir/$HOME/.config/$pkgname"
}

View File

@ -1,8 +1,13 @@
# systrayUpdater # systrayUpdater
Simple Qt based system tray icon to notify of available updates and then update on click PyQt5 system tray applet to notify of available updates.
For Arch (based) systems only! For Arch (based) systems only!
Right click to access menu actions:
-Run update
-Read the News
-Display list of packages with updates available (click to search arch website for highlighted package)
To install and use: Place files in appropriate locations and run appropriate commands when doing so To install and use: Place files in appropriate locations and run appropriate commands when doing so
Uses config file for options. Uses config file for options.
@ -14,5 +19,3 @@ Includes:
- .desktop file for autostarting - .desktop file for autostarting
- Tray and shortcut icons - Tray and shortcut icons
TODO
- look into adding option to view news or quick list

View File

@ -2,14 +2,18 @@
# Get needed modules # Get needed modules
import yaml import yaml
import webbrowser
import subprocess import subprocess
from os import path from os import path
from time import sleep
from functools import partial
from PyQt5.QtCore import QTimer from PyQt5.QtCore import QTimer
from PyQt5.QtGui import * from PyQt5.QtGui import *
from PyQt5.QtWidgets import * from PyQt5.QtWidgets import *
# Available Updates count holder # Available Updates holders
avail = "" avail = ""
outputList = ""
# Use config.yml file to allow for compatibility with # Use config.yml file to allow for compatibility with
# most terminal emulators possible & custom icon / timer duration # most terminal emulators possible & custom icon / timer duration
@ -22,59 +26,85 @@ with open(path.expanduser("~/.config/systrayUpdater/systrayUpdater.yml")) as f:
f.close() f.close()
# Run checkupdates command # Run checkupdates command
# Populates the available updates count holder # Populates the available updates and count
# Sets the list and count in proper spots
def count(): def count():
cmd = ['checkupdates'] cmd = ['checkupdates']
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) global outputList
output = ((p2.communicate()[0]).decode()).rstrip('\n') outputList = ((p1.communicate()[0]).decode()).rstrip('\n')
outputCount = len(outputList.splitlines())
if outputCount == 0:
tray.setVisible(False)
else:
tray.setVisible(True)
for i in outputList.splitlines():
menu.addAction(i, partial(infos, i))
global avail global avail
avail = str(output)+" Updates" avail = str(outputCount)+" Updates"
tray.setToolTip(avail)
# Run system update # Read the News
# Get pkg info
def news():
url = 'https://archlinux.org/news/'
webbrowser.open_new_tab(url)
# Get pkg info
def infos(pkgString):
pkg = pkgString.split(' ')
url = 'https://archlinux.org/packages/?q='+ pkg[0]
webbrowser.open_new_tab(url)
# Clear old update list when new list available
def clear():
menu.clear()
menu.addAction(option1)
menu.addAction(option2)
menu.addAction(quit)
# Run system updatehttps://archlinux.org/packages/?q='+ pkg[0]
def update(): def update():
cmd = [ term, opt, 'sudo', 'pacman', '-Syu' ] cmd = [ term, opt, 'sudo', 'pacman', '-Syu' ]
subprocess.Popen(cmd) subprocess.Popen(cmd)
clear()
# Sets new text for available updates # Create an app surface
def newText():
count()
option1.setText(avail)
tray.setToolTip(avail)
# Initially populate available updates
count()
app = QApplication([]) app = QApplication([])
app.setQuitOnLastWindowClosed(False) app.setQuitOnLastWindowClosed(False)
# Adding an icon # Set up timer to update count
icon = QIcon(icn) clearTimer = QTimer()
clearTimer.timeout.connect(clear)
updateTimer = QTimer()
updateTimer.timeout.connect(count)
updateTimer.singleShot(1,count) # Initially populate available updates
clearTimer.start(wait)
sleep(1)
updateTimer.start(wait)
# Adding item on the menu bar # Adding items to the menu
tray = QSystemTrayIcon() tray = QSystemTrayIcon()
icon = QIcon(icn)
tray.setIcon(icon) tray.setIcon(icon)
tray.setToolTip(avail) tray.setToolTip(avail)
tray.setVisible(True) tray.setVisible(True)
# Creating the options # Creating the options
menu = QMenu() menu = QMenu()
option1 = QAction(avail) option1 = QAction("Run Update")
option2 = QAction("Read the News")
option1.triggered.connect(update) option1.triggered.connect(update)
option1.triggered.connect(newText) option2.triggered.connect(news)
menu.addAction(option1) menu.addAction(option1)
menu.addAction(option2)
# Set up timer to update count
timer = QTimer()
timer.timeout.connect(newText)
timer.start(wait)
# To quit the app # To quit the app
quit = QAction("Quit") quit = QAction("Quit")
quit.triggered.connect(app.quit) quit.triggered.connect(app.quit)
menu.addAction(quit) menu.addAction(quit)
# Adding options to the System Tray # Place the app in the System Tray
tray.setContextMenu(menu) tray.setContextMenu(menu)
app.exec_() app.exec_()

View File

@ -3,8 +3,8 @@
# ----------------# # ----------------#
# Terminal emulator launch command and execute option # Terminal emulator launch command and execute option
terminal: terminator terminal: $TERM
option: -x option: -e
# timer value is set to minutes # timer value is set to minutes
timer: 10 timer: 10
# custom icons should follow Arch linux standards # custom icons should follow Arch linux standards