Friday, January 6, 2012

Disabling X ScreenSaver on *Nix systems while running VLC Media Player

Hello.

Have you ever experienced an annoyance of the gnome screeensaver coming up when watching your favorite movie and then increasing the timeout of the screensaver just to watch that movie without getting disturbed again? Well, that's because VLC's disable-screensaver feature doesn't help really well under X (though it works perfectly fine under Windows). Some Windows users might have had problems under Windows too in earlier versions of VLC because the VLC config file (don't remember the path and file name) is not properly protected. You might have to edit the file manually and see if the line below exists and not commented (beginning with a #).

disable-screensaver=1

Well, coming back to linux problems, the following is a very simple workaround I found useful. Please try it out and let me know if this doesn't help either.

  1. Open up your favourite Terminal application and type 'cd /usr/bin'.
  2. 'sudo mv vlc vlc-original'. We're renaming the original vlc program to something of our choice.
  3. 'sudo vi vlc'. Again use your favourite editor to create a file and add the following:
  • #!/bin/bash
  • xscreensaver-command -exit
  • vlc-original "$1"
  • xscreensaver &
    4. 'sudo chmod 774 vlc'. This is required to make our "vlc script" executable.
    5. Now, either type 'vlc <path-to-your-media-file>' from the terminal or play the media from your     desktop environment.

Explanation:
  1. The first line in our script indicates that this is a bash executable script and the location of bash command.
  2. The second line just exits the xscreensaver-command service so that the screensaver is not active until you close the VLC Media Player window.
  3. The third line invokes the actual VLC program with the media you want to play. Yes, it supports playing only one at a time, but you can edit it such that it can handle as many media you want it to play. Note that the first argument ($1) is wrapped within double quotes to take care of file names with spaces in between.
  4. The last line is to make sure the screensaver service is running back again.
Hope this helps someone. See you in the next blog!

No comments:

Post a Comment