2017-09-15 40 views
0

如何在命令行中設置/更改Pidgin即時通訊工具中的狀態(如Available/Busy/Away)?我需要這個來確保當我鎖定我的屏幕時,我的狀態變爲'離開'。我安裝了'awayonlock'插件,但它似乎不適用於MATE桌面環境。如何從命令行設置Pidgin狀態?

+0

喜歡的東西: '$ pidgin-client --state「dont_disturb」--text-state「在B55會議室從11:00到12:00」' –

+0

@ Goran.it:我沒有任何程序叫'pidgin-client'在我的Debian 8機器上。我擁有的是'pidgin'和'pidgin.orig'。我用這兩種方法嘗試了你的命令,但它似乎不起作用。 –

+0

也許你可以試試'紫色遙控器「setstatus?status = away&message = AFK」'..我不確定哪些程序在ubuntu上安裝pidgin ..從我讀過紫色遙控器應該做的伎倆,你可以在這裏閱讀更多關於它的信息:http://www.commandlinefu.com/commands/view/4554/change-pidgin-status –

回答

0

我能夠創建一個簡單的Python腳本來做到這一點:

set_im_status.py

#!/usr/local/bin/python 

import sys 
import dbus, gobject 
from dbus.mainloop.glib import DBusGMainLoop 

dbus_loop = DBusGMainLoop() 

bus = dbus.SessionBus(mainloop=dbus_loop) 
dbus_obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") 
purple = dbus.Interface(dbus_obj, "im.pidgin.purple.PurpleInterface") 

status = sys.argv[1] 

# Available 
if status == "a": 
    status_id = dbus.String(u'available') 

# Busy 
elif status == "b": 
    status_id = dbus.String(u'unavailable') 

# Away 
elif status == "w":  
    status_id = dbus.String(u'away') 

# Invisible 
elif status == "i": 
    status_id = dbus.String(u'invisible') 

# Offline 
elif status == "f": 
    status_id = dbus.String(u'offline') 

else: 
    status_id = dbus.String(u'available') 

status_type = purple.PurplePrimitiveGetTypeFromId(status_id) 
saved = purple.PurpleSavedstatusNew("", status_type) 
purple.PurpleSavedstatusActivate(saved) 

我們將狀態設置爲 '忙碌',運行:% python set_im_status.py b