Last active
October 3, 2017 08:13
-
-
Save kulicuu/b44145c68da838fc885a247fa549736e to your computer and use it in GitHub Desktop.
Image displays fullscreen as attention grabber to enforce Pomodoro breaktime.
This file contains hidden or 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
| { | |
| "dependencies": { | |
| "bash-color": "latest", | |
| "clear": "latest", | |
| "clear-terminal-line": "latest", | |
| "console-control-strings": "latest", | |
| "lodash": "latest", | |
| "tree-kill": "latest" | |
| } | |
| } | |
This file contains hidden or 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
| ... |
This file contains hidden or 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
| c = console.log.bind console | |
| _ = require 'lodash' | |
| fs = require 'fs' | |
| color = require 'bash-color' | |
| clear = require 'clear' | |
| clear_line = require 'clear-terminal-line' | |
| console_control = require 'console-control-strings' | |
| spawn = require('child_process').spawn | |
| kill = require 'tree-kill' # unused but may be used later if continue having issues killing drones | |
| img_rayy_f = (location) -> | |
| _.filter fs.readdirSync(location), (file) -> | |
| parts = file.split '.' | |
| if ["jpg", "png", "jpeg", "bmp", "gif"].indexOf(parts[parts.length - 1]) > -1 | |
| true | |
| else | |
| false | |
| the_path = "/home/s/Pictures" | |
| img_rayy = img_rayy_f the_path | |
| second = 1000 | |
| minute = 60 * second | |
| twenty_five_minutes = 25 * minute | |
| thirty_five_minutes = 35 * minute | |
| five_minutes = minute * 5 | |
| ten_minutes = minute * 10 | |
| launch_break = ({ break_duration })-> | |
| photos_open = [] | |
| the_start = Date.now() | |
| clear() | |
| c "#{color.cyan('Now 5 min break.', on)}" | |
| images_show = setInterval -> | |
| the_now = Date.now() | |
| the_delta = the_now - the_start | |
| the_remaining = five_minutes - the_delta | |
| minutes_remaining = Math.floor(the_remaining / 60) | |
| seconds_modulus_minutes = the_remaining % 60 | |
| random_idx = _.random(0 , img_rayy.length - 1) | |
| img = img_rayy[random_idx] | |
| photos_open.push (spawn 'eog', ['--fullscreen', '/' + the_path + '/' + img]) | |
| if the_remaining <= 0 | |
| clearInterval images_show | |
| for drone, idx in photos_open | |
| drone.stdin.pause() | |
| drone.kill() | |
| c "\t #{color.green('...Ready.', on)}" | |
| , 10 * second | |
| timer_001 = ({ pomodoro_duration, break_duration })-> | |
| the_start = Date.now() | |
| countdown = setInterval -> | |
| the_now = Date.now() | |
| the_delta = the_now - the_start | |
| the_remaining = pomodoro_duration - the_delta | |
| seconds_remaining = Math.floor(the_remaining / second) | |
| minutes_remaining = Math.floor(seconds_remaining / 60) | |
| seconds_modulus_minutes = seconds_remaining % 60 | |
| seconds_display = if seconds_modulus_minutes > 9 | |
| seconds_modulus_minutes.toString() | |
| else | |
| "0#{seconds_modulus_minutes.toString()}" | |
| clear() | |
| c "#{color.blue('\n\n\tPomodoro active:', on)}" | |
| c "\t #{color.cyan(minutes_remaining.toString(), on)}:#{color.cyan(seconds_display, off)}" | |
| if the_remaining <= 0 | |
| clearInterval countdown | |
| launch_break { break_duration } | |
| , 100 | |
| timer_001 | |
| pomodoro_duration : thirty_five_minutes | |
| break_duration : ten_minutes |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions :
Assuming you have nodejs installed, and both files in current directory:
npm iandnpm i -g coffee-scriptthe_pathstring on line 44 with the absolute path to your images folder.coffee pomodoro_001.coffee