3 # Makes sure only one purple instance is running
5 # Purple is the legal property of its developers, whose names are too numerous
6 # to list here. Please refer to the COPYRIGHT file distributed with this
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
28 if len(sys
.argv
) == 1:
29 print "Usage:", sys
.argv
[0], """<purple-client> [arguments]
32 """, sys
.argv
[0], "pidgin -d -c /my/home"
35 home
= os
.path
.expanduser('~/.purple/')
36 for arg
in range(1, len(sys
.argv
[1:])):
37 if sys
.argv
[arg
] == "-c":
38 home
= os
.path
.expanduser(sys
.argv
[arg
+ 1])
41 bus
= dbus
.SessionBus()
44 obj
= bus
.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject")
45 purple
= dbus
.Interface(obj
, "im.pidgin.purple.PurpleInterface")
46 userdir
= purple
.PurpleUserDir()
47 if not os
.path
.isabs(userdir
):
48 userdir
= os
.path
.join(purple
.PurpleHomeDir(), userdir
)
50 print "Already running."
51 purple
.PurpleBlistShow()
53 print "Starting client from a different home directory."
56 os
.execlp(sys
.argv
[1], " ".join(sys
.argv
[2:]))