| 14 # This program is distributed in the hope that it will be useful, |
14 # This program is distributed in the hope that it will be useful, |
| 15 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 # GNU General Public License for more details. |
17 # GNU General Public License for more details. |
| 18 # |
18 # |
| 19 # You should have received a copy of the GNU General Public License |
19 # You should have received a copy of the GNU General Public License along with |
| 20 # along with this program; if not, write to the Free Software |
20 # this program; if not, write to the Free Software Foundation, Inc., |
| 21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 22 # |
22 # |
| 23 |
23 |
| 24 from __future__ import absolute_import, division, print_function |
24 from __future__ import absolute_import, division, print_function |
| 25 |
25 |
| |
26 import os |
| 26 import sys |
27 import sys |
| |
28 |
| 27 import dbus |
29 import dbus |
| 28 import os |
30 |
| 29 |
31 |
| 30 if len(sys.argv) == 1: |
32 if len(sys.argv) == 1: |
| 31 print("Usage:", sys.argv[0], "<purple-client> [arguments]") |
33 print("Usage:", sys.argv[0], "<purple-client> [arguments]") |
| 32 print("\nExample:\n ", sys.argv[0], "pidgin -d -c /my/home") |
34 print("\nExample:\n ", sys.argv[0], "pidgin -d -c /my/home") |
| 33 sys.exit(1) |
35 sys.exit(1) |
| 34 |
36 |
| 35 home = os.path.expanduser('~/.purple/') |
37 home = os.path.expanduser('~/.purple/') |
| 36 for arg in range(1, len(sys.argv[1:])): |
38 for arg in range(1, len(sys.argv[1:])): |
| 37 if sys.argv[arg] == "-c": |
39 if sys.argv[arg] == "-c": |
| 38 home = os.path.expanduser(sys.argv[arg + 1]) |
40 home = os.path.expanduser(sys.argv[arg + 1]) |
| 39 break |
41 break |
| 40 |
42 |
| 41 bus = dbus.SessionBus() |
43 bus = dbus.SessionBus() |
| 42 |
44 |
| 43 try: |
45 try: |
| 44 obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") |
46 obj = bus.get_object("im.pidgin.purple.PurpleService", |
| 45 purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") |
47 "/im/pidgin/purple/PurpleObject") |
| 46 userdir = purple.PurpleUserDir() |
48 purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") |
| 47 if not os.path.isabs(userdir): |
49 userdir = purple.PurpleUserDir() |
| 48 userdir = os.path.join(purple.PurpleHomeDir(), userdir) |
50 if not os.path.isabs(userdir): |
| 49 if home == userdir: |
51 userdir = os.path.join(purple.PurpleHomeDir(), userdir) |
| 50 print("Already running.") |
52 if home == userdir: |
| 51 purple.PurpleBlistShow() |
53 print("Already running.") |
| 52 else: |
54 purple.PurpleBlistShow() |
| 53 print("Starting client from a different home directory.") |
55 else: |
| 54 raise |
56 print("Starting client from a different home directory.") |
| |
57 raise |
| 55 except: |
58 except: |
| 56 os.execlp(sys.argv[1], " ".join(sys.argv[2:])) |
59 os.execlp(sys.argv[1], " ".join(sys.argv[2:])) |