Match Window Controls side to OS settings when using Custom Window Frame on Linux

There was some discussion regarding the Window Controls on issue #142 but the end focus was the implementation of the Right-hand hamburger menu. I would like to see a way to match my OS’s settings regarding where the window controls buttons should be placed when using the Custom Window Frame. At the very least, I’d like to see a setting where I can move those buttons to either side.
Some alternatives/solutions could be:

  • New setting Default Window Controls and Right-hand Menu.
  • When selecting Custom Window Frame and Right-hand Menu have a greyed/invisible setting become available that lets me choose the side where the window controls should be placed.
  • Automatically match the side where the window controls should be based on my OS settings when Custom Window Frame and Right-hand Menu is used

(Originally posted by fcastilloec on GitHub.)

Hey! This seems like a good enhancement - do you know if there’s an API / shell command for reading the relevant OS setting?


(Originally posted by bengotow on GitHub.)

1 Like

Yes, there is, using dconf dconf: dconf Reference Manual
By using the following command dconf read /org/gnome/desktop/wm/preferences/button-layout you will get the user preferences which can be something likes this:

:minimize,maximize,close

where the : specifies if the buttons are placed to the left or to the right of the window. In the previous example, they’re on the right side of the window. The rest is pretty self-explanatory.
The only caveat is that the dconf read command will not output anything if the default setting is in place (the default setting for Ubuntu 18.04 is the above example), only if the user has modified them. The command dconf read -d should display the deafult but on my system that’s not working and I found this issue ansible/ansible#35659 (comment) that says the -d option doesn’t work either.

You can also use the variable $XDG_CURRENT_DESKTOP which will tell you if you’re using Gnome (or any other one) and then use the defaults for that, and just compile a list of the defaults for other (i.e. KDE, XFCE, LXQT, GNOME, Unity, etc.)

Hopefully this info was helpful and it was an starting point. I’ll see if I can check how other software handle this, and if I find anything interesting I’ll report back.


(Originally posted by fcastilloec on GitHub.)

Is there any news regarding this topic? It will be very useful to integrate my Material Adapted theme for Mailspring email client into Adapta GTK Theme for Gnome 3.x

Thanks!


(Originally posted by ferlanero on GitHub.)

It’s been a while since I posted here but there’s a better way to reliably get the button layout for any Linux OS: gsettings get org.gnome.desktop.wm.preferences button-layout
I’ve tested it on many different distros and it works in all.

These are the strings that are displayed: minimize, maximize, close and appmenu; also : for separating left and right. Not all of them are used by all distros, except for close which from my experience it’s always shown. The only rule I know is that if appmenu is not shown, it should be displayed opposite to close, but I’m not 100% sure about that.

I’ll try to see if I can submit a PR for this, but if anybody else can take a look at this, that’ll be great


(Originally posted by fcastilloec on GitHub.)

I started to look at the code, but I’m way over my head here. Here’s what’s I’ve found out so other people can take a look and try to implement this:
I did find that app/src/sheet-toolbar.tsx is responsible for deciding where to place the buttons. I think an additional variable could be added to decide for Linux and its button placement. I just don’t know how/where the config options are read/written so that the gsettings command can be executed and then pass this variable to app/src/sheet-toolbar.tsx, telling it where to put the buttons.
Also, #L157-159 can take into consideration the order of the buttons passed bygsettings if wanted, and even render only the buttons specified by the distro outputted by the same gsettings command. Some distros only like to have a close button and nothing else.


(Originally posted by fcastilloec on GitHub.)

I just looked into this and it looks more complicated than I expected:

  1. There is some behavioure based on the reading direction, that needs to be based into account (sheet-toolbar#L193)
  2. I can’t exactly figure out how ToolbarWindowControls and ToolbarMenuControl are placed related to each other.
  3. There is some CSS classes in play (workspace.less#L65)

Therefore, I am not going to start on this for now.

Do you want to tag this as #hard-mode or #intermediate then?

2 Likes