Skip to content

Commit

Permalink
Merge pull request #147 from hovancik/feature/microbreak-notifications
Browse files Browse the repository at this point in the history
Edit Microbreak notification behaviour
  • Loading branch information
hovancik authored Oct 26, 2017
2 parents b0a5557 + c76db6c commit b554028
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- monitoring of system idle time for natural breaks (when user leaves and after return idle time is greater then break duration, *stretchly* will reset breaks)

### Changed
- microbreak notifications are 10 seconds before and can be disabled

## [0.11.0] - 2017-09-09
### Added
- option to not show break ideas
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Microbreaks and breaks can be customized:

- you can set break window to be fullscreen
- you can disable showing of break ideas
- you can disable showing of break notifications
- you can disable showing of break and microbreak notifications
- you can disable monitoring of system idle time for natural breaks (when user leaves and after return idle time is greater then break duration, *stretchly* will reset breaks)

<img src="https://raw.githubusercontent.com/hovancik/stretchly/master/stretchly-settings-website-3.png" height="340">
Expand All @@ -69,7 +69,7 @@ In config file, change `useIdeasFromSettings: false,` to `useIdeasFromSettings:
`breakIdeas` and `microbreakIdeas`.

#### Editing break/microbreak notification interval
In config file, change `breakNotificationInterval: 30000,` to whatever value you want. 30000 is 30 seconds.
In config file, change `breakNotificationInterval: 30000,` to whatever value you want. 30000 is 30 seconds. Sane goes for microbreak.

## Install [![Github All Releases](https://img.shields.io/github/downloads/hovancik/stretchly/total.svg)](https://github.com/hovancik/stretchly/releases/latest)

Expand Down
17 changes: 12 additions & 5 deletions app/breaksPlanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ class BreaksPlanner extends EventEmitter {
let interval = this.settings.get('microbreakInterval')
let breakNotification = this.settings.get('breakNotification')
let breakNotificationInterval = this.settings.get('breakNotificationInterval')
let microbreakNotification = this.settings.get('microbreakNotification')
let microbreakNotificationInterval = this.settings.get('microbreakNotificationInterval')
if (!shouldBreak && shouldMicrobreak) {
if (breakNotification) {
this.scheduler = new Scheduler(() => this.emit('startMicrobreakNotification'), interval - breakNotificationInterval, 'startMicrobreakNotification')
if (microbreakNotification) {
this.scheduler = new Scheduler(() => this.emit('startMicrobreakNotification'), interval - microbreakNotificationInterval, 'startMicrobreakNotification')
} else {
this.scheduler = new Scheduler(() => this.emit('startMicrobreak'), interval, 'startMicrobreak')
}
Expand All @@ -66,8 +68,8 @@ class BreaksPlanner extends EventEmitter {
this.scheduler = new Scheduler(() => this.emit('startBreak'), interval, 'startBreak')
}
} else {
if (breakNotification) {
this.scheduler = new Scheduler(() => this.emit('startMicrobreakNotification'), interval - breakNotificationInterval, 'startMicrobreakNotification')
if (microbreakNotification) {
this.scheduler = new Scheduler(() => this.emit('startMicrobreakNotification'), interval - microbreakNotificationInterval, 'startMicrobreakNotification')
} else {
this.scheduler = new Scheduler(() => this.emit('startMicrobreak'), interval, 'startMicrobreak')
}
Expand All @@ -78,7 +80,12 @@ class BreaksPlanner extends EventEmitter {

nextBreakAfterNotification (name) {
if (this.scheduler) this.scheduler.cancel()
let breakNotificationInterval = this.settings.get('breakNotificationInterval')
let breakNotificationInterval
if (name === 'startMicrobreak') {
breakNotificationInterval = this.settings.get('microbreakNotificationInterval')
} else {
breakNotificationInterval = this.settings.get('breakNotificationInterval')
}
this.scheduler = new Scheduler(() => this.emit(name), breakNotificationInterval, name)
this.scheduler.plan()
}
Expand Down
2 changes: 1 addition & 1 deletion app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function checkVersion () {
}

function startMicrobreakNotification () {
processWin.webContents.send('showNotification', `Microbreak in ${settings.get('breakNotificationInterval') / 1000} seconds...`)
processWin.webContents.send('showNotification', `Microbreak in ${settings.get('microbreakNotificationInterval') / 1000} seconds...`)
breakPlanner.nextBreakAfterNotification('startMicrobreak')
}

Expand Down
4 changes: 4 additions & 0 deletions app/settings3.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ <h2>miscellaneous</h2>
<input type="checkbox" value="breakNotification" class="enable">
notify before break starts
</div>
<div class="enabled">
<input type="checkbox" value="microbreakNotification" class="enable">
notify before microbreak starts
</div>
<div class="enabled">
<input type="checkbox" value="naturalBreaks" class="enable">
monitor system idle time for natural breaks
Expand Down
3 changes: 2 additions & 1 deletion app/settings3.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ ipcRenderer.on('renderSettings', (event, data) => {
})

document.getElementById('defaults').addEventListener('click', function (e) {
ipcRenderer.send('set-default-settings', ['fullscreen', 'ideas', 'breakNotification', 'naturalBreaks'])
ipcRenderer.send('set-default-settings', ['fullscreen', 'ideas',
'breakNotification', 'microbreakNotification', 'naturalBreaks'])
})
2 changes: 2 additions & 0 deletions app/utils/defaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ module.exports = {
breakDuration: 300000,
breakInterval: 2,
breakNotification: true,
microbreakNotification: true,
breakNotificationInterval: 30000,
microbreakNotificationInterval: 10000,
microbreak: true,
break: true,
microbreakStrictMode: false,
Expand Down
Binary file modified stretchly-settings-website-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b554028

Please sign in to comment.