Name Modified Size InfoDownloads / Week
Makefile 2012-01-17 141 Bytes
movemouse 2012-01-17 6.9 kB
movemouse.c 2012-01-17 6.2 kB
README 2012-01-17 11.1 kB
Totals: 4 Items   24.4 kB 0
OVERVIEW: movemouse is a utility that permits you to save up to 10 positions of the mouse pointer on however many different screens are attached to a computer and to jump to any of those positions via a keyboard command or hotkey. 'movemouse -[h|V]': Show a [help screen | version number] and exit. 'movemouse -s2' : Save the current mouse pointer position as '#2'. 'movemouse -vg3' : Move the pointer to the location previously saved as '#3' and show verbose output about the move. 'movemouse -cg4' : Move the pointer to the location previously saved as '#2' and simulate a click of the left mouse button. Each position is saved in a file '.pointer-[number]' in your home directory where 'number' is the digit identifying that 'save'. PURPOSE: I use Linux Mint Debian Edition with the Gnome 2.30.2 GUI. I have dual monitors set up as two separate X screens, each with it's own panels and desktops. This is *not* Xinerama and *not* twinview. I don't like Xinerama because it works poorly with my monitors due to the fact that they have different resolutions. Also I like to be able to change desktops on one monitor without changing anything on the other which can't be done if you are using Xinerama (where both screens change at the same time since they are part of the same logical desktop). Your experience may differ, but here, with Gnome/metacity the only way to change focus from one screen to the other is to use the mouse to move the pointer. (There are keyboard shortcuts to move between desktops/windows on any given screen, but there is no shortcut that I know of to move from one screen to the other.) When I have both screens loaded with GUI applications, my hand tends to spend a lot of time on the mouse anyway, so the above isn't much of an issue -- when I want to change screens I just use the mouse to move the pointer as normal. However I often have both screens devoted to xterms (konsole, terminal, etc) -- normally two xterms on each screen. When that is the case, I find that reaching for the mouse just to move focus from one xterm to the next is quite a bother. movemouse is designed to provide a pure keyboard solution to that problem. INSTALLATION AND USAGE: After untaring the tarball or just grabbing idividual files, you can type 'make' to build the binary from the included C source code & Makefile, or you can just use the included binary. Copy it to somewhere on your path and that's that. Rename the binary as desired, setup aliases and hotkeys as explained below if you like. Although movemouse can be used on a single screen, it is really meant for use with dual (or more) monitors. I'm not going to explain fully how to configure dual monitors, there's lots of documentation on the web and it depends on your hardware anyway. (You probably already have dual monitors if you are even interested in this utility in the first place.) Very briefly, you'll normally end up running either 'X -configure' or the proprietary software than comes with your video card(s). This will create the file '/etc/X11/xorg.conf' which contains the needed information about your screens/monitors. For what it's worth, here's mine: Section "ServerLayout" Identifier "Layout" Screen 0 "Screen-0" 0 0 Screen "Screen-1" RightOf "Screen-0" EndSection #Screen 0: =========================================== Section "Monitor" Identifier "Monitor-0" Option "DPMS" "true" EndSection Section "Device" Identifier "Device-0" Driver "fglrx" BusID "PCI:2:0:0" EndSection Section "Screen" Identifier "Screen-0" Device "Device-0" Monitor "Monitor-0" DefaultDepth 24 SubSection "Display" Viewport 0 0 Depth 24 EndSubSection EndSection #Screen 1: =========================================== Section "Monitor" Identifier "Monitor-1" Option "DPMS" "true" EndSection Section "Device" Identifier "Device-1" Driver "fglrx" BusID "PCI:2:0:0" Screen 1 EndSection Section "Screen" Identifier "Screen-1" Device "Device-1" Monitor "Monitor-1" DefaultDepth 24 SubSection "Display" Viewport 0 0 Depth 24 EndSubSection EndSection *************************************************** Because moving the mouse using the keyboard should be quicker and more convenient than using the mouse (why would you bother otherwise?), it is expected that various movemouse commands will be bound to various hotkeys as you prefer. You can do something like this (zsh bindings and aliases shown, but bash will be very similar): alias mm1='movemouse -s1' alias mm2='movemouse -s2' ... bindkey -s "\e1" 'movemouse -cg1\C-m' #Alt+1 bindkey -s "\e2" 'movemouse -cg2\C-m' #Alt+2 ... Or you can bind the keys under your GUI, which is probably better becuase it lets you invoke movemouse even when you don't have a command line. In this version of Gnome, at an xterm: 'gconf-editor > apps > metacity > global-keybindings > value' to select a hotkey, and 'gconf-editor > apps > metacity > keybinding_commands > value' to enter the command to bind to it. This page explains it very well: http://www.howtogeek.com/howto/ubuntu/assign-custom-shortcut-keys-on-ubuntu-linux/ If you use the GUI method, movemouse commands execute 'silently', if you use the 'bindkey' method, they are echoed to the command line. There are times when moving the pointer is not enough to properly raise focus at the moved-to location. This is the case when a new window has opened overtop of the window that was there when the pointer location was saved (as mentioned above) or when the pointer is in a text entry box, and probably in other situations as well. Simulating the left mouse button click with the 'c' switch should always cure the focus problem, but beware, if the pointer is on an HTML link, or some other 'active' location, then that action will be executed, just as if you did a real left click. Insidentaly, for the true mouse hater this feature of movemouse might make it of some use even with a single screen system since it makes it possible to 'drive' an HTML page without needing to use the mouse to move between buttons. One example of a situation where you probably don't want the 'autoclick' is when moving back and forth to/from a text editor -- the 'click' moves the text cursor back to the mouse pointer's position whereas you probably just want to move into the editor window and leave the text cursor where it was. PEDIGREE: movemouse is based on David Mohr's 'mouse-switchscreen'. After the usual Google searching I found: http://en.gentoo-wiki.com/wiki/Switchscreen which lead me to: http://digamma.cs.unm.edu/trac.dmohr/wiki/DualscreenMouseUtils containing a link to this source code tarball: dualscreen-mouse-utils-0.5.tar.gz According the the documentation in the two pages above, David Mohr improved a utility written by David Antliff: http://unlogical.net/files/scripts/switchscreen-0.4.tar.gz This program makes it possible to jump back and forth between two screens using a keyboard command. Before each jump, the current pointer location is remembered so that a return jump knows where it should land. The above work may have been based on an earlier program called 'switchscreen' by Sampo Niskanen found at: http://sampo.kapsi.fi/switchscreen/ That program is dated 2003 and is much inferior to David Mohr's work IMHO. NOTES ON THE SOURCE AND THINGS TO DO: To build movemouse from source you may need to install aditional 'X' libraries. Note this line from the Makefile: LDFLAGS=-L /usr/X11R6/lib -lX11 -lXtst. David Mohr's code has 's' and 'f' switches that seem to be unused. The 'f' switch is supposed to simulate the left button click in the same way that my 'c' switch now does. The comment block at the very top of the source will probably be of no use to anyone but myself and should probably just be deleted. As of version 1.8, if you do not specify a save/goto number when executing movemouse, you will be prompted for one. The main point of this is to avoid needing to bind a different hotkey for each pointer location you might want to save. We have only so many hotkey combinations available and the above is intended to make it possible to assign just one hotkey for saving any location and one hotkey for jumping to any location, eg. to save, just move the pointer, hit the hotkey and then a digit, and that location is saved to that digit. Alas, whereas this works fine from the command line in an xterm, it does not work as a metacity key binding -- although it waits for a keystroke. that key is not passed to movemouse, but seems to be interpreted as a seperate command. I currently have <Ctrl><Alt>[1-0] bound to save 10 different locations, and <Alt>[1-0] set to goto those locations in the same sequence, if the above could be made to work, it would free up keybindings to be used for more possible goto destinations or just some other useful purpose. As mentioned above, as it is now, movemouse will always move the pointer to any previous position and focus whatever window is there, regardless of whether that window is the same one that was there when the position was saved. However, by using the XRaiseWindow() function it should be possible to have movemouse 'raise' the original window at that location. This might make an interesting modification to the program, since you could move between screens and raise any particular window as desired at the same time -- but I can't get it to work. Although I document this program as being able to save up to 10 positions, the astute coder will quickly see that as many positions could be saved as there are characters that can be used in a legal Linux filename: '~/.pointer-[any legal character]' -- but I presume that 10 should be enough for anyone. To enable 'any character' saving, comment out the test ca. line 147: "Permit only digits." The problem with is is ofcourse finding enough keybindings. As mentioned above, the 'prompt for save/goto number' idea doesn't work when called via a hotkey. Also, there is an irritating 'beep' attached to that code ca. line 143 which you will probably want to comment out or cut. In order to work correctly, the source requires two calls to 'usleep', it would be nice to be able to get rid of them, they seem so arbitrary. Feedback on the program is always welcome. Suggestions, edits or other improvements to the program/source will be gratefully received. I'd like to get hold of David Mohr and show him my work, since it is based on his. If you know how to get in touch with him please let me know. LEGALITIES: movemouse is copyleft (L) 2012 by Ray Andrews <rayandrews@eastlink.ca> movemouse is distributed under the GNU General Public License version 2 or any later version blah, blah. Basically you may use, modify and distribute the program in any way you wish, provided that the source code to any modifications distributed is made available under the GPL too. You may find the exact terms of the GPL on the web. The author takes absolutely no responsibility for any harm this program might do. Use entirely at your own risk.
Source: README, updated 2012-01-17