Skip to content

Instantly share code, notes, and snippets.

@velazcod
Created September 9, 2010 05:03
Show Gist options
  • Save velazcod/571401 to your computer and use it in GitHub Desktop.
Save velazcod/571401 to your computer and use it in GitHub Desktop.
Ability to change volume on your mac remotely. You can use Tasker's HTTP GET action for better results..
<html>
<head>
<title>MacBook remote volume</title>
</head>
<body>
<?php
if (!isset($_GET['volumechange']))
{
echo "<h1>An error has occurred.</h1>";
exit();
}
switch ($_GET['volumechange'])
{
case "mute":
exec("osascript -e \"set volume 0\"");
echo "<h1>Volume was set to: 0</h1>";
break;
case "low":
exec("osascript -e \"set volume 1.5\"");
echo "<h1>Volume was set to: 1.5</h1>";
break;
case "normal":
exec("osascript -e \"set volume 3\"");
echo "<h1>Volume was set to: 3</h1>";
break;
case "highest":
exec("osascript -e \"set volume 7\"");
echo "<h1>Volume was set to: 7</h1>";
break;
case 0:
exec("osascript -e \"set volume 0\"");
echo "<h1>Volume was set to: 0</h1>";
break;
case 1:
exec("osascript -e \"set volume 1\"");
echo "<h1>Volume was set to: 1</h1>";
break;
case 2:
exec("osascript -e \"set volume 2\"");
echo "<h1>Volume was set to: 2</h1>";
break;
case 3:
exec("osascript -e \"set volume 3\"");
echo "<h1>Volume was set to: 3</h1>";
break;
case 4:
exec("osascript -e \"set volume 4\"");
echo "<h1>Volume was set to: 4</h1>";
break;
case 5:
exec("osascript -e \"set volume 5\"");
echo "<h1>Volume was set to: 5</h1>";
break;
case 6:
exec("osascript -e \"set volume 6\"");
echo "<h1>Volume was set to: 6</h1>";
break;
case 7:
exec("osascript -e \"set volume 7\"");
echo "<h1>Volume was set to: 7</h1>";
break;
default:
echo "<h1>The volume command was not recognized</h1>";
break;
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment