Skip to content

Commit

Permalink
Updated to match version 16 capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
aunetx committed Jul 1, 2021
1 parent b47ff2a commit ba09307
Show file tree
Hide file tree
Showing 18 changed files with 1,029 additions and 194 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/build/
/pkg/
*~
*~
.idea/
.ts-for-gir.js
.vscode/
jsconfig.json
@types/
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ vm_test: build
cp -r build/* $(SHARED_VM)/blur_my_shell/blur-my-shell@aunetx/


vm_pkg: build_pkg
cp pkg/[email protected] $(SHARED_VM)/blur_my_shell/[email protected]


install: build
rm -rf $(HOME)/.local/share/gnome-shell/extensions/blur-my-shell@aunetx
mkdir -p $(HOME)/.local/share/gnome-shell/extensions/blur-my-shell@aunetx
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

A GNOME Shell extension that adds a blur look to different parts of the GNOME Shell, including the top panel, dash and overview.

![Capture d’écran de 2021-04-20 15-00-18](https://user-images.githubusercontent.com/31563930/115416485-1cad1a80-a1f8-11eb-844e-cab11d3b863e.png)
![Capture d’écran de 2021-04-20 15-00-13](https://user-images.githubusercontent.com/31563930/115400536-af928880-a1e9-11eb-8ac2-44dcb7718285.png)

[<img src="https://github.com/aunetx/files_utils/raw/master/get_it_on_gnome_extensions.png" height="100">](https://extensions.gnome.org/extension/3193/blur-my-shell/)

You can now select which part you want to blur, wether or not you want overview animation and there is an option that reduces a lot the artifacts :)
## Screenshots

*Note: this extension contains a lot of bugs. If you find one (that is not already reported), please create an issue!*
*Blurred Overview:*
![Blurred Overview](https://user-images.githubusercontent.com/38633812/116588850-779beb80-a935-11eb-8f2f-81bcd46fe694.png)
*Blurred Top Panel:*
![Blurred Top Panel](https://user-images.githubusercontent.com/38633812/116588885-81bdea00-a935-11eb-9c80-c97716369b7c.png)

## Known bugs

### Note

This extension can be buggy, as the gnome-shell's blur implementation is quite flawed in some ways.

However, selecting *no artifacts* in the settings allows the blur to regenerate itself a lot better, at the expense of CPU time (adds ~3% CPU usage for the gnome-shell process in my old Thinkpad).
To entirely remove artifacts from the top panel, you can use static blur with the appropriate switch, **use static blur**.

Moreover, if you don't use static blur, selecting *no artifacts* in the settings allows the blur to regenerate itself a lot better, at the expense of CPU time (but cannot currently tell the difference, less than 0.5% CPU on my middle-range i5)

Selecting another profile might be enought (especially if you have disabled animations), feel free to test!
Selecting another profile might be enough (especially if you have disabled animations and/or windows borders), feel free to test!

### List of bugs

Expand All @@ -44,10 +46,10 @@ And restart GNOME Shell if needed.

### Versions support

The current extension supports those GNOME Shell versions:
The current extension supports these GNOME Shell versions:

- 3.36
- 3.38
- 3.36

## License

Expand Down
19 changes: 19 additions & 0 deletions src/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,25 @@ var Connections = class Connections {
this.process_connection(actor, id);
}

disconnect_all_for(actor) {
actor_connections = this.buffer.filter((infos) => {
infos.actor == actor
});

actor_connections.forEach((connection) => {
// disconnect
try {
connection.actor.disconnect(connection.id)
} catch (e) {
this._log(`error removing connection: ${e}; continuing`)
}

// remove from buffer
let index = this.buffer.indexOf(connection);
this.buffer.splice(index, 1);
})
}

disconnect_all() {
this.buffer.forEach((connection) => {
try {
Expand Down
13 changes: 8 additions & 5 deletions src/dash.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

const St = imports.gi.St;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
const { St, Shell, Meta } = imports.gi;
const Main = imports.ui.main;

const default_sigma = 30;
Expand All @@ -15,9 +13,12 @@ var DashBlur = class DashBlur {

enable() {
this._log("blurring dash");
this.update()
}

update() {
if (Main.overview.dash.constructor.name == "Dash") {
Main.overview.dash.get_child_at_index(0).style = "background-color:rgba(0,0,0,0.0)";
Main.overview.dash.get_child_at_index(0).style = "background-color:rgba(0,0,0," + prefs.DASH_OPACITY.get() + ")";
}
}

Expand All @@ -27,12 +28,14 @@ var DashBlur = class DashBlur {
if (Main.overview.dash.constructor.name == "Dash") {
if (!Main.screenShield.locked) {
try {
Main.overview.dash.get_child_at_index(0).style = none;
Main.overview.dash.get_child_at_index(0).style = null;
} catch (e) {
this._log(e)
}
}
}

this.connections.disconnect_all();
}

_log(str) {
Expand Down
6 changes: 3 additions & 3 deletions src/dash_to_dock.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict';

const St = imports.gi.St;
const GLib = imports.gi.GLib;
const Shell = imports.gi.Shell;
const { St, Shell, GLib } = imports.gi;
const Main = imports.ui.main;
const Signals = imports.signals;

Expand Down Expand Up @@ -192,9 +190,11 @@ var DashBlur = class DashBlur {
disable() {
this._log("removing blur from dashes");


this.emit('remove-dashes', true);

this.dashes = [];
this.connections.disconnect_all();
}

show() {
Expand Down
79 changes: 40 additions & 39 deletions src/extension.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const St = imports.gi.St;
const Shell = imports.gi.Shell;
const { St, Shell } = imports.gi;
const Main = imports.ui.main;

const Me = imports.misc.extensionUtils.getCurrentExtension();
Expand All @@ -16,41 +15,41 @@ const DashToDock = Me.imports.dash_to_dock;
const Lockscreen = Me.imports.lockscreen;

class Extension {
constructor() {
this._connections = new Connections.Connections;
this._prefs = new Settings.Prefs;

this._panel_blur = new Panel.PanelBlur(this._connections);
this._dash_blur = new Dash.DashBlur(this._connections);
this._dash_to_dock_blur = new DashToDock.DashBlur(this._connections);
this._overview_blur = new Overview.OverviewBlur(this._connections);
this._lockscreen_blur = new Lockscreen.LockscreenBlur(this._connections);
}
constructor() { }

enable() {
this._log("enabling extension...");
this._connections = [];
this._prefs = new Settings.Prefs;

this._panel_blur = new Panel.PanelBlur(new Connections.Connections);
this._dash_blur = new Dash.DashBlur(new Connections.Connections);
this._dash_to_dock_blur = new DashToDock.DashBlur(new Connections.Connections);
this._overview_blur = new Overview.OverviewBlur(new Connections.Connections);
this._lockscreen_blur = new Lockscreen.LockscreenBlur(new Connections.Connections);

this._connections.push(this._panel_blur.connections, this._dash_blur.connections,
this._dash_to_dock_blur.connections, this._overview_blur.connections, this._lockscreen_blur.connections);

this._connect_to_settings();

if (this._prefs.BLUR_PANEL.get()) {
this._panel_blur.enable()
this._panel_blur.enable();
}
if (this._prefs.BLUR_DASH.get()) {
this._dash_blur.enable();
this._dash_to_dock_blur.enable();
}
if (this._prefs.BLUR_OVERVIEW.get()) {
this._overview_blur.enable()
this._overview_blur.enable();
}
if (this._prefs.BLUR_LOCKSCREEN.get()) {
this._lockscreen_blur.enable()
this._lockscreen_blur.enable();
}

this._update_sigma();
this._update_brightness();

this._connect_to_overview();

this._log("extension enabled.");
}

Expand All @@ -64,17 +63,24 @@ class Extension {
this._lockscreen_blur.disable();

this._disconnect_settings();
this._connections.disconnect_all();

// in theory, this shouldn't be needed if we switch to making modules responsible for disconnecting their own
// signals. For now, I will leave this small bit of code in. Calling disable on all modules has already
// done the same thing
this._connections.forEach((connections) => {
connections.disconnect_all();
})
this._connections = [];

this._log("extension disabled.");
}

_connect_to_settings() {
this._prefs.SIGMA.changed(() => {
this._update_sigma()
this._update_sigma();
});
this._prefs.BRIGHTNESS.changed(() => {
this._update_brightness()
this._update_brightness();
});

this._prefs.BLUR_DASH.changed(() => {
Expand All @@ -88,25 +94,31 @@ class Extension {
});
this._prefs.BLUR_PANEL.changed(() => {
if (this._prefs.BLUR_PANEL.get()) {
this._panel_blur.enable()
this._panel_blur.enable();
} else {
this._panel_blur.disable()
this._panel_blur.disable();
}
});
this._prefs.BLUR_OVERVIEW.changed(() => {
if (this._prefs.BLUR_OVERVIEW.get()) {
this._overview_blur.enable()
this._overview_blur.enable();
} else {
this._overview_blur.disable()
this._overview_blur.disable();
}
});
this._prefs.BLUR_LOCKSCREEN.changed(() => {
if (this._prefs.BLUR_LOCKSCREEN.get()) {
this._lockscreen_blur.enable()
this._lockscreen_blur.enable();
} else {
this._lockscreen_blur.disable()
this._lockscreen_blur.disable();
}
});
this._prefs.DASH_OPACITY.changed(() => {
this._dash_blur.update();
});
this._prefs.STATIC_BLUR.changed(() => {
this._panel_blur.change_blur_type()
});
}

_disconnect_settings() {
Expand All @@ -132,24 +144,13 @@ class Extension {
this._lockscreen_blur.set_brightness(brightness);
}

_connect_to_overview() {
this._connections.connect(Main.overview, 'showing', () => {
this._panel_blur.hide();
this._dash_to_dock_blur.hide();
});
this._connections.connect(Main.overview, 'hidden', () => {
this._panel_blur.show();
this._dash_to_dock_blur.show();
});
}

_log(str) {
log(`[Blur my Shell] ${str}`)
}
};
}


// Called on gnome-shell loading, even if extension is deactivated
function init() {
return new Extension();
}
}
12 changes: 5 additions & 7 deletions src/lockscreen.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
'use strict';

const St = imports.gi.St;
const Shell = imports.gi.Shell;
const { St, Shell } = imports.gi;
const Main = imports.ui.main;
const Background = imports.ui.background;

const themeContext = St.ThemeContext.get_for_stage(global.stage);

let shell_version = imports.misc.config.PACKAGE_VERSION.split('.');

function verify_function_to_use() {
Expand Down Expand Up @@ -49,7 +46,7 @@ var LockscreenBlur = class LockscreenBlur {
for (const widget of this._backgroundGroup.get_children()) {
widget.get_effect('blur').set({
brightness: brightness,
sigma: sigma * themeContext.scale_factor,
sigma: sigma,
});
}
}
Expand All @@ -76,12 +73,12 @@ var LockscreenBlur = class LockscreenBlur {

let effect = new Shell.BlurEffect({
brightness: brightness,
sigma: sigma * themeContext.scale_factor,
sigma: sigma,
mode: 0
});

this._scaleChangedId = themeContext.connect('notify::scale-factor', () => {
effect.sigma = sigma * themeContext.scale_factor;
effect.sigma = sigma;
});

widget.add_effect(effect);
Expand All @@ -105,6 +102,7 @@ var LockscreenBlur = class LockscreenBlur {
else
imports.ui.unlockDialog.UnlockDialog.prototype._createBackground = original_createBackground_old;

this.connections.disconnect_all();
}

_log(str) {
Expand Down
Loading

0 comments on commit ba09307

Please sign in to comment.