Shut down your computer using your Slim Devices remote control - XPLProject



This HowTo guide explains how you can use xPLHal in conjunction with the native xPL support in SlimServer to automatically shut down your computer using a sequence of button presses on the Slim Devices remote control.

We will create an xPLHal script that will execute a free command-line utility called poweroff.exe to shut down the computer when the defined button presses are detected.

What You Need

  • A Windows PC running xPLHal, xPLHal manager and an xPL Hub as described in the HowTo guide Get Started on Windows.
  • A SliMP3 or Squeezebox using SlimServer version 5.2 or greater, with xPL support enabled as described in the HowTo guide Enable xPL support in SlimServer

Downloading the Software

Download poweroff.exe from (26KB)

Installing the Software

Unzip poweroff.exe into your Windows system directory (Usually either C:\Winnt\System32 or C:\Windows\System32).

Creating the xPLHal script

  • Click Start -> Programs -> xPLHal -> xPLHal Manager
  • In xPLHal Manager, click on Scripts.
  • You should see a script for your player, with the filename of slimdev_slimserv_<player-name>.xpl - double click on it to open the script editor.
  • Paste the following script into the script editor, replacing <player-name> with the name of your player:
sub slimdev_slimserv_<player-name>_trigger(XplMsg)
  ' We're only interested in button presses
  If not lcase(xpl.GetParam(XplMsg,"{schema}",True)) = "remote.basic" Then
    Exit Sub
  End If

  ' We're only interested if the player is powered off
  If not lcase(xpl.getparam(XplMsg,"power",true)) = "off" Then
    Exit Sub
  End If

  if lcase(xpl.getparam(XplMsg,"keys",true)) = "numberscroll_1" Then
    sys.value("SlimShutdown") = "1"
  ElseIf lcase(xpl.getparam(XplMsg,"keys",true)) = "numberscroll_2" and sys.value("SlimShutdown") = "1" Then
    sys.value("SlimShutdown") = "2"
  ElseIf lcase(xpl.getparam(XplMsg,"keys",true)) = "numberscroll_3" and sys.value("SlimShutdown") = "2" Then
    sys.value("SlimShutdown") = "3"
    call sys.execute("poweroff.exe","/h",False)
  End If  
End Sub
  • If you want to shut down a PC other than the one that is running xPLHal, change the IP address ( in the call sys.execute line to the IP address or hostname of the target machine.
  • Select the Save and Reload option from the File menu - you should see a message saying your scripts were reloaded successfully.


To test the script, turn off your player, then press 1, then 2, then 3 on the remote control. Your PC should now shut down.

Want to discuss this article?

If you have questions or comments about this article, you can join the mailing list enabled xPL forums.

This page was last modified on 14 January 2006, at 22:13. This page has been accessed 5,626 times.