In 12.04, the screen never went to sleep while watching videos in XBMC. However after upgrading to 12.10 and changing no settings, it does.

Is there any way I can prevent the screen automatically turning off while playing a video in XBMC, without actually disabling the screen from turning off at other times?

Ideally, is there a XBMC specific setting for this? Was this a feature of XBMC that is now somehow broken in 12.10 or has this changed due to some other non-XBMC change within Ubuntu?

  • 1
    There should be a setting in XBMC under Power Saving>Turn off on idle or something to that effect. Have you tried that ? Jan 23 '13 at 3:18
  • The problem is happening while watching a movie, which isn't idle. I don't mind (and actually like) it turning off the screen while idle. Jan 23 '13 at 3:47
  • What versions are you using? Do you have any special power-settings in ubuntu? I'm running a fresh 12.10 install with the (normal, not the unstable) XBMC from the PPA, and I'm not affected by this, so it doesn't seem to be a default thing // doesn't affect all people. (yeah, I know, that doesn't help you much, but still it might help to know it's not an ever-present bug.. I dunno :) )
    – Nanne
    Jan 23 '13 at 10:40
  • I'm using the version from Ubuntu (12.10, recently upgraded from 12.04), not from a PPA. No special power settings, just the default which turns off the monitor after a period of inactivity. Jan 23 '13 at 23:56
  • Thanks for the effort you put in to that answer Aditya but I think I'd rather try the two alternatives proposed by Nanne's answer first. Jan 24 '13 at 23:19

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:

  1. Install necessary tools:

    We would need xdotool Install xdotool to do this job for us. Install it by running the following command in terminal:

    sudo apt-get install xdotool
  2. 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=$(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}
        sleep ${sleep_period}
  3. Make this script executable:

    Right-click on the file you just saved >> Select Properties >> In the Permission tab, put the Check mark on Execute.

    make the script executable

  4. 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.

    startup applications preferences

  5. 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.

    System Monitor

  • 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).

    Terminal <code>top</code> command

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.

  • Wouldn't that be a last, last, final, nothing-else works resort though?
    – Nanne
    Jan 23 '13 at 10:41
  • 1
    @Nanne: No... Why would that be so; the shell script won't hog your system resources; and it wouldn't simulate mouse movement when XMBC is not running; as well as you won't have to remember to run this script everytime... Though a Preference setting in XMBC would obviously be the best solution; since I don't use XMBC - I don't know if such setting exists. I have tested this Shell script with Firefox and it works as expected by the OP.
    – Aditya
    Jan 23 '13 at 10:47
  • The problem is that the system shouldn't go to sleep while playing video (and for me it doesn't). This is clearly a workaround (you might call it a hack even) and I'm not saying it is bad, props to you for this great post, but still I would first look for a real solution (as you say, you do not know about XBMC, so there might be an actual one) before you try this. Again, nothing bad about your actual post, but don't you agree that making the mouse move is something you should try after "normal" settings fail?
    – Nanne
    Jan 23 '13 at 10:49
  • 1
    @Nanne As I said, a Preference Setting within XMBC to control it would obviously be the best solution. However, its prudent for me to expect that the OP has done his homework. Moreover, if such setting was available within XMBC, I think someone would have come up and posted his answer. The question being 7 days old as of now - I don't think its there in XMBC. Anyways, as you use XMBC, can you please check if it can be done :)
    – Aditya
    Jan 23 '13 at 10:53
  • 3
    I wouldn't call this a hack. People use shell scripts to do these things all the time. Awesome answer +1.
    – Seth
    Jan 26 '13 at 16:19

A very simple solution is caffeine. Caffeine is a 'status bar application able to temporarily prevent the activation of both the screensaver and the "sleep" powersaving mode.'

Enabling it is as easy as clicking the status bar indicator, but you can also set it up such that it automatically disables the screensaver when you start xbmc. See the screenshot below

enter image description here

If you're using Gnome you can install the caffeine gnome extension. If not, for Ubuntu up to 15.04 (vivid) you can install caffeine from the launchpad ppa:

sudo add-apt-repository ppa:caffeine-developers/ppa
sudo apt-get update
sudo apt-get install caffeine

from 15.10 onwards you can install without ppa

sudo apt install caffeine


  • This looks like a good tool. Jan 29 '13 at 0:13
  • @PeterMortensen It does work, even on 16.04, that answer is outdated. Thanks for the headsup though, because my answer could use an update as well ;) I added the installation instructions for the newer Ubuntu versions. Jul 26 '16 at 5:35

This seems to be a bug in the XBMC package for ubuntu

I'm not sure what version you have installed, but the version from the PPA* doesn't seem to have it on my system. This can be because I have different settings in ubuntu of course, so your milleage may vary.

If you don't, you can try to use XBMC as a session (on your login-screen, press the ubuntu logo next to your name and select XBMC. You won't get unity, but just fullscreen XMBC). The settings for unity will not be there, so you might luck out on not having a screensaver. (If you have auto-login set, you need to press logout to get the login screen)

* https://launchpad.net/~team-xbmc/+archive/ppa

  • Thanks for the bug link, that looks like the reason for my problem as I'm using the xbmc package from Ubuntu. I will try using XBMC as a session when I'm at home and see if that fixes it. Jan 23 '13 at 23:55

I use these in ~/bin/:


# ssoff - disable screensaver and power mgmt
pkill xscreensaver
xset s 0
xset -dpms


# sson - activate screen and power mgmt
xscreensaver > /dev/null 2>&1 &
xset s 100
xset +dpms

of course you can make an icon to run these but I don't use XBMC either

  • I'm using Gnome so I don't think I'm using xscreensaver. Thanks for your answer. Jan 29 '13 at 1:02

These solutions all turn the screensaver off whenever xbmc is running, not just when it's playing videos. As it has a built-in UPnP server, I leave it running 24/7 but I only want to disable the screensaver when a video is being played locally.

Here's what I came up with: turn on http and JSON support in XBMC. Then loop making a request to find out whether the player is active or not. If it is, issue an xscreensaver-command -disable (you can adjust this per your screensaver). If not, do nothing. Checking every 50 seconds is plenty for me.

Python code here: http://sumnerhayes.com/software/

  • This question was about the XBMC in Ubuntu 12.10 which had a bug where it didn't disable the screensaver while playing a video. This bug doesn't exist in the XBMC in more up-to-date versions of Ubuntu, so I don't think your workaround is necessary. XBMC disables the screensaver while playing video, as it should. Sep 2 '14 at 0:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.