1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
#!/usr/bin/env python
#
# senapwm.py -- Example PLWM window manager "configuration"
#
# Copyright (C) 1999,2000 Peter Liljenberg <petli@ctrl-c.liu.se>
#
# 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 2 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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import sys
import os
###SETUP PATH
sys.path[1:1] = [os.path.join(sys.path[0], '/home/morgan/hack/plwm/')]
###END SETUP PATH
from plxlib import plxlib, X
from plwm import wmanager, focus, keys, \
deltamove, \
border, color, font, cycle, views, \
modewinctl, modestatus
from plwm.moveresize import MoveResizeKeys
# from textwindow import TextWindow
delta = deltamove.DeltaMove()
class MyClient(wmanager.Client,
focus.FocusClient,
border.BorderClient,
focus.JumpstartClient,
modestatus.ModeFocusedTitle):
no_border_clients = ['XModeWindow']
start_iconified_clients = ['WMManager']
move_focus_ignore_clients = no_border_clients
default_pointer_pos = {'Emacs': (-1, 0),
'XTerm': (-1, 0)}
class MyScreen(wmanager.Screen,
color.Color,
modewinctl.ModeClientControl,
modestatus.ModeStatus,
modestatus.ModeMoveResize,
views.XMW_ViewHandler,
keys.KeyGrabber):
view_always_visible_clients = ['XModeWindow']
class WMConfig:
def __wm_init__(self):
BasicKeys(self, self.dispatch)
self.dispatch.add_handler('cmdevent', cmdhandler)
class PLWM(wmanager.WindowManager,
focus.SloppyFocus,
font.Font,
WMConfig):
client_class = MyClient
screen_class = MyScreen
def cmdhandler(evt):
print 'Exit:', evt.exitstatus(), 'Signal:', evt.termsig()
class BasicKeys(keys.KeyHandler):
def F1(self, event):
self.wm.current_screen.view_prev()
def F2(self, event):
self.wm.current_screen.view_next()
def F3(self, event):
self.wm.move_focus(focus.MOVE_LEFT)
def F4(self, event):
self.wm.move_focus(focus.MOVE_RIGHT)
def KP_End(self, event):
self.wm.current_screen.view_prev()
def KP_Down(self, event):
self.wm.current_screen.view_next()
def KP_Insert(self, event):
wmanager.debug('keys', 'New view')
self.wm.current_screen.view_new()
def KP_Divide(self, event): #up
self.wm.move_focus(focus.MOVE_UP)
def KP_Delete(self, event): #down
self.wm.move_focus(focus.MOVE_DOWN)
def KP_Next(self, event): #left
self.wm.move_focus(focus.MOVE_LEFT)
def KP_Add(self, event): #right
self.wm.move_focus(focus.MOVE_RIGHT)
def S_KP_Divide(self, event): #up
d = delta.get(event.time)
self.wm.display.WarpPointer(0, -d)
def S_KP_Delete(self, event): #down
d = delta.get(event.time)
self.wm.display.WarpPointer(0, d)
def S_KP_Next(self, event): #left
d = delta.get(event.time)
self.wm.display.WarpPointer(-d, 0)
def S_KP_Add(self, event): #right
d = delta.get(event.time)
self.wm.display.WarpPointer(d, 0)
def KP_Subtract(self, event):
MyMoveResizeKeys(self, event)
def Pause(self, event):
self.wm.system('xlock -mode blank')
def C_M_Escape(self, event):
raise 'PLWMEscape', 'Escaping window manager'
def C_KP_Delete(self, event):
if self.wm.focus_client:
self.wm.focus_client.delete(1)
def C_S_KP_Delete(self, event):
if self.wm.focus_client:
self.wm.focus_client.destroy()
def M_section(self, event):
self.wm.system('xterm')
def M_F9(self, event):
self.wm.system('xterm -title Shell -sb -sl 1024 -fn fixed -bg grey70 -fg black')
def M_F10(self, event):
self.wm.system('emacs -bg grey70 -fg black')
def M_F11(self, event):
self.wm.system('netscape&')
#
# Use the keymap for moving and resizing windows.
#
class MyMoveResizeKeys(MoveResizeKeys):
KP_Next = MoveResizeKeys._move_w
KP_Add = MoveResizeKeys._move_e
KP_Divide = MoveResizeKeys._move_n
KP_Delete = MoveResizeKeys._move_s
C_KP_Next = MoveResizeKeys._enlarge_w
C_KP_Add = MoveResizeKeys._enlarge_e
C_KP_Divide = MoveResizeKeys._enlarge_n
C_KP_Delete = MoveResizeKeys._enlarge_s
M_KP_Next = MoveResizeKeys._shrink_e
M_KP_Add = MoveResizeKeys._shrink_w
M_KP_Divide = MoveResizeKeys._shrink_s
M_KP_Delete = MoveResizeKeys._shrink_n
KP_Subtract = MoveResizeKeys._moveresize_end
S_KP_Subtract = MoveResizeKeys._moveresize_end
C_KP_Subtract = MoveResizeKeys._moveresize_end
class CycleUMKeys(keys.KeyGrabKeyboard):
propagate_keys = 0
timeout = 10
def __init__(self, wm, dispatch, time):
keys.KeyGrabKeyboard.__init__(self, wm, dispatch, time)
self.cy = cycle.CycleUnmapped(wm.current_screen, 1)
def Tab(self, event):
self.cy.next()
C_Tab = Tab
def S_Tab(self, event):
self.cy.previous()
def Return(self, event):
wmanager.debug('keys', 'Escaping CycleMapped mode')
self._cleanup()
self.cy.end()
def Escape(self, event):
wmanager.debug('keys', 'Aborting CycleMapped mode')
self._cleanup()
self.cy.abort()
_timeout = Escape
if __name__ == '__main__':
sync = 0
while len(sys.argv) > 1:
if sys.argv[1] == '-d':
wmanager.debug = wmanager.do_debug
elif sys.argv[1] == '-s':
sync = 1
del sys.argv[1]
try:
p = PLWM()
except wmanager.error_no_unmanaged_screens:
sys.stderr.write(sys.argv[0] + ': Another window manager already running?\n')
sys.exit(1)
if sync:
p.display.Synchronize(1)
p.brave_loop()
|