Skip to content
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

MacOS Blurred Background #1520

Merged
merged 6 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Bengali, Catalan, Greek and Serbian translations
- it is not possible to close app during break that is in strict mode
- `logs` command line option to show location of logs
- advanced option to make break windows' background blurred

### Fixed
- error when end break shortcut is not set
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ In the preferences file, change `mainColor` to whatever color you like.
To show the Welcome window again on the next start, change `"isFirstRun"` to `true`.

#### Theme transparency [![Contributor Preferences](https://img.shields.io/badge/Contributor_Preferences-✔-success)](#contributor-preferences)
To specify how solid the break window should be when Theme transparency is enabled, set the value of `opacity` from `0` to `1` (which is in turn 0 to 100%).
To specify how solid the break window should be when Theme transparency is enabled, set the value of `opacity` from `0` to `1` (which is in turn 0 to 100%). If you want the break window to have a blurred background, set the value of `blurredBackground` to `true`.

#### Break window size [![Contributor Preferences](https://img.shields.io/badge/Contributor_Preferences-✔-success)](#contributor-preferences)
To specify the size of the break window, set the value of `breakWindowHeight` and `breakWindowWidth` from `0` to `0.99` (which is in turn 0 to 99% of the size of the screen). Don't set 100% as that's fullscreen.
Expand Down
20 changes: 19 additions & 1 deletion app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,22 @@ function startBreakNotification () {
updateTray()
}

function getBlurredBackgroundWindowOptions () {
if (!settings.get('blurredBackground')) {
return {}
}

switch (process.platform) {
case 'darwin':
return {
vibrancy: 'hud',
visualEffectState: 'active'
}
default:
return {}
}
}

function startMicrobreak () {
// don't start another break if break running
if (microbreakWins) {
Expand Down Expand Up @@ -704,6 +720,7 @@ function startMicrobreak () {
show: false,
backgroundThrottling: false,
transparent: true,
...getBlurredBackgroundWindowOptions(),
backgroundColor: calculateBackgroundColor(settings.get('miniBreakColor')),
skipTaskbar: !showBreaksAsRegularWindows,
focusable: showBreaksAsRegularWindows,
Expand Down Expand Up @@ -852,6 +869,7 @@ function startBreak () {
show: false,
backgroundThrottling: false,
transparent: true,
...getBlurredBackgroundWindowOptions(),
backgroundColor: calculateBackgroundColor(settings.get('mainColor')),
skipTaskbar: !showBreaksAsRegularWindows,
focusable: showBreaksAsRegularWindows,
Expand Down Expand Up @@ -1064,7 +1082,7 @@ function calculateBackgroundColor (color) {
if (settings.get('transparentMode')) {
opacityMultiplier = settings.get('opacity')
}
return color + Math.round(opacityMultiplier * 255).toString(16)
return color + Math.round(opacityMultiplier * 255).toString(16).padStart(2, '0')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if opacity is zero, the output will be "#ffffff0", which is an invalid color code.
The opacity part should always have exactly 2 digits.

}

function loadIdeas () {
Expand Down
1 change: 1 addition & 0 deletions app/utils/defaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
mainColor: '#478484',
miniBreakColor: '#478484',
transparentMode: false,
blurredBackground: false,
opacity: 0.9,
audio: 'crystal-glass',
miniBreakAudio: 'crystal-glass',
Expand Down