Intro
What you might want to do to solve your issue is split into three steps:
Install xdotool.
Create a shell script which uses xdotool to position the cursor center-screen when run
Run this script on gnome startup
I can assist with part 1 and part 2. Part 3 I will drop some advice on, but I cannot test that advice personally as I do not use the gnome de.
Part 1
To install xdotool, you need to enable Ubuntu's universe repository in the apt package manager.
If you have Ubuntu 14.04, this should have been enabled by default when you installed your system.
If you feel this may not be the case, or if you have manually disabled the repo yourself, please enter the following commands into a terminal window (accessed by pressing ctrl
+ alt
+ t
) to enable it:
sudo add-apt-repository universe
sudo apt-get update
Following this, to install xdotool, simple enter the following command into a terminal window
sudo apt-get install xdotool
Part 2
You can create this script wherever you like, but I will be using the Documents directory of your home folder for this example.
Additionally, you will have to source your own screen coordinates for the script. I will be using 960x540 because this is the center of my 1920x1080 resolution screen.
To get the center of your screen, find the resolution e.g. 1280x800, and half the width and height.
e.g.:
1280/2 = 640
800/2 = 400
So for a 1280x800 screen you would use 640x800.
To create a script that will position your cursor in the center of the screen when run, do the following:
Enter the command nano ~/Documents/cursorcenter.sh
Copy/paste the following into the terminal window (which has prepared to create the file cursorcenter.sh in your Documents folder upon saving):
#!/bin/bash
xdotool mousemove --sync 960 540
Press ctrl
+ x
then press y
then press enter
to save the script.
Finally, to make the script 'executable', enter the following into a terminal window:
sudo chmod +x ~/Documents/cursorcenter.sh
You can test that your script works by running sh ~/Documents/cursorcenter.sh
in a terminal window. If all goes according to plan, your cursor should jump to the center of the screen!
Part 3
To run your script on startup, you simply have to stick the command sh ~/Documents/cursorcenter.sh
into whatever script gnome runs as it starts up.
If you are using Gnome3, you should be able to make this script run on start up by sticking it in the ~/.config/autostart/
folder.
To do this, run mkdir ~/.config/autostart && mv ~/Documents/cursorcenter.sh ~/.config/autostart/cursorcenter.sh
in a terminal window.
EDIT
If you want to delay the running of xdotool, so that it waits until after whatever time gnome moves the mouse by, put a sleep [time in seconds]
line in the script to be run.
For example, the entire script might look like:
#!/bin/bash
sleep 10
xdotool mousemove --sync 960 540
This would wait 10 seconds before positioning your cursor center-screen.