-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxutil.py
More file actions
31 lines (22 loc) · 807 Bytes
/
xutil.py
File metadata and controls
31 lines (22 loc) · 807 Bytes
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
import subprocess
from PyQt5.QtCore import QRect
XDOTOOL = "xdotool"
def xdotool(*args):
return subprocess.check_output([XDOTOOL] + list(map(str, args))).decode().strip()
def get_window_name(window_id):
return xdotool("getwindowname", window_id)
def get_active_window():
return int(xdotool("getactivewindow"))
def window_move(window_id, x, y):
xdotool("windowmove", window_id, x, y)
def window_resize(window_id, w, h):
xdotool("windowsize", window_id, w, h)
def window_move_resize(window_id, rect):
window_move(window_id, rect.left(), rect.top())
window_resize(window_id, rect.width(), rect.height())
def window_raise(window_id):
xdotool("windowraise", window_id)
def get_display_rectangle():
size = xdotool("getdisplaygeometry")
(w, h) = map(int, size.split())
return QRect(0, 0, w, h)