>
> #! /usr/bin/python3
>
> import sys
> import dbus
> from pydbus import SessionBus
>
> def usage():
> text = '''
> ./presence.py busy FIRSTNAME ACCOUNT
> ./presence.py avail FIRSTNAME ACCOUNT
>
> FIRSTNAME: first name.
> ACCOUNT: the alias of the account presence to change
>
> Example:
>
> ./presence.py busy claudio resource5
> --> sets resource5 to busy with msg: "claudio using resource5"
> ./presence.py avail claudio resource5
> --> claudio frees up resource5, status set to avail.
> '''
> print(text)
> sys.exit(1)
>
> #sys.argv = ["./presence.py", "busy", "claudio", "resource5"]
>
> if len(sys.argv) != 4:
> print(len(sys.argv))
> usage()
>
> if (sys.argv[1]) == "busy":
> arg_status = "Do Not Disturb"
> elif (sys.argv[1]) == "avail":
> arg_status = "Available"
> else:
> usage()
>
> arg_firstname = sys.argv[2]
> arg_account = sys.argv[3]
>
> print("presence: connecting to PurpleService")
>
> bus = SessionBus()
> try:
> p = bus.get("im.pidgin.purple.PurpleService",
> "/im/pidgin/purple/PurpleObject")
> except:
> sys.exit("presence: failed to connect to PurpleService")
>
> accounts = p.PurpleAccountsGetAll()
>
> if len(accounts) == 0:
> sys.exit("presence: no account found.")
>
> for account in accounts:
> alias = p.PurpleAccountGetAlias(account)
> print(alias + " is accountid " + str(account))
> if (alias != arg_account):
> print("presence: skipping account " + alias)
> continue
>
> print("presence: found account " + alias)
>
> presence = p.PurpleAccountGetPresence(account)
> status = p.PurplePresenceGetActiveStatus(presence)
> status_type = p.PurpleStatusGetType(status)
> status_type_name = p.PurpleStatusTypeGetName(status_type)
>
> if (status_type_name == arg_status):
> sys.exit("presence: account is already " + arg_status)
>
> status_type_list = p.PurpleAccountGetStatusTypes(account)
> status_id = "";
>
> for status_type in status_type_list:
> status_type_name = p.PurpleStatusTypeGetName(status_type)
> print("status_type_name in status_type_list = " + status_type_name)
> if (status_type_name == arg_status):
> status_id = p.PurpleStatusTypeGetId(status_type)
here I am missing a
break;
(just noticed). Does not fix the problem though, my script seems to run
consistently,
but the client (finch) does not show any changes in my status.
_______________________________________________
[email protected] mailing list
Want to unsubscribe? Use this link:
https://pidgin.im/cgi-bin/mailman/listinfo/support