/
ActivateWindows
executable file
·91 lines (71 loc) · 2.25 KB
/
ActivateWindows
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
#!/bin/python3
import cairo
import gi
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning) # genius fix
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gtk, Gdk
root = Gdk.get_default_root_window()
screen = root.get_screen()
def get_screen_size(display):
mon_geoms = [
display.get_monitor(i).get_geometry()
for i in range(display.get_n_monitors())
]
x0 = min(r.x for r in mon_geoms)
y0 = min(r.y for r in mon_geoms)
x1 = max(r.x + r.width for r in mon_geoms)
y1 = max(r.y + r.height for r in mon_geoms)
return x1 - x0, y1 - y0
class ActivateWindows (Gtk.Window):
def __init__(self):
super().__init__(type=Gtk.WindowType.POPUP)
try: # in case it gets removed
self.set_wmclass("ActivateWindows", "ActivateWindows");
except:
pass;
self.set_app_paintable(True);
screen = self.get_screen();
visual = screen.get_rgba_visual();
self.set_visual(visual);
self.show_all();
width, height = get_screen_size(Gdk.Display.get_default())
SELF_WIDTH = 350
SELF_HEIGHT = 100
self.resize(SELF_WIDTH, 100);
self.move(width - (SELF_WIDTH + 15), height - (SELF_HEIGHT + 15));
self.set_decorated(False);
self.set_skip_taskbar_hint(True)
self.set_skip_pager_hint(True)
self.set_keep_above(True)
self.set_type_hint(Gdk.WindowTypeHint.NOTIFICATION)
self.set_accept_focus(False)
self.set_focus_on_map(False)
self.input_shape_combine_region(cairo.Region())
self.connect('draw', self._on_draw)
def _on_draw(self, _wid, ctx):
ctx.save()
ctx.set_source_rgba(166, 166, 166, 0.6);
ctx.select_font_face("Segoe UI",
cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL);
ctx.set_font_size(26);
ctx.move_to(0, 50 - 26 / 2);
ctx.show_text("Activate Windows");
ctx.set_font_size(18);
ctx.move_to(0, 50 + 26 / 2);
ctx.show_text("Go to PC settings to activate Windows.");
ctx.restore()
def main():
win = ActivateWindows();
win.connect("destroy", Gtk.main_quit);
win.set_title("ActivateWindows")
win.show_all()
Gtk.main()
if __name__=="__main__":
try:
main()
except KeyboardInterrupt:
exit(0)
else:
print("This program is not meant to be imported to other Python modules. Please run ActivateWindows as a standalone script!")