Amarok 1.4 script: knowing who's running you

137 views Asked by At

I've been using Amarok 1.4 for a long time, switching to Bogdan Butnaru's packages when KDE stopped supporting it, and I'm now giving Pana a try.

I realised that a script I wrote in Python for Amarok 1.4 will not immediately run without changes under Pana. But instead of converting my script, which basically comes down to replacing "amarok" with "pana" in the paths I use, I'd rather make it compatible with both the original Amarok 1.4 and Pana, so that I could be able to distribute only a single version of that script (and possibly modifying it later if other forks become popular).

So, is there a (Python(ic)) way for my script, running from within the player, to find out which program launched it?

1

There are 1 answers

1
aukaost On BEST ANSWER
import os

pid = os.getppid()
with open("/proc/%s/cmdline" % pid) as f:
    print f.readline()

Assuming you are running Linux. Not sure if you need getppid() or getpid() here. Not so pythonic maybe.