Hello Yann, I've got a new version for the kdesktop_lock.py script. I changed it that way, that the scripts remembers the status message prior to switching status to away. Please integrate it into the wiki on [1]. Will attachments to a wiki page be overwritten automatically? The tutorial for it might come on the weekend.
[1] - http://trac.gajim.org/wiki/GajimCommunity Greetings, Nico.
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (C) 2007, Nico Gulden # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. """ This script is a wrapper for kdedesktop_lock to enable auto-status for gajim. It switches the status to away on session locking and restores the previous status for each account. """ import sys import commands def whereis(command): """Return the correct path to command using the whereis command.""" return commands.getoutput('whereis %s' % command).split(' ')[1] KDEDESKTOP_LOCK_BIN = '/usr/kde/current/bin/kdesktop_lock.kde' GAJIM_REMOTE_BIN = whereis('gajim-remote') AWAY_STATUS_MSG = 'Abwesend - Away' def get_status(): """Find out all accounts in gajim and save the current status. Output: dictionary with account:status mapping.""" status = {} accounts = commands.getoutput("%s list_accounts" % GAJIM_REMOTE_BIN).split() for a in accounts: acc_props = {} acc_props['status'] = commands.getoutput("%s get_status %s" % (GAJIM_REMOTE_BIN, a)) acc_props['msg'] = commands.getoutput("%s get_status_message %s" % (GAJIM_REMOTE_BIN, a)) status[a] = acc_props return status def exec_change_status(status_to, msg, a): """Execute the change_status command of gajim-remote.""" (exitstatus, outtext) = commands.getstatusoutput("%s change_status %s '%s' %s" % (GAJIM_REMOTE_BIN, status_to, msg, a)) def change_status(status, status_from, status_to): """Change the status for all accounts matching the status given with status_from and change them to the status give in status_to.""" for a in status.keys(): # switch only online accounts to away if (status_to == 'away' and status[a]['status'] == 'online'): exec_change_status(status_to, AWAY_STATUS_MSG, a) # switch only accounts back to away that have been online before elif (status_to == 'online' and status[a]['status'] == 'online'): exec_change_status(status_to, status[a]['msg'], a) if __name__ == '__main__': if KDEDESKTOP_LOCK_BIN is None: print """You need to configure this script. Find the binary kdedesktop_lock and move it to kdesktop_lock.kde. Copy %s to /usr/local/bin and make a symlink from the kdesktop_lock path to /usr/local/bin/%s and name it kdesktop_lock. """ % (sys.argv[0],sys.argv[0]) sys.exit(1) options = " ".join(sys.argv[1:]) status = get_status() change_status(status, status_from='online', status_to='away') commands.getoutput("%s %s" % (KDEDESKTOP_LOCK_BIN, options)) change_status(status, status_from='away', status_to='online')
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
_______________________________________________ Gajim-devel mailing list Gajim-devel@gajim.org https://lists.gajim.org/cgi-bin/listinfo/gajim-devel