Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持 Linux 自动更新状态 #10

Merged
merged 1 commit into from
Jan 22, 2025
Merged

支持 Linux 自动更新状态 #10

merged 1 commit into from
Jan 22, 2025

Conversation

RikkaNaa
Copy link
Contributor

从 Windows 的实现小改过来的
只支持 KDE,依赖 kdotool
image

@wyf9
Copy link
Owner

wyf9 commented Jan 22, 2025

可以说明一下注意事项之类的吗
会加到 client/README.md 里

@wyf9 wyf9 merged commit ab7248f into wyf9:main Jan 22, 2025
@RikkaNaa
Copy link
Contributor Author

暂时只支持KDE,且需要系统已经安装了 kdotool
不支持检测是否在使用(因为一锁屏kdotool就获取不了信息了
可以用变量计时的方法实现检测使用,参考,比较简单粗暴(

@wyf9
Copy link
Owner

wyf9 commented Jan 22, 2025

因为一锁屏kdotool就获取不了信息了

请问一下获取不了信息有怎样的表现
是直接报错(返回值不为 0),还是返回空字符串,亦或是其他的?

@RikkaNaa
Copy link
Contributor Author

直接报错

X11 下锁屏再唤醒之后 kdotool 会报错 Error: No such object path '/Scripting/Script0'
应该是锁屏之后就没法再调用 KWin了

@wyf9
Copy link
Owner

wyf9 commented Jan 22, 2025

这时子进程的返回代码应该不是 0?
或许可以检测一下
image

@RikkaNaa
Copy link
Contributor Author

image
只给了 code 1

@wyf9
Copy link
Owner

wyf9 commented Jan 22, 2025

只给了 code 1

足够了
给一下检测代码?
我先把现在的 dev-2025-1-2 合并过来,然后加上 code 检测来判断是否锁屏,锁屏就视为未在使用

@RikkaNaa
Copy link
Contributor Author

RikkaNaa commented Jan 22, 2025

window = subprocess.run(["kdotool", "getactivewindow", "getwindowname"], capture_output=True, text=True)
print(f"ExitCode:", {window.returncode})
print(f"Window Name:", {window.stdout})

image
可以使用 "capture_output=True, text=True" 让它直接输出窗口名,就不用开两次 subprocess 了,不过输出末尾会带一个 \n

@RikkaNaa
Copy link
Contributor Author

window_info = subprocess.run(["kdotool", "getactivewindow", "getwindowname"], capture_output=True, text=True)
window_name = window_info.stdout.replace("\n", "")
return_code = window_info.returncode

这样应该没问题了,能一步获取到窗口名和返回代码

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants