This repository has been archived by the owner on Jul 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
control-center
executable file
·130 lines (111 loc) · 4.8 KB
/
control-center
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/python3
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gio, Gdk
from src.widgets.connection_box import ConnectionsBox
from src.widgets.disturb_box import DisturbBox
from src.widgets.keyboard_brightness import KbdBrightnessBox
from src.widgets.wireless_display import WirelessDisplayBox
from src.widgets.display_level import DisplayLevelBox
from src.widgets.sound_box import SoundLevelBox
class Application(Gtk.Application):
def __init__(self, *args, **kwargs):
super().__init__(
*args,
application_id="com.github.lioaslan.control-center",
flags=Gio.ApplicationFlags.FLAGS_NONE,
**kwargs
)
self.window = None
def do_activate(self):
if not self.window:
# Initial window
self.window = Gtk.ApplicationWindow(
application=self,
title="Control Center",
default_height=300,
default_width=260,
window_position=Gtk.WindowPosition.MOUSE
)
self.window.set_resizable(False)
self.window.set_skip_pager_hint(True)
self.window.set_skip_taskbar_hint(True)
self.window.set_decorated(False)
self.window.set_visual(self.window.get_screen().get_rgba_visual())
# Move the window some pixels below
position = self.window.get_position()
self.window.move(position.root_x, position.root_y + 32)
# CSS Styles
css_file = "./src/application.css"
css_provider = Gtk.CssProvider()
try:
css_provider.load_from_path(css_file)
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(), css_provider,
Gtk.STYLE_PROVIDER_PRIORITY_USER
)
except Exception:
print("APP [ERROR LOADING CSS STYLES]")
# Main Box and its organization
main_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
header_box = Gtk.Box(
orientation=Gtk.Orientation.HORIZONTAL, spacing=0
)
extras_box = Gtk.Box(
orientation=Gtk.Orientation.VERTICAL, spacing=0
)
extras_bottom_box = Gtk.Box(
orientation=Gtk.Orientation.HORIZONTAL, spacing=0
)
display_box = Gtk.Box(
orientation=Gtk.Orientation.HORIZONTAL, spacing=0
)
sound_box = Gtk.Box(
orientation=Gtk.Orientation.HORIZONTAL, spacing=0
)
# Custom Things
connection_box = ConnectionsBox()
diturb_box = DisturbBox()
kbdbrightness_box = KbdBrightnessBox()
wirelessdisplay_box = WirelessDisplayBox()
display_level_box = DisplayLevelBox()
sound_level_box = SoundLevelBox()
fix_separator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL)
fix_separator.set_opacity(0.0)
extras_separator = Gtk.Separator(
orientation=Gtk.Orientation.VERTICAL
)
extras_separator.set_opacity(0.0)
extras_bottom_separator = Gtk.Separator(
orientation=Gtk.Orientation.VERTICAL
)
extras_bottom_separator.set_opacity(0.0)
# All boxes are packaged
header_box.pack_start(connection_box, False, True, 10)
extras_bottom_box.pack_start(kbdbrightness_box, False, True, 0)
extras_bottom_box.pack_start(
extras_bottom_separator, False, True, 4
)
extras_bottom_box.pack_start(wirelessdisplay_box, False, True, 0)
extras_box.pack_start(diturb_box, False, True, 0)
extras_box.pack_start(extras_separator, False, True, 4)
extras_box.pack_start(extras_bottom_box, False, True, 0)
header_box.pack_start(extras_box, False, True, 0)
header_box.pack_start(fix_separator, False, True, 4)
display_box.pack_start(display_level_box, False, True, 10)
sound_box.pack_start(sound_level_box, False, True, 10)
main_box.pack_start(header_box, False, True, 10)
main_box.pack_start(display_box, False, True, 0)
main_box.pack_start(sound_box, False, True, 10)
self.window.add(main_box)
# At the end... show all!
self.window.get_style_context().add_class("mainwindow")
self.window.show_all()
self.window.connect("focus-out-event", self._on_focus_out_event)
self.window.present()
def _on_focus_out_event(self, window, event):
window.destroy()
if __name__ == "__main__":
app = Application()
app.run(sys.argv)