How do I move window buttons from left to right using command line or by editing a specific file?

I know that Ubuntu has a file hidden somewhere deep inside it that holds the old metacity values for changing the position of the menu buttons. My question is how can I do this WITHOUT Ubuntu Tweak in Ubuntu Classic?

"Why not use the thing that's already done?"

  • That thing was written by finding this file once then making a mental note of it to create a GUI to solve the problem, which is all fine and dandy.
  • I want to learn where this stuff is for myself because I like knowing how to do things from the command line. (Also, come on, how many times have you seen a dude in a coffee shop using the command line interface to mess with stuff?)
  • It could be helpful to note the directory for others because of installing other themes to gnome-classic (cough new macbuntu port cough)

I would also like to know if this is a text file that I may be able to change with vim, emacs, gedit, etc.


Solution 1:

You can move buttons to the right with:

gsettings set org.gnome.desktop.wm.preferences button-layout ':close,minimize,maximize'

or, maybe better to twitch "close" button with "maximize" button:

gsettings set org.gnome.desktop.wm.preferences button-layout ':maximize,minimize, close'

And move them back to the left with:

gsettings set org.gnome.desktop.wm.preferences button-layout 'close,minimize,maximize:'

To get the current settings, use:

gsettings get org.gnome.desktop.wm.preferences button-layout

See man gsettings for more info, and, as a bonus:

dconf Editor

In this case the changes are made in ~/.config/dconf/user file which is expected to be in the binary dconf (GVDB) database format. Only programs like dconf Editor or gsettings can safely edit this file.

More about:

  • dconf System Administrator Guide
  • Do dconf use EXI binary XML?
  • What is dconf, what is its function, and how do I use it?
  • What are the differences between gconf and dconf?

Solution 2:

I found this question searching for a way to move buttons from left to right using for the whole system. I am using autologin-guess. So everyting the system get restarted this setting got lost.

Create a file /usr/share/glib-2.0/schemas/60_our-own.gschema.override with this content:

[org.gnome.desktop.wm.preferences]
button-layout=':minimize,maximize,close'

Then execute this command:

glib-compile-schemas /usr/share/glib-2.0/schemas/

Reboot your system.