Prerequisite: xdotool
To install xdotool : sudo apt-get install xdotool
Create a script file nano moveCustor.sh
and save it in your desired directory. (Here, I've saved it in my /home/user
directory)
Paste the below script content in the file.
Remember to make your script executable using the command chmod +x moveCustor.sh
. Then you can run your script with ./moveCustor.sh
.
Please note that xdotool
might not work as expected in all environments or for all types of applications, especially those that don’t use standard X11 interfaces. If you encounter any issues or need more complex functionality, I recommend checking out the xdotool
man page or other online resources for more information.
-
Create a new service file in /etc/systemd/system/ with a .service extension, for example myscript.service. You can use
sudo nano /etc/systemd/system/myscript.service
to open a new file in the nano text editor. -
Add the following content:
[Unit] Description=My Script [Service] User=yourUserName Environment=DISPLAY=:1 Environment=XAUTHORITY=/run/user/1000/gdm/Xauthority ExecStart=/path/to/your/script.sh [Install] WantedBy=multi-user.target
Note:
- To get your
Environment=DISPLAY
value, doecho $DISPLAY
. - To get your
Environment=XAUTHORITY
value, doecho $XAUTHORITY
. - Replace yourusername with your actual username.
- To get your
-
Save and close the file (in nano, you can do this by pressing Ctrl+X, then Y to confirm saving).
-
Now you need to reload the systemd manager configuration with:
sudo systemctl daemon-reload
. -
Enable your service to be run at startup:
sudo systemctl enable myscript.service
-
You can start your service immediately with:
sudo systemctl start myscript.service
-
You can check the status of your service anytime with:
sudo systemctl status myscript.service