how to open a file or folder using autokey

511 views
Skip to first unread message

cedardoc

unread,
Mar 9, 2010, 7:38:13 PM3/9/10
to autokey-users
I've been looking for a way to do this for a while now and can't
figure it out. I do intent to learn python, but in the mean time (I'm
a slow learner), would someone have pity on me and post an example of
a script that opens a file and one that opens a folder that I could
assign to a keyboard shortcut please?

Thanks,

Dave

Luke Faraone

unread,
Mar 9, 2010, 7:42:08 PM3/9/10
to autoke...@googlegroups.com
If you're using GNOME, the line you want is:
import subprocess; subprocess.Popen(['/usr/bin/nautilus', 'PATH_TO_DIRECTORY_GOES_HERE']);

On KDE, I think you should use:
import subprocess; subprocess.Popen(['/usr/bin/konqueror', 'PATH_TO_DIRECTORY_GOES_HERE']);

--
Luke Faraone
http://luke.faraone.cc

cedardoc

unread,
Mar 9, 2010, 8:11:26 PM3/9/10
to autokey-users
wow that was quick! Thanks, I'll try that out.

On Mar 9, 5:42 pm, Luke Faraone <l...@faraone.cc> wrote:

Chris Dekter

unread,
Mar 9, 2010, 8:19:14 PM3/9/10
to autoke...@googlegroups.com
A simpler more generic solution would be:

import subprocess
subprocess.call(['xdg-open', 'PATH_TO_FILE_OR_DIR'])

This will open the file or directory in the correct program based on
your current desktop environment.

cedardoc

unread,
Mar 10, 2010, 10:56:44 AM3/10/10
to autokey-users
Thanks to both of you - it works!!

On Mar 9, 6:19 pm, Chris Dekter <cdek...@gmail.com> wrote:
> A simpler more generic solution would be:
>
> import subprocess
> subprocess.call(['xdg-open', 'PATH_TO_FILE_OR_DIR'])
>
> This will open the file or directory in the correct program based on
> your current desktop environment.
>

> On 10 March 2010 11:42, Luke Faraone <l...@faraone.cc> wrote:

Reply all
Reply to author
Forward
0 new messages