# $Id: home_userconfig.py,v 1.31 2004/02/03 21:53:39 hyriand Exp $
# Kahakai configuration file
from macros import *
# mouseFocus() Focus follows mouse (both in & out the window)
#
# sloppyFocus() Like mouseFocus() but leaving window doesn't
# unfocus
#
# clickFocus() Window/Mac/Gnome/KDE-like standard behavior
#
# wheelStacking() Use wheel on window title to raise/lower
# windows. Default setting is to lower on
# wheel up & vice versa. Call with
# wheelStacking("raise") to reverse.
#
# viewportSurf() Lets you "surf" around your viewports with
# the mouse. You can specify modifiers, so
# that it will only flip edges when you're
# pressing those modifiers. For example,
# viewportSurf(Alt), or Ctrl-Alt or Ctrl+Alt
#
# viewportKnock() Lets you "knock" on screen edges with an
# input event. It can be any event, but
# mouse clicking is the only on that really
# makes much sense. If called with no action,
# it will by default flip when you click on the
# screen edge with Button1. To change this,
# you need to pass a full input event as the
# argument. For example:
# viewportKnocK(ButtonPress(Ctrl, 'Button1'))
# also see $PREFIX/share/kahakai/scripts/macros.py for explanations of other
# macros not explained above.
init() # we always need this
###############################################################################
##### modifier masks to ignore ################################################
ignoreModifiers( modifiers = [CapsLock, NumLock] )
###############################################################################
##### window behavior #########################################################
sloppyFocus()
#clickFocus( passthru=True )
#mouseFocus()
focusNewWindows()
smartWindowPlacement()
clickToRaise()
#mouseRaise() #raise windows on hover
# wheel up lowers, wheel down raises windows, on titlebar.
# alt+wheel on the whole window also lowers/raises
wheelStacking( raiseButton=5, lowerButton=4, modifier=Alt )
windowSnapping( pixels=15 ) # argument is snapping distance, in pixels
###############################################################################
##### desktop switching #######################################################
# ctrl+alt+<number> to go to <number> desktop
desktopKeys( modifier=Ctrl+Alt-AltGr, keys="%d" )
# alt+F<number> to go to <number> desktop
#desktopKeys( modifier=-Ctrl+Alt-AltGr, keys="F%d" )
# ctrl+alt+[h,j,k,l] to go to desktops 1,2,3,4
#desktopKeys( modifier=Ctrl+Alt-AltGr, keys="h,j,k,l" )
desktopWheelScroll( modifier=None )
###############################################################################
##### viewport navigation #####################################################
viewportSurf( modifier=-Ctrl+Alt, wrap=False )
#viewportKnock( button=1, modifier=-Ctrl+Alt, wrap=False )
###############################################################################
##### menu stuff ##############################################################
mouseMenuNavigation( closeOnExec=True, moveWithModifier=Alt, closeButtons=[3] )
keyboardMenuNavigation( closeOnExec=True )
rootMenuClick( buttons=[2,3] )
rootMenuUnmap( buttons=[1] )
windowMenuClick( buttons=[3] )
windowMenuUnmap( buttons=[1,2] )
#windowMenuKeyPress( modifier=Super, key="space" )
###############################################################################
##### window stuff ############################################################
##### alt+mousebutton window actions
moveWindowWithModifier( modifier=Alt, button=1, opaque=True )
resizeWindowWithModifier( modifier=Alt, button=3, opaque=False )
lowerWindowWithModifier( modifier=Alt, button=2 )
##### other window actions
moveByTitlebar( buttons=[1], opaque=True )
# don't uncomment both of these!
doubleClickTitlebarShade( buttons=[1] )
#doubleClickTitlebarMaximize( buttons=[1] )
resizeWithGrips( buttons=[1], opaque=False )
##### button actions (you almost definitely want these :)
windowButtons()
###############################################################################
##### misc ####################################################################
# default action is "TaskSwitcher", pass it something else if you want.
# ("PreviousTask" is also nice)
altTab( action="TaskSwitcher" )
###############################################################################
# you are free to delete MyConfiguration and the stuff after it, but if you do,
# uncomment this finish().
#finish()
class MyConfiguration:
"""
This class contains various methods that return lists of bindings, which
are installed (made active) by running install() on an instance of this
class.
NOTE that this should be used for fairly "personal" input bindings.
Commonly used key/mouse actions should have predefined functions above, if
not, please recommend them to us so we can consider creating a built-in
function.
A python list is in brackets ('[' and ']'), with each item delimited by a
comma. Each item should be a tuple with the first item being an event
object, and the second an action. Tuples are fairly similar to lists with
the exceptions that they cannot be changed in place (which is fairly
irrelevant for what you will usually be doing in this file), and that they
are surrounded by parentheses, not brackets.
Valid events are:
Keyboard Events:
KeyPress
KeyRelease
Mouse Events:
ButtonPress
ButtonRelease
DoubleClick
Misc:
EnterNotify - when the pointer enters a window
LeaveNotify - when the pointer leaves a window
MapRequest - when a window asks to appear onscreen
Valid Actions are:
[ imagine list of actions here .. for now, look in src/Window.hh, or
http://kahakai.sourceforge.net/wiki/index.php/WindowActions for a
partial list. ]
Say we want Ctrl + Alt + X to bring up an xterm. To execute shell commands,
you use a string containing the command surrounded by curly braces. To run
xterm, it would be "{xterm}".
(KeyPress(Ctrl+Alt, "x"), "{xterm}")
Modifiers can be added or subtracted from each other. If you wanted to say
"control but not control+alt", you would use Ctrl-Alt. If you have used
Waimea, it is similar to the use of "!" for negation of modifiers.
For mouse bindings, use "Button1", "Button2", etc. E.g.:
(DoubleClick(Ctrl+Alt, "Button1"), "{xterm}")
EnterNotify, LeaveNotify, and MapRequest take no arguments. For example,
if you wanted a window to raise on EnterNotify:
(EnterNotify(), "Raise")
Now obviously, some actions only apply to certain things. Trying to use
Raise in your root window bindings is not going to work, trying to use
menu actions on a window won't work, etc.
Also rememeber - this is plain old python, so you can do much,
much more than just return lists. If you felt like being extreme
for fun, you could implement your own keybinding file format,
parse and load it here, and return the bindings according to it.
You can access the screen size via screen().height and
screen().width. You can do len(screen().desktop_list) to get the
number of desktops, etc. print dir(whatever) is your friend. :)
If a function returns no bindings, it should return an empty iterable, e.g.
an empty list, "[]". You can also delete the function altogether, but keep
in mind that you might want it in the future.
You may also find it simpler to just use functions for registering your
custom bindings, instead of this class. In that case, you can use the
following functions:
windowActions()
screenActions()
menuActions()
edgeActions()
allWindowActions()
allMenuActions()
globalActions()
See actions.py for their usage.
"""
def newWindow(self, window, winClass, winName, event, action):
"""
Called when a new window is created (mapped)
This method does *not* return a list of actions.
example:
if winName == 'gaim':
window.JoinAllDesktops()
NOTE: you can use window.name, to match against the window title
To see all methods/attributes of every window opened (printed on
stdout), you could do:
print dir(window)
"""
# .. do something interesting here .. (and remove pass)
#print ("A new window appeared! Its titlebar says '%s', and its "
# "classhint name and class are '%s' and '%s'."
# % (window.name, winName, winClass))
def globalKeyBindings(self):
"""
Place to define bindings (mostly keyboard) that apply to all areas of
the screen. Adding shortcuts for commonly used programs is a good use.
Examples:
return [(KeyPress('XF86AudioPrev'), '{xmms -r}'),
(KeyPress(Ctrl, 'Escape'), ('RemapFocused', 'rootmenu'))]
"""
return []
def defaultAllWindows(self):
"""
Place to define bindings that apply to all parts of a window.
Example for defining keys to close/shade windows:
return [ (KeyPress(Super, 'q'), 'Close'),
(KeyPress(Super, 's'), 'Shade') ]
"""
return []
def defaultAllDecor(self):
"""
Bindings for window decorations, which include every part of the window
except the main middle part where the actual program is.
"""
return []
def defaultAllTitle(self):
"""Bindings for window titlebar."""
return []
def defaultAllMenus(self):
"""
Any bindings which you would want to apply to every part of the menu.
"""
return []
def root(self):
"""
Define bindings for the root window, AKA desktop.
For example, to make double click open an xterm, you could return:
(DoubleClick('Button1'), '{xterm}')
"""
return []
# screen edges
def northEdge(self):
return []
def southEdge(self):
return []
def eastEdge(self):
return []
def westEdge(self):
return []
# window parts
def window_frame(self):
"""The whole window, regardless of focus"""
return []
def window_focused(self):
return []
def window_unfocused(self):
return []
def window_title(self):
return []
def window_label(self):
return []
def window_handle(self):
return []
def window_leftgrip(self):
return []
def window_rightgrip(self):
return []
def window_button_shade(self):
return []
def window_button_minimize(self):
return []
def window_button_close(self):
return []
def window_button_maximize(self):
return []
def window_button_vmaximize(self):
return []
def window_button_hmaximize(self):
return []
# menu parts
def menu_title(self):
return []
def menu_item(self):
return []
def menu_checkbox(self):
return []
def menu_sub(self):
return []
if __name__ == '__main__':
print "Loading configuration from userconfig.py"
install(MyConfiguration())
print "Done."
|