update
This commit is contained in:
parent
25c6b8a8bf
commit
9955176321
|
@ -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"
|
||||
}
|
|
@ -1,8 +1,13 @@
|
|||
# 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!
|
||||
|
||||
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
|
||||
|
||||
Uses config file for options.
|
||||
|
@ -14,5 +19,3 @@ Includes:
|
|||
- .desktop file for autostarting
|
||||
- Tray and shortcut icons
|
||||
|
||||
TODO
|
||||
- look into adding option to view news or quick list
|
||||
|
|
|
@ -2,14 +2,18 @@
|
|||
|
||||
# Get needed modules
|
||||
import yaml
|
||||
import webbrowser
|
||||
import subprocess
|
||||
from os import path
|
||||
from time import sleep
|
||||
from functools import partial
|
||||
from PyQt5.QtCore import QTimer
|
||||
from PyQt5.QtGui import *
|
||||
from PyQt5.QtWidgets import *
|
||||
|
||||
# Available Updates count holder
|
||||
# Available Updates holders
|
||||
avail = ""
|
||||
outputList = ""
|
||||
|
||||
# Use config.yml file to allow for compatibility with
|
||||
# most terminal emulators possible & custom icon / timer duration
|
||||
|
@ -22,59 +26,85 @@ with open(path.expanduser("~/.config/systrayUpdater/systrayUpdater.yml")) as f:
|
|||
f.close()
|
||||
|
||||
# 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():
|
||||
cmd = ['checkupdates']
|
||||
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')
|
||||
global outputList
|
||||
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
|
||||
avail = str(output)+" Updates"
|
||||
|
||||
# Run system update
|
||||
def update():
|
||||
cmd = [ term, opt, 'sudo', 'pacman', '-Syu']
|
||||
subprocess.Popen(cmd)
|
||||
|
||||
# Sets new text for available updates
|
||||
def newText():
|
||||
count()
|
||||
option1.setText(avail)
|
||||
avail = str(outputCount)+" Updates"
|
||||
tray.setToolTip(avail)
|
||||
|
||||
# Initially populate available updates
|
||||
count()
|
||||
# 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():
|
||||
cmd = [ term, opt, 'sudo', 'pacman', '-Syu' ]
|
||||
subprocess.Popen(cmd)
|
||||
clear()
|
||||
|
||||
# Create an app surface
|
||||
app = QApplication([])
|
||||
app.setQuitOnLastWindowClosed(False)
|
||||
|
||||
# Adding an icon
|
||||
icon = QIcon(icn)
|
||||
# Set up timer to update count
|
||||
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()
|
||||
icon = QIcon(icn)
|
||||
tray.setIcon(icon)
|
||||
tray.setToolTip(avail)
|
||||
tray.setVisible(True)
|
||||
|
||||
# Creating the options
|
||||
menu = QMenu()
|
||||
option1 = QAction(avail)
|
||||
option1 = QAction("Run Update")
|
||||
option2 = QAction("Read the News")
|
||||
option1.triggered.connect(update)
|
||||
option1.triggered.connect(newText)
|
||||
option2.triggered.connect(news)
|
||||
menu.addAction(option1)
|
||||
|
||||
# Set up timer to update count
|
||||
timer = QTimer()
|
||||
timer.timeout.connect(newText)
|
||||
timer.start(wait)
|
||||
menu.addAction(option2)
|
||||
|
||||
# To quit the app
|
||||
quit = QAction("Quit")
|
||||
quit.triggered.connect(app.quit)
|
||||
menu.addAction(quit)
|
||||
|
||||
# Adding options to the System Tray
|
||||
# Place the app in the System Tray
|
||||
tray.setContextMenu(menu)
|
||||
|
||||
app.exec_()
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
# ----------------#
|
||||
|
||||
# Terminal emulator launch command and execute option
|
||||
terminal: terminator
|
||||
option: -x
|
||||
terminal: $TERM
|
||||
option: -e
|
||||
# timer value is set to minutes
|
||||
timer: 10
|
||||
# custom icons should follow Arch linux standards
|
||||
|
|
Loading…
Reference in New Issue