We can create a shell script which would simulate mouse movement at a specified interval (only when XBMC is running) and prevent your screen from turning off.
Follow the steps:
Install necessary tools:
We would need xdotool
to do this job for us. Install it by running the following command in terminal:
sudo apt-get install xdotool
The Script:
Save the following script anywhere on your PC. You can modify sleep_period
according to your needs, I have set it at 60 seconds. The script checks if there is a process called xbmc.bin
running; and if it finds one, then it loops to simulate mouse movement while the process is active. Otherwise, checks for the process again after the specified interval.
#!/usr/bin/env bash
sleep_period=60s #seconds
mouse_x=0
mouse_y=0
movement_px=2
mouse_x=$(xdotool getmouselocation 2>/dev/null | sed -e 's/x://' -e 's/y//' -e 's/ screen:.*$//' -e 's/ //' | awk 'BEGIN {FS=":"} {print $1}')
mouse_y=$(xdotool getmouselocation 2>/dev/null | sed -e 's/x://' -e 's/y//' -e 's/ screen:.*$//' -e 's/ //' | awk 'BEGIN {FS=":"} {print $1}')
while true; do
if [[ $(pidof xbmc.bin | wc -w) -gt 0 ]]; then
while [[ $(pidof xbmc.bin | wc -w) -gt 0 ]]; do
xdotool mousemove $((mouse_x+${movement_px})) $((mouse_y+${movement_px}))
xdotool mousemove $((mouse_x-${movement_px})) $((mouse_y-${movement_px}))
sleep ${sleep_period}
done
else
sleep ${sleep_period}
fi
done
Make this script executable:
Right-click on the file you just saved >> Select Properties >> In the Permission tab, put the Check mark on Execute.

Execute this script automatically on every startup:
We can do this with the help of Startup Applications. Open your Dash by pressing Enter and query for Startup Applications
>> In Startup Applications Window, click on Add >> Then, in the dialog that pops up, fill the information:
Name: optional, whatever you want to name this.
Command: path to the file where you saved it.
Comment: optional, if you wish to add some.

Restart your system and enjoy your movies with XBMC.
How to use it with other Applications
This was an example for XBMC (Process name xbmc.bin
). However, it can also be used for any other process of your choice by just replacing xbmc.bin
in the Script mentioned in Step-2 with the name of the process you wish. Find the following lines in the above script:
while true; do
if [[ $(pidof xbmc.bin | wc -w) -gt 0 ]]; then
while [[ $(pidof xbmc.bin | wc -w) -gt 0 ]]; do
And replace xbmc.bin
in both lines 2 and 3 with the process name of your choice.
How to find the process name
With GUI (GNOME):
We can use System Monitor
to find the name of the process. Press Super to open Dash and query for "System Monitor" to launch it. In the Processes Tab, we can find the Process Name as the first column.

With Terminal:
We can run top
to list all the running processes. The last column called Command
gives us the name of the Process (however it is limited to first 15 characters).

Here we can see that Firefox is just named as firefox
. So, if we want this behavior when Firefox is running; we would replace xbmc.bin
in the script with firefox
and everything else would work just fine.
Acknowledgement: I had found the script here. However, I have made necessary modifications to make it compact and satisfy the demands of the question.