summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrx862023-07-19 22:12:49 +0800
committerBrx862023-07-19 22:12:49 +0800
commit9a27e9bb134efbbbcba0bf0a52422307bfdc7d8a (patch)
tree444f36a2e7bc7c476ce626ae3b8ab570c90136c7
downloadaur-9a27e9bb134efbbbcba0bf0a52422307bfdc7d8a.tar.gz
First commit
-rw-r--r--.SRCINFO15
-rw-r--r--PKGBUILD17
-rwxr-xr-xxstop22
3 files changed, 54 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..b63fb40e875d
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,15 @@
+pkgbase = xstop
+ pkgdesc = Just click to pause/resume x11 windows, like xkill.
+ pkgver = 0.1.0
+ pkgrel = 1
+ url = https://github.com/Brx86/Xstop
+ arch = x86_64
+ license = GPL3
+ depends = python
+ depends = xorg-xprop
+ depends = procps-ng
+ provides = xstop
+ source = xstop
+ sha256sums = 4c7ac97485fde73e6b5b4096bcae5f2b9da24e73bb20dcf71a0ab28d878ee76a
+
+pkgname = xstop
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..814e94f51cb6
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,17 @@
+# Maintainer: Ayatale <ayatale@qq.com>
+
+pkgname=xstop
+pkgver=0.1.0
+pkgrel=1
+pkgdesc="Just click to pause/resume x11 windows, like xkill."
+url="https://github.com/Brx86/Xstop"
+arch=("x86_64")
+license=("GPL3")
+depends=("python" "xorg-xprop" "procps-ng")
+provides=("xstop")
+source=("xstop")
+sha256sums=('4c7ac97485fde73e6b5b4096bcae5f2b9da24e73bb20dcf71a0ab28d878ee76a')
+
+package() {
+ install -Dm755 "xstop" -t "$pkgdir/usr/bin"
+}
diff --git a/xstop b/xstop
new file mode 100755
index 000000000000..c8210847a13b
--- /dev/null
+++ b/xstop
@@ -0,0 +1,22 @@
+#!/usr/bin/python3
+import os, re
+
+# 正则匹配窗口的 PID 和 CLASS 名
+cmd = os.popen("xprop -notype _NET_WM_PID WM_CLASS")
+info = re.findall(r"= (\d+)\n.+\"([\w\-]+)", cmd.read())
+if info:
+ pid, name = info[0]
+ # 获取该父进程ID的所有直接子进程的 PID
+ cmd = os.popen(f"pgrep -P {pid}")
+ child_pids = cmd.read().replace("\n", " ")
+ # 获取该进程当前状态( T 为已暂停)
+ cmd = os.popen(f"ps -p {pid} -o state=")
+ state = cmd.read().strip()
+ if state == "T":
+ # 如果已暂停,则发送恢复信号
+ os.popen(f"kill -CONT {pid} {child_pids}")
+ print(f"Resume: {pid} {name}")
+ else:
+ # 如果正在运行,则发送暂停信号
+ os.popen(f"kill -STOP {pid} {child_pids}")
+ print(f"Stop: {pid} {name}")