Skip to content

Commit

Permalink
More shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
hovancik committed Aug 4, 2023
1 parent 36e1981 commit 7224233
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- both left and right click on tray opens menu (Windows)
- double click on tray opens Preferences (Windows)
- adds Vietnamese translations
- reset breaks shortcut (advanced option)
- skip to the next break shortcut (advanced option)

## Changed
- updated many translations
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,18 @@ In the preferences file, set `pauseBreaksToggleShortcut` to your preferred value

If you'd like to disable the shortcut, set value to empty string `""`. That's the default value as well.

#### Skip to the next Break Shortcut

In the preferences file, set `skipToNextScheduledBreakShortcut`, `skipToNextMiniBreakShortcut`, `skipToNextLongBreakShortcut` to your preferred value. We do not validate this input, so please check [Electron's documentation](https://www.electronjs.org/docs/api/accelerator) for available values for key and modifier. When a given accelerator is already taken by other applications, this call will silently fail. This behavior is intended by operating systems, since they don't want applications to fight for global shortcuts.

If you'd like to disable the shortcut, set value to empty string `""`. That's the default value as well.

#### Reset Breaks Shortcut

In the preferences file, set `resetBreaksShortcut` to your preferred value. We do not validate this input, so please check [Electron's documentation](https://www.electronjs.org/docs/api/accelerator) for available values for key and modifier. When a given accelerator is already taken by other applications, this call will silently fail. This behavior is intended by operating systems, since they don't want applications to fight for global shortcuts.

If you'd like to disable the shortcut, set value to empty string `""`. That's the default value as well.

#### Appearance [![Contributor Preferences](https://img.shields.io/badge/Contributor_Preferences-✔-success)](#contributor-preferences)
In the preferences file, change `themeSource: 'system'` to either `'light'` or `'dark'` to always use the specified theme.

Expand Down
52 changes: 52 additions & 0 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,58 @@ function initialize (isAppStart = true) {
log.info(`Stretchly: pauseBreaksToggleShortcut registration successful (${settings.get('pauseBreaksToggleShortcut')})`)
}
}
if (settings.get('skipToNextScheduledBreakShortcut') !== '') {
const skipToNextScheduledBreakShortcut = globalShortcut.register(settings.get('skipToNextScheduledBreakShortcut'), () => {
log.info('Stretchly: skipping to next scheduled Break by shortcut')
if (breakPlanner._scheduledBreakType === 'break') {
skipToBreak()
} else if (breakPlanner._scheduledBreakType === 'microbreak') {
skipToMicrobreak()
}
})

if (!skipToNextScheduledBreakShortcut) {
log.warn('Stretchly: skipToNextScheduledBreakShortcut registration failed')
} else {
log.info(`Stretchly: skipToNextScheduledBreakShortcut registration successful (${settings.get('skipToNextScheduledBreakShortcut')})`)
}
}
if (settings.get('skipToNextMiniBreakShortcut') !== '') {
const skipToNextMiniBreakShortcut = globalShortcut.register(settings.get('skipToNextMiniBreakShortcut'), () => {
log.info('Stretchly: skipping to next Mini Break by shortcut')
skipToMicrobreak()
})

if (!skipToNextMiniBreakShortcut) {
log.warn('Stretchly: skipToNextMiniBreakShortcut registration failed')
} else {
log.info(`Stretchly: skipToNextMiniBreakShortcut registration successful (${settings.get('skipToNextMiniBreakShortcut')})`)
}
}
if (settings.get('skipToNextLongBreakShortcut') !== '') {
const skipToNextLongBreakShortcut = globalShortcut.register(settings.get('skipToNextLongBreakShortcut'), () => {
log.info('Stretchly: skipping to next Long Break by shortcut')
skipToBreak()
})

if (!skipToNextLongBreakShortcut) {
log.warn('Stretchly: skipToNextLongBreakShortcut registration failed')
} else {
log.info(`Stretchly: skipToNextLongBreakShortcut registration successful (${settings.get('skipToNextLongBreakShortcut')})`)
}
}
if (settings.get('resetBreaksShortcut') !== '') {
const resetBreaksShortcut = globalShortcut.register(settings.get('resetBreaksShortcut'), () => {
log.info('Stretchly: resetting breaks by shortcut')
resetBreaks()
})

if (!resetBreaksShortcut) {
log.warn('Stretchly: resetBreaksShortcut registration failed')
} else {
log.info(`Stretchly: resetBreaksShortcut registration successful (${settings.get('resetBreaksShortcut')})`)
}
}
loadIdeas()
updateTray()
}
Expand Down
6 changes: 5 additions & 1 deletion app/utils/defaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,9 @@ module.exports = {
screen: 'primary',
timeToBreakInTray: false,
currentTimeInBreaks: false,
showTrayIcon: true
showTrayIcon: true,
skipToNextScheduledBreakShortcut: '',
skipToNextMiniBreakShortcut: '',
skipToNextLongBreakShortcut: '',
resetBreaksShortcut: ''
}

0 comments on commit 7224233

Please sign in to comment.