fuhsjr00 / bug.n

Tiling Window Manager for Windows
GNU General Public License v3.0
3.36k stars 214 forks source link

[Question] config rules not working with Electron/Chromium Apps? All have same class #289

Closed jsjoeio closed 2 years ago

jsjoeio commented 2 years ago

First, thanks so much for making this! I'm still understanding how it all works but I'm having trouble setting my config rules with regard to which views/tags applications should move to.

Here is my Config.ini:

; bug.n - tiling window management
; @version 9.0.2

Monitor_#1_aView_#1=2
View_#1_#6_layoutMFact=0.500000
View_#1_#6_layoutMY=2
View_#1_#8_layout_#1=2
View_#1_#8_layoutMFact=0.700000

; Config rules
Config_viewNames=1;2;3;4;5;6

; Application Rules
;; Browser on View 1
Config_rule=Chrome_WidgetWin_1;Brave;;1;1;1;0;1;0;maximize

;; Editor and Chrome on View 2
Config_rule=Chrome_WidgetWin_1;Code Web;;1;1;2;0;1;0;
Config_rule=Chrome_WidgetWin_1;Google Chrome;;1;1;2;0;1;0;

;; Obsidian on View 4
Config_rule=Chrome_WidgetWin_1;Obsidian;;1;1;8;0;1;0;maximize

;; Spotify on View 5
Config_rule=Chrome_WidgetWin_0;Spotify;;1;1;16;0;1;0;maximize

;; File Explorer on View 6
Config_rule=CabinetWClass;bug.n-9.0.2;;1;1;32;0;1;0;maximize

This unfortunately doesn't work and I think it's because all these apps are based on Chromium (probably built with Electron) and so the class name for a lot of them is Chrome_WidgetWin_1. That means they all end up in view/tag 1.

What's the proper way to do this to achieve what I want? (i.e. Brave in View 1 and Obisidan in View 4)

Current Process

The way I tried to do it:

  1. Open Brave Browser in View/Tag 1
  2. Hit Win+i to get information
  3. Copy to clipbard
  4. Go to View/Tag 3
  5. Hit Win+ctrl+e to edit Config.ini in Notepad
  6. Paste information and delete everything but Config_rule
  7. Restart bug.n

Notes

If someone can help me, I would be more than happy to make a blog post, YouTube video or contribute to the Wiki so this knowledge lives on!

joten commented 2 years ago

I think you were almost there. The process and the tags are correct, but the parts of a rule, which identify a window (class and title) are based on regular expressions, therefor Google Chrome would need to be an exact match and should be e.g. .*Google Chrome, therewith including titles, which also have the name of the website in them. The same for the other windows.

You may post all rules, which you get by pressing WinI here. The rules, given by WinI normally can only be used as a hint and most often need to be altered by replacing some parts of the string with .*.

jsjoeio commented 2 years ago

Ahhhh! Okay, I saw regular expression mentioned in the docs but wasn't sure how it was used. That makes way more sense because the title of the window is something like [Question] config rules not working with Electron/Chromium Apps? All have same class · Issue #289 · fuhsjr00/bug.n - Brave -> and we want to tell bug.n to match everything up to the Application name in this case, Brave.

Thanks for your help! I'm working on a blog post and will share afterwards.

Notes so far: image

I'll close this as well. Thanks for the quick reply.

P.S. I hope it's okay to ask questions via GitHub issues. If there's a better place to do this in the future, please let me know!

jsjoeio commented 2 years ago

Okay so the regular expressions mostly fixed it except for these two:

Config_rule=Chrome_WidgetWin_1;.*Brave;;1;1;1;0;1;0;maximize

Config_rule=Chrome_WidgetWin_1;.*Code Web;;1;1;2;0;1;0;

For some reason, bug.n thinks they're the same and puts them both in View/Tag 1.

More information about each:

Brave:

ID: 0x3047c
class:  Chrome_WidgetWin_1
title:  [Question] config rules not working with Electron/Chromium Apps? All have same class · Issue #289 · fuhsjr00/bug.n - Brave
process:    brave.exe [17508]
style:  0x17CF0000
metrics:    x: -16, y: -16, width: 3872, height: 2192
tags:   1

Config_rule=Chrome_WidgetWin_1;[Question] config rules not working with Electron/Chromium Apps? All have same class · Issue #289 · fuhsjr00/bug.n - Brave;;1;1;1;0;1;0;maximize

Code Web:

ID: 0x30782
class:  Chrome_WidgetWin_1
title:  joe-test-workspace — Code Web
process:    chrome.exe [21768]
style:  0x16CF0000
metrics:    x: -14, y: 0, width: 3867, height: 2173
tags:   2

Config_rule=Chrome_WidgetWin_1;joe-test-workspace — Code Web;;1;1;2;0;1;0;

Full config:

; bug.n - tiling window management
; @version 9.0.2

Monitor_#1_aView_#1=2
View_#1_#6_layoutMFact=0.500000
View_#1_#6_layoutMY=2
View_#1_#8_layout_#1=2
View_#1_#8_layoutMFact=0.700000

; Testing window configuration
Config_showTaskBar=0
Config_barTransparency=0
Config_verticalBarPos=tray

; Config rules
Config_viewNames=1;2;3;4;5;6;7;8;9

; Application Rules
;; Browser on View 1
Config_rule=Chrome_WidgetWin_1;.*Brave;;1;1;1;0;1;0;maximize

;; Editor and Chrome on View 2
Config_rule=Chrome_WidgetWin_1;.*Web;;1;1;2;0;1;0;

;; Obsidian on View 3
Config_rule=Chrome_WidgetWin_1;.*Obsidian;;1;1;4;0;1;0;maximize

;; Spotify on View 5

Config_rule=Chrome_WidgetWin_0;.*Spotify;;1;1;16;0;1;0;maximize

;; File Explorer on View 6
Config_rule=CabinetWClass;.*File Explorer;;1;1;32;0;1;0;maximize

;; Show Chrome on View 7 
Config_rule=Chrome_WidgetWin_1;.*Google Chrome;;1;1;64;0;1;0;

;; Show OBS on View 8
Config_rule=Qt5152QWindowIcon;OBS.*;;0;;;;;1;

; Hotkeys
Config_hotkey=#^Left::
Config_hotkey=#^Right::
joten commented 2 years ago

The rule used should set Brave to view 1; did it get maximized?

Did Config_rule=Chrome_WidgetWin_1;.*Web;;1;1;2;0;1;0; from your full config work neither? I am not sure, if bug.n can digest the special character "—" in the windows title of Code Web.

jsjoeio commented 2 years ago

Weird. I think after adding a fix for the chrome apps, it's working now.

Demo

https://www.loom.com/share/3a8d6509d9ea4872a0511955f2dc205b