-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
63 lines (45 loc) · 1.48 KB
/
main.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
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
import pyglet
import sys
import os
APPLICATION_PATH = os.path.dirname(__file__) if getattr(sys, 'frozen', True) else os.path.dirname(sys.executable)
pyglet.resource.path = [os.path.join(APPLICATION_PATH, 'resources')]
def run_app():
display = pyglet.canvas.get_display()
screens = display.get_screens()
windows = []
for screen in screens:
windows.append(pyglet.window.Window(fullscreen=True, screen=screen, caption='4Focus'))
for window in windows:
add_hotkeys(window, windows)
window.set_icon(pyglet.resource.image('sad-cat.png'))
pyglet.app.run()
def add_hotkeys(window, windows):
@window.event
def on_key_press(symbol, modifiers):
if symbol == pyglet.window.key.ESCAPE:
pyglet.app.exit()
if symbol == pyglet.window.key.M:
for win in windows:
win.minimize()
if (
symbol == pyglet.window.key.SPACE or
symbol == pyglet.window.key.UP
):
for win in windows:
win.maximize()
if (
symbol == pyglet.window.key.DOWN and
not modifiers & pyglet.window.key.MOD_CTRL
):
window.minimize()
if (
modifiers & pyglet.window.key.MOD_CTRL and
symbol == pyglet.window.key.DOWN
):
for win in windows:
if win != window:
win.minimize()
def main():
run_app()
if __name__ == "__main__":
main()