velitasali / gtktitlebar

GNOME extension that removes title bar for non-GTK software (when maximized)
https://extensions.gnome.org/extension/1732/gtk-title-bar/
GNU General Public License v3.0
184 stars 16 forks source link

Blacklist/Whitelist features #2

Open biloky opened 5 years ago

biloky commented 5 years ago

Hi, thanks for this much needed extension :)

Is it possible to implement a blacklist and whitelist option?

Blacklist: list of windows that this extension will not touch (ie. Firefox w/ titlebar hidden) Whitelist: list of windows that will always have titlebars hidden (not only when maximized)

I use Firefox as my default browser and has configured it to hide its titlebar. With this extension, unmaximizing Firefox will show its titlebar, which should not be the case.

Thanks :)

velitasali commented 5 years ago

Hi @biloky,

Good suggestion. I will try to add this in my free time.

Thanks.

jacksongoode commented 3 years ago

This would be a top feature in-case of specific apps breaking!

neo-sam commented 2 years ago

@biloky temporarily solve method:

vi "~/.local/share/applications/free-window.desktop":

[Desktop Entry]
Name=Free Window
Exec=xprop -f _MOTIF_WM_HINTS 32c -set _MOTIF_WM_HINTS '0x2, 0x0, 0x1, 0x0, 0x0'
Type=Application

another .desktop file within _MOTIF_WM_HINTS '0x2, 0x0, 0x2, 0x0, 0x0' as opposite

manually run it from start menu each time, click window to apply

yusanshi commented 2 years ago

Here is another quick and dirty solution for whitelist mode:

diff --git a/window.js b/window.js
index e4705d5..fb9191f 100644
--- a/window.js
+++ b/window.js
@@ -188,6 +188,26 @@ var MetaWindow = GObject.registerClass(
     }

     syncDecorations() {
+      // Run in the whitelist mode: only work for the window
+      // if any in the whitelist is a substring of the window name
+      const WHITELIST = ['Oracle VM VirtualBox'];
+
+      const result = GLib.spawn_command_line_sync(`xprop -id ${this.xid}`);
+      const string = Bytes.toString(result[1]);
+      let windowName;
+      try {
+        windowName = (string.match(/WM_NAME\(STRING\) = "(.+)"/) ||
+          string.match(/WM_NAME\(UTF8_STRING\) = "(.+)"/))[1];
+      } catch (error) {
+        windowName = 'unknown';
+      }
+      if (!WHITELIST.some((e) => windowName.includes(e))) {
+        console.log(`"${windowName}" does not match the whitelist, skipped`);
+        return;
+      } else {
+        console.log(`"${windowName}" matches the whitelist, continue`);
+      }
+
       if (this.hidingStrategyPreference) {
         this.decorations.hide()
       } else {

Result:

Oct 19 21:35:32 yu-ubuntu gnome-shell[2940]: "window.js - gtktitlebar@velitasali.github.io - Visual Studio Code" does not match the whitelist, skipped
Oct 19 21:35:38 yu-ubuntu gnome-shell[2940]: "yu@yu-ubuntu: ~" does not match the whitelist, skipped
Oct 19 21:35:48 yu-ubuntu gnome-shell[2940]: "window.js - gtktitlebar@velitasali.github.io - Visual Studio Code" does not match the whitelist, skipped
Oct 19 21:35:49 yu-ubuntu gnome-shell[2940]: "String.prototype.match() - JavaScript | MDN - Google Chrome" does not match the whitelist, skipped
Oct 19 21:35:50 yu-ubuntu gnome-shell[2940]: "Oracle VM VirtualBox Manager" matches whitelist, continue
Oct 19 21:35:52 yu-ubuntu gnome-shell[2940]: "VirtualBoxVM" does not match the whitelist, skipped
Oct 19 21:35:52 yu-ubuntu gnome-shell[2940]: "VirtualBoxVM" does not match the whitelist, skipped
Oct 19 21:35:52 yu-ubuntu gnome-shell[2940]: "VirtualBoxVM" does not match the whitelist, skipped
Oct 19 21:35:52 yu-ubuntu gnome-shell[2940]: "VirtualBoxVM" does not match the whitelist, skipped
Oct 19 21:35:53 yu-ubuntu gnome-shell[2940]: "Windows 10 LTSC [Starting] - Oracle VM VirtualBox" matches whitelist, continue
Oct 19 21:35:53 yu-ubuntu gnome-shell[2940]: "Windows 10 LTSC [Starting] - Oracle VM VirtualBox" matches whitelist, continue
Oct 19 21:35:53 yu-ubuntu gnome-shell[2940]: "Windows 10 LTSC [Starting] - Oracle VM VirtualBox" matches whitelist, continue
Oct 19 21:35:57 yu-ubuntu gnome-shell[2940]: "String.prototype.match() - JavaScript | MDN - Google Chrome" does not match the whitelist, skipped