mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 22:52:42 +01:00
feat: foreground window (WIP)
This commit is contained in:
1 parent
2b10fcaaad
commit
c0708b9358
2 files changed
+10
-4
No files matched your search
@@ -65,4 +65,4 @@ CHANGELOG_PATH = "data/CHANGELOG.md"
|
|||||||
CSS_PATH = "data/app.css"
|
CSS_PATH = "data/app.css"
|
||||||
|
|
||||||
LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG")
|
LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG")
|
||||||
FOREGROUND_CMDS = ("wmctrlu", "xdotool")
|
FOREGROUND_CMDS = ("wmctrl", "xdotool")
|
||||||
+9
-3
@@ -43,8 +43,14 @@ def has_cmd(cmd: str) -> bool:
|
|||||||
|
|
||||||
def foreground(cmd: str, pid: int) -> None:
|
def foreground(cmd: str, pid: int) -> None:
|
||||||
if cmd == "wmctrl":
|
if cmd == "wmctrl":
|
||||||
# TODO: convert wid from hexadecimal
|
proc = subprocess.run(["wmctrl", "-ilp"], capture_output=True, text=True)
|
||||||
args = [cmd, "-a", "DZGUI"]
|
lines = proc.stdout.splitlines()
|
||||||
|
for line in lines:
|
||||||
|
els = line.split(" ")
|
||||||
|
if str(pid) in els:
|
||||||
|
wid = els[0]
|
||||||
|
break
|
||||||
|
subprocess.run(["wmctrl", "-ia", wid])
|
||||||
elif cmd == "xdotool":
|
elif cmd == "xdotool":
|
||||||
args = [cmd, "search", "--onlyvisible", "--name", "DZGUI", "windowactivate"]
|
args = [cmd, "search", "--onlyvisible", "--name", "DZGUI", "windowactivate"]
|
||||||
subprocess.Popen([*args])
|
subprocess.Popen([*args])
|
||||||
Reference in new issue
Block a user