Skip to content

Commit

Permalink
Merge pull request #46 from gmelodie/master
Browse files Browse the repository at this point in the history
Add silent mode
  • Loading branch information
JaDogg authored Oct 18, 2019
2 parents 244420c + f070718 commit bce782c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ Usage 📖

.. _wiki: https://github.com/JaDogg/pydoro/wiki


**Obs:** Use `--no-sound` to mute alarms, `--no-clock` to hide the clock or `--focus` for both clock hiding and sound muting

Credits 🙇‍♂️
------------------
* Pomodoro - Invented by Francesco Cirillo
Expand Down
10 changes: 8 additions & 2 deletions pydoro/pydoro_core/tomato.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def __init__(self, time_period=0, tomato=None):
self._progress = itertools.cycle(PROGRESS)

def start(self):
play_alarm()
if not self._tomato._no_sound:
play_alarm()
return WorkingState(tomato=self._tomato)

def pause(self):
Expand Down Expand Up @@ -240,6 +241,8 @@ def __init__(self, time_period=0, tomato=None):
self._sound()

def _sound(self):
if self._tomato._no_sound:
pass
if cur_time() - self._last_alarm_time > ALARM_TIME:
play_alarm()
self._last_alarm_time = cur_time()
Expand Down Expand Up @@ -279,7 +282,8 @@ def start(self):
@property
def time_remaining(self):
self._calc_remainder()

if self._tomato._no_clock:
return ""
return self._format_time(self._remainder)

@property
Expand Down Expand Up @@ -430,6 +434,8 @@ def return_to(tomato, state):
class Tomato:
def __init__(self, emoji):
self._state = InitialState(tomato=self)
self._no_clock = False
self._no_sound = False
self.tomatoes = 0

self._emoji = emoji
Expand Down
23 changes: 22 additions & 1 deletion pydoro/pydoro_tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import argparse
import threading

import argparse

from prompt_toolkit.application import Application
from prompt_toolkit.application.current import get_app
from prompt_toolkit.key_binding import KeyBindings
from prompt_toolkit.key_binding.bindings.focus import focus_next, focus_previous
from prompt_toolkit.layout import HSplit, Layout, VSplit, FormattedTextControl, Window
from prompt_toolkit.layout import HSplit, Layout, VSplit, FormattedTextControl, Window, ConditionalContainer
from prompt_toolkit.styles import Style
from prompt_toolkit.widgets import Box, Button, Label

Expand Down Expand Up @@ -98,6 +100,25 @@ def draw():


def main():
# Parse arguments
parser = argparse.ArgumentParser()
parser.add_argument("--focus", help="focus mode: hides clock and \
mutes sounds (equivalent to --no-clock and --no-sound)",
action="store_true")
parser.add_argument("--no-clock", help="hides clock",
action="store_true")
parser.add_argument("--no-sound", help="mutes all sounds",
action="store_true")
args = parser.parse_args()

# Check for no-clock (or focus mode)
if args.no_clock or args.focus:
tomato._no_clock = True

# Check for no-sound (or focus mode)
if args.no_sound or args.focus:
tomato._no_sound = True

draw()
threading.Thread(target=lambda: every(0.4, draw), daemon=True).start()
application.run()
Expand Down

0 comments on commit bce782c

Please sign in to comment.