forked from d4nj1/TLPUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tlpui.py
executable file
·36 lines (29 loc) · 993 Bytes
/
tlpui.py
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
#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
from os import path
from css import get_css_provider
from file import read_tlp_file_config
from mainui import create_main_box, close_window
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(),
get_css_provider(),
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
defaultconfigpath = '/etc/default/tlp'
window = Gtk.Window()
window.set_title('TLP-UI')
window.set_default_size(900, 600)
if path.exists(defaultconfigpath):
tlpconfig = read_tlp_file_config(defaultconfigpath)
window.add(create_main_box(window, defaultconfigpath, tlpconfig))
else:
noconfiglabel = Gtk.Label("No config file found at " + defaultconfigpath)
noconfigbox = Gtk.Box()
noconfigbox.pack_start(noconfiglabel, True, True, 0)
window.add(noconfigbox)
window.connect('delete-event', Gtk.main_quit)
window.connect('key-press-event', close_window)
window.show_all()
Gtk.main()