]> git.donarmstrong.com Git - x_base.git/blob - .ion3/xinerama_switcher.lua
* fixup linking to current xsession-errors file
[x_base.git] / .ion3 / xinerama_switcher.lua
1 -- xinerama_switcher.lua
2 -- 
3 -- Goes to the frame in the specified direction. If there is no frame in the
4 -- given direction (the user is trying to move off the edge of the screen), it
5 -- switches workspace or screen. I assume that left/right switch between
6 -- screens, since xinerama displays are usually next to each other. Up/down,
7 -- on the other hand switch between workspaces. For me, the next workspace is
8 -- down as if I was reading a webpage.
9 --
10 -- The following keybindings may be useful:
11 --
12 --defbindings("WIonWS", {
13 --    kpress(MOD1.."Up", "xinerama_switcher_up(_)"),
14 --    kpress(MOD1.."Down", "xinerama_switcher_down(_)"),
15 --    kpress(MOD1.."Right", "xinerama_switcher_right(_)"),
16 --    kpress(MOD1.."Left", "xinerama_switcher_left(_)"),
17 --})
18 --
19 -- Based on go_desk_or_desk lua by Rene van Bevern <rvb@pro-linux.de>, 2005
20 --
21 -- This script is (c) copyright 2005 by martin f. krafft <madduck@madduck.net>
22 -- and released under the terms of the Artistic Licence.
23 --
24 -- Version 2005.08.14.1515
25 -- 
26 -- TODO: prevent switching screens when there is none on that side. E.g.
27 -- moving off the left edge of the left screen should either do nothing or
28 -- wrap to the right side of the right screen. This likely needs
29 -- a configuration file which would also solve the problem about assigning
30 -- left/right to next/prev according to xinerama configuration.
31 -- When solving this, don't just solve it for dual-head. :)
32 --
33
34 function goto_right_screen()
35   -- do whatever it takes to switch to the screen on the right
36   -- this may be either the previous or next screen, depending on how you set
37   -- up xinerama.
38   
39   return ioncore.goto_prev_screen()
40   --return ioncore.goto_next_screen()
41 end
42
43 function goto_left_screen()
44   -- do whatever it takes to switch to the screen on the right
45   -- this may be either the previous or next screen, depending on how you set
46   -- up xinerama.
47
48   --return ioncore.goto_prev_screen()
49   return ioncore.goto_next_screen()
50 end
51
52 function goto_workspace_down(screen)
53   -- do whatever it takes to switch to the workspace below
54   -- in my book, that's the next workspace
55   screen:switch_next()
56 end
57
58 function goto_workspace_up(screen)
59   -- do whatever it takes to switch to the workspace below
60   -- in my book, that's the previous workspace
61   screen:switch_prev()
62 end
63   
64 function xinerama_switcher(workspace,direction)
65
66     if direction == "left" then
67       -- we move to the screen on the left
68       local screen = goto_left_screen()
69       screen:current():farthest("right"):goto()
70     
71     elseif direction == "right" then
72       -- we move to the screen on the right
73       local screen = goto_right_screen()
74       screen:current():farthest("left"):goto()
75     
76     elseif direction == "up" then
77       -- we switch to the workspace above this one
78       local screen = workspace:screen_of()
79       goto_workspace_up(screen)
80       screen:current():farthest("down"):goto()
81     
82     elseif direction == "down" then
83       -- we switch to the workspace below this one
84       local screen = workspace:screen_of()
85       goto_workspace_down(screen)
86       screen:current():farthest("up"):goto()
87       
88     end
89 end
90
91 -- helper functions for easier keybindings (see top of the file)
92
93 function xinerama_switcher_left(reg)
94    xinerama_switcher(reg, "left")
95 end
96
97 function xinerama_switcher_right(reg)
98    xinerama_switcher(reg, "right")
99 end
100
101 function xinerama_switcher_up(reg)
102    xinerama_switcher(reg, "up")
103 end
104
105 function xinerama_switcher_down(reg)
106    xinerama_switcher(reg, "down")
107 end