-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtraytext
executable file
·51 lines (44 loc) · 1.42 KB
/
traytext
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
#Potaje6
#Script para ponerme un texto en la barra de tareas y matar el proceso que se le pase por parametro al salir
import signal
import gi
import sys
import os
gi.require_version('Gtk', '3.0')
gi.require_version('AppIndicator3', '0.1')
from gi.repository import Gtk, AppIndicator3
SERVER=sys.argv[1]
PROC=sys.argv[2]
class Indicator():
def __init__(self):
self.app = 'test123'
iconpath = "/home/dmolinao/scripts/parametros/LoL.ico"
self.indicator = AppIndicator3.Indicator.new(
self.app, iconpath,
AppIndicator3.IndicatorCategory.OTHER)
self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
self.indicator.set_menu(self.create_menu())
self.indicator.set_label(SERVER, self.app)
def create_menu(self):
menu = Gtk.Menu()
# menu item 1
# item_1 = Gtk.MenuItem('Menu item')
# # item_about.connect('activate', self.about)
# menu.append(item_1)
# separator
menu_sep = Gtk.SeparatorMenuItem()
menu.append(menu_sep)
# quit
item_quit = Gtk.MenuItem('Quit')
item_quit.connect('activate', self.stop)
menu.append(item_quit)
menu.show_all()
return menu
def stop(self, source):
cmd = "sudo kill "+PROC
os.system(cmd)
Gtk.main_quit()
Indicator()
signal.signal(signal.SIGINT, signal.SIG_DFL)
Gtk.main()