Skip to content

Commit

Permalink
Small fixes and cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
okraits committed Apr 19, 2017
1 parent 60d8b14 commit 88ae369
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ When omodoro is running, you can type:
- __c__ to continue the current pomodoro cycle - the end time will be adjusted
- __n__ to abort the current pomodori or break and start the next one
- __s__ to get the status of the current cycle
- __t__ to turn the terminal bell on/off
- __q__ to quit omodoro
- __t__ to toggle the terminal bell on/off

### 6. Customization

Expand All @@ -82,7 +82,7 @@ with
L length of one pomodori in minutes
S length of a short break in minutes
B length of a long break in minutes
T option for playing a terminal bell at the start of each pomodoro / break. 1 for ON, 0 for OFF.
T enable/disable the terminal bell to be played at the begin of each pomodoro/break. 1 for on, 0 for off.

Example with the default values:

Expand Down
28 changes: 13 additions & 15 deletions omodoro
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ num_pomodori = 4 # number of pomodori to do in a cycle
length_pomodori = 25 # length of one pomodori in minutes
length_short_break = 5 # length of a short break in minutes
length_long_break = 15 # length of a long break in minutes
play_terminal_bell = False # Option to play a terminal bell at the start of cycles
terminal_bell = False # play the terminal bell at the begin of each pomodoro/break

# path to user-specific configuration file
if onWindows:
Expand All @@ -40,13 +40,13 @@ else:
def printUsageInfo():
print("""Usage:
\tomodoro
\tomodoro P-L-S-B
\tomodoro P-L-S-B-T
with
\tP\tnumber of pomodori to do in a cycle
\tL\tlength of one pomodori in minutes
\tS\tlength of a short break in minutes
\tB\tlength of a long break in minutes
\tT\tterminal bell switch: 1 = On / 0 = Off \n
\tT\tterminal bell: 1 = On / 0 = Off\n
Example with the default values:
\tomodoro 4-25-5-15-0
""")
Expand All @@ -57,8 +57,8 @@ def printCLIInfo():
c continue the current pomodoro cycle
n abort current pomodori/break, start next one
s get status of current cycle
q quit omodoro
t terminal bell on/off toggle""")
t terminal bell on/off
q quit omodoro""")

# global variables
class States:
Expand Down Expand Up @@ -91,8 +91,8 @@ def changeState(newState, length):
end_time = datetime.now() + timedelta(minutes=length)
description = description + end_time.strftime("%H:%M")

if play_terminal_bell == True:
print("\n%s\nEnd Time: %s\n\a$ " % (title, end_time.strftime("%H:%M")), end="")
if terminal_bell == True:
print("\n%s\nEnd Time: %s\a\n$ " % (title, end_time.strftime("%H:%M")), end="")
else:
print("\n%s\nEnd Time: %s\n$ " % (title, end_time.strftime("%H:%M")), end="")

Expand Down Expand Up @@ -170,6 +170,7 @@ if __name__ == "__main__":
length_pomodori = config.getint('POMODORO','length')
length_short_break = config.getint('POMODORO','short_break')
length_long_break = config.getint('POMODORO','long_break')
terminal_bell = bool(config.getint('POMODORO', 'terminal_bell'))
except KeyError as error:
print('"{key}" is not located in the config file "{file}".'.format(
key=error,
Expand All @@ -184,12 +185,11 @@ if __name__ == "__main__":
else:
try:
user_values = argv[1].split('-')
print(user_values[4])
num_pomodori = int(user_values[0])
length_pomodori = int(user_values[1])
length_short_break = int(user_values[2])
length_long_break = int(user_values[3])
play_terminal_bell = bool(int((user_values[4])))
terminal_bell = bool(int((user_values[4])))
except:
print("Invalid argument: " + str(argv[1]) + "\n")
printUsageInfo()
Expand All @@ -205,7 +205,6 @@ if __name__ == "__main__":
pomodorothread = PomodoroThread()
pomodorothread.start()


# commandline interface
while True:
command = get_input()
Expand Down Expand Up @@ -249,13 +248,12 @@ if __name__ == "__main__":
pass # Lock was not locked - exit anyway
print("omodoro is shutting down, please wait some seconds.")
exit(0)
#toggles the terminal bell option on or off
elif command == "t":
if play_terminal_bell == True:
play_terminal_bell = False
if terminal_bell == True:
terminal_bell = False
print("Terminal bell off")
elif play_terminal_bell == False:
play_terminal_bell = True
elif terminal_bell == False:
terminal_bell = True
print("Terminal bell on")
else:
print("Unknown command.\n$ ", end="")
4 changes: 2 additions & 2 deletions omodoro.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ short_break = 5
# This is the length of each long break in minutes
long_break = 15

# This is the option to play a terminal bell at the start of each pomodoro / break
play_terminal_bell = False
# This enables/disables the terminal bell to be played at the begin of each pomodoro/break
terminal_bell = 1

0 comments on commit 88ae369

Please sign in to comment.