Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Created October 20, 2012 20:34
Show Gist options
  • Save ttscoff/3924705 to your computer and use it in GitHub Desktop.
Save ttscoff/3924705 to your computer and use it in GitHub Desktop.
First draft of an iPhone-controlled cough button for my Mac

Rough start: iPhone cough button for Mac

Video: http://ckyp.us/mLi+

Not all that smart yet, but a little jQuery with Hammer.js:

	(function($){
		window.scrollTo(0,1);
		$("#cough")
			.hammer({
				prevent_default: true,
				hold_timeout: 0
			})
			.bind("hold", function(ev) {
				$.get('functions.php?func=coughon');
				$(this).css({background:'red'});
			})
			.bind('release', function(ev) {
				$.get('functions.php?func=coughoff');
				$(this).css({background:'#478b35'});
			});
	})(jQuery);

and a PHP script:

<?php

switch ($_REQUEST['func'])
{
  case "coughon":
  exec("osascript -e 'set volume input volume 0'");
  echo "Input Muted";
  break;

  case "coughoff":
  exec("osascript -e 'set volume input volume 60'");
  echo "Input restored";
  break;
}

with some CSS/HTML and it's a go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment