yur*_*dal 1 gnome instant-messaging
我正在使用 oa 脚本,当屏幕被锁定或 gnome-screensaver 被激活时,它会自动将 Gnome Shell 集成的聊天/消息传递状态更改为“不可用”。
任何人都知道将 gnome 消息传递系统状态设置为“可用”或“不可用”的终端命令是什么?
我已经尝试过 pidgin 和 empathy 的插件,但似乎 gnome 消息状态不依赖于这些。
让它工作!简单的python脚本:
#!/usr/bin/python
import os
import time
import dbus
session_bus = dbus.SessionBus()
from gi.repository import TelepathyGLib as Tp
from gi.repository import GObject
loop = GObject.MainLoop()
am = Tp.AccountManager.dup()
am.prepare_async(None, lambda *args: loop.quit(), None)
loop.run()
screensaver_started = 0
running = 0
while 1:
active = 0
out = ""
pid = 0
if screensaver_started == 0:
# Don't do anything if the screensaver isn't running
s = os.popen("pidof gnome-screensaver")
spid = s.read()
s.close()
if len(spid) > 0:
screensaver_started = 1
else:
h = os.popen("gnome-screensaver-command -q", "r")
out = h.read()
active = out.find("inactive")
h.close()
if active < 0 and running == 0:
am.set_all_requested_presences(Tp.ConnectionPresenceType.OFFLINE, 'Offline', "")
running = 1
elif active > 0 and running == 1:
am.set_all_requested_presences(Tp.ConnectionPresenceType.AVAILABLE, 'available', "")
running = 0
time.sleep(3)
Run Code Online (Sandbox Code Playgroud)
此脚本会在屏幕锁定或屏幕保护程序激活时自动将状态设置为“不可用”,并在屏幕保护程序关闭时将其恢复为可用(在线)!
| 归档时间: |
|
| 查看次数: |
573 次 |
| 最近记录: |