-
Notifications
You must be signed in to change notification settings - Fork 0
/
indicator-proxy-control
executable file
·48 lines (35 loc) · 1.31 KB
/
indicator-proxy-control
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
#!/usr/bin/env python
# ubuntu fast proxy control
import commands
from gi.repository import GObject as gobject
from gi.repository import Gtk as gtk
from gi.repository import AppIndicator3 as appindicator
indicator = None
def set_level(level):
system("gsettings set org.gnome.system.proxy mode " + level)
def get_level():
status, output = commands.getstatusoutput("gsettings get org.gnome.system.proxy mode")
return output.replace("'","")
def menu_item_callback(w,level):
if not w.get_active():
return
set_level(level)
indicator.set_label(get_level(), "")
if __name__ == "__main__":
indicator = appindicator.Indicator.new("proxycontrol",
"proxycontrol",
appindicator.IndicatorCategory.HARDWARE)
indicator.set_icon_theme_path("/usr/share/icons/gnome")
indicator.set_icon('tray-online')
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
indicator.set_label(get_level(), "")
menu = gtk.Menu()
menu_group = []
for level in [ "none", "manual", "auto" ]:
menu_item = gtk.RadioMenuItem.new_with_label(menu_group, level)
menu_group = menu_item.get_group()
menu.append(menu_item)
menu_item.connect("toggled", menu_item_callback, level)
menu_item.show()
indicator.set_menu(menu)
gtk.main()