Permalink
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (49 sloc) 1.96 KB
#!/usr/bin/env python
#
# ginvoke: a programmable launcher for GTK+
# Copyright (C) 2011 Thomas Lee
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import os
from ginvoke.actions import wildcard
from ginvoke.engine import BadCommandException
settings.show_at_startup = True
settings.browser = "gnome-www-browser"
TERMINAL = "gnome-terminal"
def terminal(context, args):
args = context.args
if len(args) == 1:
run(context, (TERMINAL, "--working-directory=%s" % args[0]))
elif len(args) == 0:
run(context, (TERMINAL,))
else:
raise BadCommandException("terminal command takes a maximum of one argument")
def custom_wildcard(context, args):
command = context.command
if os.path.isdir(command):
run(context, (TERMINAL, "--working-directory=%s" % command))
else:
return wildcard(context, args)
commands.reset()
commands.add("goto", url, "${args[0]}")
commands.add("google", url, "http://google.com/#q=${u(' '.join(args))}")
commands.add("gmail", url, "http://gmail.com")
commands.add("github", url, "http://github.com/${u(' '.join(args))}")
commands.add("terminal", terminal)
commands.add("editconfig", run, "gvim", os.path.join(os.getenv("HOME"), ".ginvokerc"))
commands.add("shutdown", run, "gnome-session-quit", "--power-off", "--no-prompt")
commands.add("reconfigure", reconfigure)
commands.add("exit", quit)
commands.setwildcard(custom_wildcard)