Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
1  
There should be a setting in XBMC under Power Saving>Turn off on idle or something to that effect. Have you tried that ? –  Ye Lin Aung 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. –  neon_overload 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. –  neon_overload 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. –  neon_overload Jan 24 '13 at 23:19
show 1 more comment

4 Answers 4

up vote 5 down vote accepted
+150

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

share|improve this answer
    
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. –  neon_overload Jan 23 '13 at 23:55
add comment

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

share|improve this answer
    
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
show 1 more comment

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

You can install caffeine from the launchpad ppa by doing the following steps

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

Enjoy!

share|improve this answer
    
This looks like a good tool. –  neon_overload Jan 29 '13 at 0:13
add comment

I use these in ~/bin/:

#!/bin/bash

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

#!/bin/bash

# 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

share|improve this answer
    
I'm using Gnome so I don't think I'm using xscreensaver. Thanks for your answer. –  neon_overload Jan 29 '13 at 1:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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