1 -- xinerama_switcher.lua
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.
10 -- The following keybindings may be useful:
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(_)"),
19 -- Based on go_desk_or_desk lua by Rene van Bevern <rvb@pro-linux.de>, 2005
21 -- This script is (c) copyright 2005 by martin f. krafft <madduck@madduck.net>
22 -- and released under the terms of the Artistic Licence.
24 -- Version 2005.08.14.1515
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. :)
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
39 return ioncore.goto_prev_screen()
40 --return ioncore.goto_next_screen()
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
48 --return ioncore.goto_prev_screen()
49 return ioncore.goto_next_screen()
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
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
64 function xinerama_switcher(workspace,direction)
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()
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()
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()
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()
91 -- helper functions for easier keybindings (see top of the file)
93 function xinerama_switcher_left(reg)
94 xinerama_switcher(reg, "left")
97 function xinerama_switcher_right(reg)
98 xinerama_switcher(reg, "right")
101 function xinerama_switcher_up(reg)
102 xinerama_switcher(reg, "up")
105 function xinerama_switcher_down(reg)
106 xinerama_switcher(reg, "down")