Created
July 23, 2013 18:27
-
-
Save jqtruong/6064851 to your computer and use it in GitHub Desktop.
When i feel like taking a break to watch a video but now ads are everywhere, thought of this neat elisp script to turn off the volume for a specified number of seconds (otherwise defaults to 30) and message me when the time's up on a Mac OS X, using osascript... now if there was a way to switch back to my browser :) i'll try that on stumpwm!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun jqt/skip-ads (&optional seconds) | |
"SECONDS default to 30" | |
(interactive "p") | |
(let* ((seconds (number-to-string (or seconds 30))) | |
(command "osascript -e 'output volume of (get volume settings)'") | |
(output (shell-command-to-string command)) | |
(current-volume (replace-regexp-in-string "[\s\n]" "" output)) | |
(set-volume-command "osascript -e 'set volume output volume %s'")) | |
(shell-command (format set-volume-command 0)) | |
(message "Ads stink! Turned volume (was at level %s) off for %s seconds..." current-volume seconds) | |
(run-at-time (concat seconds " sec") nil | |
(lambda (v cmd) | |
(shell-command (format cmd v)) | |
(message "Ads should be done now... phew! Turned volume back up to %s." v)) | |
current-volume set-volume-command))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment