#!/usr/bin/python
import os, signal, gi, subprocess, time, getpass
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk as gtk
gi.require_version('AppIndicator3', '0.1')
from gi.repository import AppIndicator3 as appindicator
USER = getpass.getuser()
APPINDICATOR_ID = 'myappindicator_pacman'
checking = os.environ["checking"]
if str(checking) == "0":
num = os.environ["num"]
def main():
indicator = appindicator.Indicator.new(APPINDICATOR_ID, '', appindicator.IndicatorCategory.SYSTEM_SERVICES)
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
indicator.set_menu(build_menu())
indicator.set_icon('start-here-symbolic')
indicator.set_label(" {}".format(num), APPINDICATOR_ID)
gtk.main()
def build_menu():
menu = gtk.Menu()
item = gtk.MenuItem(label='Pacchetti aggiornabili {}'.format(num))
submenu = gtk.Menu()
item.set_submenu(submenu)
menu.append(item)
packages = ''
for i in os.environ["content"].split(' '):
packages = packages+i+'\n'
items = gtk.MenuItem(packages.rstrip())
items.set_sensitive(False)
item.get_submenu().append(items)
menu.append(gtk.SeparatorMenuItem())
menu.append(gtk.SeparatorMenuItem())
aur = gtk.MenuItem("Verifica ora")
aur.connect('activate', pacman_check)
menu.append(aur)
update = gtk.MenuItem("Aggiorna ora")
update.connect('activate', pacman_update)
menu.append(update)
item_quit = gtk.MenuItem('Esci')
item_quit.connect('activate', quit)
item_quit.show()
menu.append(item_quit)
#end of items
menu.show_all()
return menu
def pacman_update(_):
os.system("gnome-terminal --geometry 85x15 --hide-menubar --title=\"Gestore aggiornamenti PACMAN\" -e \'sh -c \"sudo pacman -Syu ; echo Fatto. Premi invio per continuare.. ; read ; echo controllo_aggiornamenti.. ; nohup pacman_update >/dev/null 2>&1\"\'")
def pacman_check(_):
output = os.system("ps aux | grep \"[p]acman_update\" > /dev/null 2>&1")
if output == 256:
output1 = os.system("ps aux | grep \"[p]acman_update\" > /dev/null 2>&1")
if output1 == 256:
os.system("pacman_update &")
#end of function
def quit(_):
gtk.main_quit()
if str(checking) == "1":
def main():
indicator = appindicator.Indicator.new(APPINDICATOR_ID, '', appindicator.IndicatorCategory.SYSTEM_SERVICES)
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
indicator.set_menu(gtk.Menu())
indicator.set_icon('start-here-symbolic')
indicator.set_label(" PACMAN", APPINDICATOR_ID)
while True:
for i in range(0, 11):
icon = '/home/'+USER+'/Immagini/GIF/loader/' + str(i) + '.png'
while gtk.events_pending(): gtk.main_iteration()
indicator.set_icon(icon)
time.sleep(0.15)
gtk.main()
if __name__ == "__main__":
main()