-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use pymodoro as app name in notifications (+ more cleanup) #54
Open
dkasak
wants to merge
31
commits into
dattanchu:master
Choose a base branch
from
dkasak:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Prior to this commit, there was still some inconsistency in how XDG Base Directory was handled. For instance, hooks were still being loaded from the old-style config directory. This commit unifies the handling of directory locations in the method `init_dirs`. Directories are not hardcoded, respecting the XDG_* environment variables, only falling back to the defaults if they are not set. Any missing directories are created. Any tildes in the paths are immediately expanded using `path.expanduser`. For backward compatibility, the implementation prefers the old-style directory if it exists, but emits a deprecation warning to the user on stderr. All methods should now use the `Config` instance variables `_config_dir` and `_cache_dir` for the config and cache directories (respectively), instead of calculating those paths themselves.
Instead of specifying defaults by directly assigning them to Pymodoro's internal state, a PymodoroConfigParser (a derived class of RawConfigParser) instance is constructed containing the defaults. A separate function then takes such an instance and assigns its settings to the internal state. This allows us to easily merge user settings from the config file over the defaults. It also obviates the need for a separate function for creating the config file, because we can simply use `PymodoroConfigParser.write`. In addition, it provides the following benefits: - Lays groundwork for supporting multiple configuration files of increasing priority (e.g. system-wide, followed by user configuration), if wanted. - The config parser now tolerates missing options in the config file. - Self-documenting: when the config file is missing, it will get created with all available settings populated with their default values. - Hooks were made configurable. - Allows all sounds used by Pymodoro to be customized via the config file.
Command-line argument parsing has been moved out of the Config class and into main, as part of this change. Instead, the Config class now receives parsed arguments.
Previously the state calculation algorithm worked by separately determining the current state and then predicting (based on the current state and parameters such as pomodoro and break lengths) what the next state will be, after the next tick elapses. Unfortunately this method is unable to predict user actions and will therefore never predict that the next state would be the active state (because it can never predict a user clicking to start a pomodoro). This left start hooks completely broken. Fortunately, this kind of prediction is entirely unnecessary. The new algorithm works as follows: 1. Initialize current state to IDLE_STATE. 2. Loop: a. Calculate the next state by comparing the mtime of the cache file with the current time. *Do not* assign this state as the current state yet. b. Run events (notifications, hooks) based on the difference between the current and next states. c. Assume the next state as the current state. d. Print output and play tick sounds. e. Wait for the next tick. f. Go back to a.
This is a hook which fires whenever a pomodoro is ended, regardless of whether it because the pomodoro completed naturally or it was terminated by the user. A possible use case is to be able to pause system notifications when the pomodoro starts and turn them back on when it is no longer active.
There's no reason to specify default paths for the hooks in the config file since the hooks are not created automatically. Furthermore, since the only constraint on hooks is that they should be executable files, there's no reason to suggest that they should be Python modules (as was previously the case due to the default filenames having the .py extension).
- Reflect changes in location of the config and session files (due to following XDG Base Directory). - Document hooks. - Fix typos. - Wrap paragraphs.
The names reflect the config option names, i.e. pomodoro_{start,end,complete}.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.