[
  {
    "path": ".gitignore",
    "content": "*.py[cod]\n\n# C extensions\n*.so\n\n# Packages\n*.egg\n*.egg-info\ndist\nbuild\neggs\nparts\nbin\nvar\nsdist\ndevelop-eggs\n.installed.cfg\nlib\nlib64\n\n# Installer logs\npip-log.txt\n\n# Unit test / coverage reports\n.coverage\n.tox\nnosetests.xml\n\n# Translations\n*.mo\n\n# Mr Developer\n.mr.developer.cfg\n.project\n.pydevproject\n"
  },
  {
    "path": "LICENSE.txt",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2013 Daniel Bader\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# [A countdown timer extension for Alfred.app](http://dbader.org/blog/alfred-timer-extension)\nA simple countdown timer command for [Alfred.app](http://www.alfredapp.com/) that uses Mountain Lion User Notifications.\n\n![Demo screenshot](https://raw.github.com/dbader/alfred-countdown-timer/master/screenshot.png)\n\nThe extension is described in closer detail on my [blog](http://dbader.org/blog/alfred-timer-extension).\n\n## Benefits\n- Helps you make great tea.\n- Solves your [Pomodoro](http://en.wikipedia.org/wiki/Pomodoro_Technique) needs.\n- Uses Mountain Lion's User Notifications to tell you when time's up.\n- Plays a non-intrusive alarm sound.\n- Allows you to run multiple timers at the same time.\n- Allows you to add an optional label to the timer, e.g. \"Laundry is done!\". Thanks to [Alexander Lehmann](http://rudairandamacha.blogspot.de) for the suggestion.\n- Shows you how to write Alfred extensions in Python.\n\n## Installation\n- Download [Timer.alfredworkflow](https://github.com/dbader/alfred-countdown-timer/blob/master/Timer.alfredworkflow?raw=true)\n- Double-click `Timer.alfredworkflow` to install the extension.\n\nTo use this extension you need [Alfred.app](http://www.alfredapp.com/) for macOS and the [Alfred PowerPack](http://www.alfredapp.com/powerpack/).\n\n## Usage\n- The general syntax is `timer [minutes] [optional:title]`\n- `timer 5` sets a countdown timer that goes off after 5 minutes.\n- `timer 0:30` or `timer 0.5` sets a timer that goes off after 30 seconds.\n- `timer 40 Laundry is done!` adds an optional title to the timer.\n- `timer` displays usage information.\n\n## Meta\n\nDaniel Bader – [@dbader_org](https://twitter.com/dbader_org) – mail@dbader.org\n\nDistributed under the MIT license. See ``LICENSE.txt`` for more information.\n\nhttps://github.com/dbader/alfred-countdown-timer\n"
  },
  {
    "path": "Timer/LICENSE.txt",
    "content": "The icon is from ~MazeNL77's \"nx10\" icon set.\n\nThe sound is \"Ice\" from Nitram+Nunca's awesome \"Minutes\" dashboard widget.\nSadly, the company seems to have vanished. I love this sound and use\nit on all my devices as an alarm sound. So Nitram+Nunca, I hope it is okay\nfor you that I include your sound file. If not please contact me and I will\ntake it offline.\n\nThe rest of the project is released under the MIT license.\n\n\nCopyright (c) 2013 Daniel Bader (http://dbader.org)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "Timer/info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>action</key>\n\t<false/>\n\t<key>category</key>\n\t<string>SCRIPTS</string>\n\t<key>command</key>\n\t<string>python timer.py {query}</string>\n\t<key>disabled</key>\n\t<false/>\n\t<key>escapedollar</key>\n\t<false/>\n\t<key>escapequery</key>\n\t<false/>\n\t<key>escapequerybackquotes</key>\n\t<true/>\n\t<key>escapequerybrackets</key>\n\t<true/>\n\t<key>escapequeryquotes</key>\n\t<true/>\n\t<key>escapequerysemicolons</key>\n\t<true/>\n\t<key>growloutput</key>\n\t<true/>\n\t<key>growloutputsticky</key>\n\t<true/>\n\t<key>keyword</key>\n\t<string>timer</string>\n\t<key>logging</key>\n\t<false/>\n\t<key>multifileargs</key>\n\t<false/>\n\t<key>parameter</key>\n\t<integer>0</integer>\n\t<key>silent</key>\n\t<true/>\n\t<key>subtitle</key>\n\t<string>Example: timer 5:30</string>\n\t<key>title</key>\n\t<string>Start a countdown timer</string>\n</dict>\n</plist>\n"
  },
  {
    "path": "Timer/kudos.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>creator</key>\n\t<string>Daniel Bader</string>\n\t<key>website</key>\n\t<string>http://dbader.org/blog/alfred-timer-extension</string>\n</dict>\n</plist>\n"
  },
  {
    "path": "Timer/timer.py",
    "content": "#!/usr/bin/env python3\n\n\"\"\"\nA simple countdown timer command for Alfred.app that\nuses Mountain Lion User Notifications.\n\nCopyright (c) 2013 Daniel Bader (http://dbader.org)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\"\"\"\n\nimport json\nimport os\nimport subprocess\nimport sys\nimport time\n\n\ndef main(argv):\n    interval = parse_time(argv)\n    minutes = interval / 60\n    seconds = interval % 60\n\n    label = ' '.join(argv[1:])\n    title = 'Timer started' + (': %s' % label.capitalize() if label else '.')\n\n    if minutes and seconds:\n        notify(title, \"I'll notify you in %i:%.2i.\" % (minutes, seconds))\n        passed_time = '%i:%.2i have passed.' % (minutes, seconds)\n    elif minutes:\n        notify(title, \"I'll notify you in %i %s.\" % (minutes,\n               'minute' if minutes == 1 else 'minutes'))\n        passed_time = '%i %s passed.' % (minutes,\n                      'minute has' if minutes == 1 else 'minutes have')\n    else:\n        notify(title, \"I'll notify you in %i seconds.\" % seconds)\n        passed_time = '%i seconds have passed.' % seconds\n\n    time.sleep(interval)\n    notify(\"Time's up\" + (': %s' % label.capitalize() if label else '.'),\n           passed_time)\n    play_sound('alarm.m4a')\n\n\ndef parse_time(argv):\n    \"\"\"Parse and return the desired countdown duration in seconds from\n    the commandline.\n    \"\"\"\n    try:\n        duration = argv[0]\n        if ':' in duration:\n            # Minutes and seconds, e.g. \"5:30\"\n            minutes, seconds = duration.split(':')\n            return int(minutes) * 60 + int(seconds)\n        else:\n            # Just minutes, e.g. \"1.5\"\n            return int(float(duration) * 60)\n    except:\n        show_usage()\n        sys.exit(1)\n\n\ndef show_usage():\n    notify('Timer usage', 'timer [minutes] [optional: title]')\n\n\ndef notify(title, text=None):\n    subprocess.Popen([\n        'osascript', \n        '-e', \n        f'''tell application id \"com.runningwithcrayons.Alfred\" to run trigger \"notification\" in workflow \"org.dbader.alfred.timer\" with argument \"{title}|||{text}\"'''\n    ])\n\n\ndef play_sound(filename):\n    \"\"\"Play the given sound file using the `afplay` command line utility.\"\"\"\n    subprocess.Popen(['afplay', filename])\n\n\nif __name__ == '__main__':\n    if len(sys.argv) > 1:\n        argv = sys.argv[1].split()\n    else:\n        argv = []\n    main(argv)\n"
  }
]