Mercurial > hg > config
comparison python/dmenu.py @ 297:618db1b1f34b
dmenu + emacs, baby
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sat, 11 May 2013 10:00:48 -0700 |
parents | 8f92aa15406f |
children |
comparison
equal
deleted
inserted
replaced
296:ee3c1b65d6d1 | 297:618db1b1f34b |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 import optparse | 3 import optparse |
4 import os | 4 import os |
5 import shlex | |
5 import subprocess | 6 import subprocess |
6 import sys | 7 import sys |
7 | 8 |
8 def choose_file(directory, dmenu='dmenu', | 9 def choose_file(directory, dmenu='dmenu', |
9 args=('-i', '-nb', 'black', '-nf', 'white', | 10 args=('-i', '-nb', 'black', '-nf', 'white', |
36 help="call this proram with the result") | 37 help="call this proram with the result") |
37 options, args = parser.parse_args(args) | 38 options, args = parser.parse_args(args) |
38 chosen = choose_file(options.directory) | 39 chosen = choose_file(options.directory) |
39 if chosen: | 40 if chosen: |
40 if options.executable: | 41 if options.executable: |
41 pass | 42 # TODO: extract this pattern (see ims journal.txt) |
42 print chosen | 43 command = shlex.split(options.executable) |
44 executable = command[0] | |
45 command.append(chosen) | |
46 os.execlp(executable, *command) | |
47 else: | |
48 print chosen | |
43 else: | 49 else: |
44 sys.exit(1) | 50 sys.exit(1) |
45 | 51 |
46 if __name__ == '__main__': | 52 if __name__ == '__main__': |
47 main() | 53 main() |