登录后如何自动将状态设置为“可用”?


Answers:


14

为了使默认的Ubuntu IM应用程序Empathy在您登录时自动启动,以下说明来自OMG Ubuntu

移情需要一点点脚步才能继续登录。

您会以为在Empathy的首选项中选中“启动时自动连接”框与启动系统登录有关就可以了。并非如此,在这种情况下,启动是指Empathy的启动,而不是您计算机的启动。

通过进入系统>首选项>启动应用程序>新项目,然后在相关字段中输入以下信息,我们可以使其开始登录:

名称:移情

命令:同情-h


@fluteflute:感谢您提供有意义的答案... :-)
Kushal 2011年

2
我仍然认为这与直觉相反。我是唯一的一个吗?
levesque 2013年

5

当屏幕锁定或激活了屏幕保护程序时,此脚本将自动将状态设置为“不可用”,并且在关闭屏幕保护程序时将其恢复为可用状态(在线)!

#!/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)

3
一个不错的解决方案,但是大多数新手在遇到如此简单的需求而遇到这样的脚本时,都会放弃使用Linux。
库沙尔(Kushal)2012年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.