aquarius | if I have a path to a .desktop file, what's the best way of launching that program from a python app? Do I have to open it and parse it for the Exec key myself? | 00:10 |
---|---|---|
ajmitch | aquarius: you could possibly use python-xdg to parse the .desktop file, I don't know if it'd be worth it though | 00:11 |
jo-erlend | well... "Parse"? :) for line in open("/path/to/desktop.file"): if line.startswith("Exec="): subprocess.check_call([line[5:]]) | 00:13 |
aquarius | heh. | 00:13 |
aquarius | not if, for example, the exec line specifies a parameter | 00:13 |
aquarius | or if it's broken over two lines | 00:13 |
ajmitch | which would need the % arguments stripped off :) | 00:13 |
aquarius | etc, etc, etc :) | 00:13 |
aquarius | this is why I was hoping someone else had already done the hard work ;) | 00:14 |
jo-erlend | aquarius, add shell=True and it'll work with parameters. But what do you mean broken over two lines? Is that legal in .desktop-files? | 00:15 |
aquarius | jo-erlend, yeah, I am pretty sure there's a line-break thing | 00:15 |
aquarius | am looking at pyxdg | 00:15 |
jo-erlend | oh. I didn't know that. | 00:15 |
aquarius | gio.AppInfo is the way to launch it, I think | 00:15 |
ajmitch | python-xdg has a DesktopEntry class with a getExec() method, probably the closest you'll get :) | 00:15 |
aquarius | but I still need to load the individual details with pyxdg to pass them to gio. Bah | 00:16 |
aquarius | wish gio.AppInfo had a load_desktop_file method. | 00:16 |
ajmitch | it used to be that you could just call 'xdg-open blah.desktop' & it'd run it | 00:16 |
jo-erlend | btw... I've forgotten how to get outputs of commands as lines when running subprocess. Anyone? | 00:24 |
aquarius | jo-erlend, http://docs.python.org/library/subprocess.html#replacing-bin-sh-shell-backquote | 01:01 |
dpm | morning | 08:20 |
jo-erlend | morning. :) | 08:39 |
jml | hi | 09:32 |
=== johnoxton_ is now known as johnoxton | ||
=== johnoxton_ is now known as johnoxton |
Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!