GNOME: Difference between revisions

Normalcea (talk | contribs)
Excluding GNOME Applications: Remove section on excluding GNOME application as it is not clear which applications are necessary and which are not and makes the `Installation` section more confusing to new GNOME users.
Normalcea (talk | contribs)
Configuration: Overhaul section on dconf to be more clear and pedagogical
Line 1: Line 1:
[[{{PAGENAME}}]] (/(ɡ)noʊm/) is a [[:Category:Desktop environment|desktop environment]] for both [[Wayland]] and [[Xorg]] that seeks to be "an independent computing platform for everyone."<ref>Official GNOME Project one-liner https://www.gnome.org/ </ref>  
[[{{PAGENAME}}]] (/(ɡ)noʊm/) is a [[:Category:Desktop environment|desktop environment]] for both [[Wayland]] and [[Xorg]] that seeks to be "an independent computing platform for everyone."<ref>Official GNOME Project one-liner https://www.gnome.org/ </ref>


This article is an extension of the documentation in the [https://nixos.org/manual/nixos/stable/#chap-gnome NixOS manual].
This article is an extension of the documentation in the [https://nixos.org/manual/nixos/stable/#chap-gnome NixOS manual].
Line 27: Line 27:
However, Nix automatically packages all available GNOME extensions under the <code>pkgs.gnomeExtensions</code> attribute. Extensions which require additional dependencies are then manually packaged if needed. Installed extensions can be enabled graphically through the built-in "Extensions" application or through the <code>gnome-extensions</code> command line interface.
However, Nix automatically packages all available GNOME extensions under the <code>pkgs.gnomeExtensions</code> attribute. Extensions which require additional dependencies are then manually packaged if needed. Installed extensions can be enabled graphically through the built-in "Extensions" application or through the <code>gnome-extensions</code> command line interface.


{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{{file|3={
{
   environment.systemPackages = with pkgs; [
   environment.systemPackages = with pkgs; [
     gnomeExtensions.blur-my-shell
     gnomeExtensions.blur-my-shell
Line 34: Line 33:
     gnomeExtensions.arc-menu
     gnomeExtensions.arc-menu
   ];
   ];
}
}|name=/etc/nixos/configuration.nix|lang=nix}}
</nowiki>}}
== Configuration ==
== Configuration ==


=== Managing extensions ===
=== dconf ===
 
Dconf is a low-level configuration system for storing and loading configurations. The dconf database is stored in a single binary file in <code>~/.config/dconf/user</code>  and contains all known configuration values for all applications and programs that use dconf (GNOME applications and shell, gtk, etc).
 
For example, the setting which controls the accent color of GNOME shell is located in the ''schema'' labeled <code>/org/gnome/desktop/interface/</code> which contains the ''key'' <code>accent-color</code> which accepts a GVariant ''value'' of type <code>enum</code> (one of <code>'blue'</code>, <code>'teal'</code>, <code>'green'</code>, etc)
 
NixOS and Home Manager both provide an interface for declarative configuration of dconf settings exposed in <code>programs.dconf</code> and <code>dconf</code> modules respectively. This option accepts an attribute set whose names are schemas whose paired value is another attribute set whose names are keys and paired values as GVariant values.
 
Going back to the previous example, to set the accent color of GNOME in a declarative manner in NixOS as well as mapping the keyboard's "caps lock" key to "ctrl" you would write:
 
{{file|3={
  programs.dconf.profiles.user.databases = [
    {
      lockAll = true; # prevents overriding
      settings = {
        "org/gnome/desktop/interface" = {
          accent-color = "blue";
        };
        "org/gnome/desktop/input-sources" = {
          xkb-options = ["ctrl:nocaps"];
        };
      };
    }
  ];
}|name=/etc/nixos/configuration.nix|lang=Nix}}
 
And the equivalent snippet in Home Manager:
 
{{file|3={
  dconf.enable = true;
  dconf.settings = {
    "org/gnome/desktop/interface" = {
      accent-color = "pink";
    };
    "org/gnome/desktop/input-sources" = {
      xkb-options = [ "ctrl:nocaps" ];
    };
  };
}|name=~/.config/home-manager/home.nix|lang=nix}}
 
{{Note|Schemas in Nix are written without leading and trailing slashes. In addition, since dconf have more data types than the Nix language (for example, tuples), in some cases you'll need to convert Nix value to a GVariant value. You can achieve that by using function defined in <code>lib.gvariant</code>, they're documented [https://nixos.org/manual/nixpkgs/stable/#sec-functions-library-gvariant here].}}


Installed extensions can be enabled and configured in Extension app that comes preinstalled with GNOME. If you want to do that declaratively in your configuration, you can use [[Home Manager]] <code>dconf</code> module by adding following lines.
==== Extensions ====
Extensions are not activated by default when installed with Nix but can be configured to do so using the respective dconf modules. The schema is <code>/org/gnome/shell/</code> with the key <code>enabled-extensions</code> which accepts a list of strings that represent extension UUIDs. If the extension was installed with Nix, then the UUID can be accessed by the <code>extensionUuid</code> attribute of the extension itself. Each extension's configuration can then be found under their corresponding schema in <code>/org/gnome/shell/extensions/</code> and be configured as needed.


{{file|~/.config/home-manager/home.nix|nix|<nowiki>
For example, in Home Manager, you could write:
{
 
{{file|3={
   dconf = {
   dconf = {
     enable = true;
     enable = true;
Line 55: Line 95:
           # field (look at the following example).
           # field (look at the following example).
           pkgs.gnomeExtensions.gsconnect.extensionUuid
           pkgs.gnomeExtensions.gsconnect.extensionUuid
         
 
           # Alternatively, you can manually pass UUID as a string.
           # Alternatively, you can manually pass UUID as a string.
           "blur-my-shell@aunetx"
           "blur-my-shell@aunetx"
           # ...
           # ...
Line 69: Line 109:
     };
     };
   };
   };
}
}|name=~/.config/home-manager/home.nix|lang=nix}}
</nowiki>}}


=== dconf settings ===
== Tips and tricks ==
 
Most of the GNOME settings are stored in [https://en.wikipedia.org/wiki/Dconf dconf] database. Settings are stored as keys placed in folders.
 
To learn about settings that can be configured with dconf either look into <code>dconf-editor</code> program (provided by <code>gnome.dconf-editor</code> package) or type <code>dconf watch /</code> in the terminal and change settings from the GUI and see which options are responsible for that component/element.


These settings can be changed by NixOS via <code>programs.dconf</code> module or by [[Home Manager]] via <code>dconf</code> module. To so in Home Manager, you need to change <code>dconf.settings</code> attribute set. This attribute set contains absolute folder paths (without leading slash) as attributes' names which value is another attribute set with keys (settings).
=== Discover dconf settings ===
If you wish to discover the corresponding dconf entry for a given setting in a program, you can run `dconf watch /` inside of a terminal and change the setting graphically. For example, when changing toggling the Quick-Settings option "Dark Style" from "on" to "off" and back to "on," this will be the output:<syntaxhighlight lang="shell-session">
$ dconf watch /
/org/gnome/desktop/interface/color-scheme
  'default'


For example, to change the value of <code>clock-show-weekday</code> key that is located in <code>/org/gnome/desktop/interface</code>, you need to the following:
/org/gnome/desktop/interface/color-scheme
  'prefer-dark'
</syntaxhighlight>Otherwise you can use the gsettings programs to inspect the schemas installed on your system. For example, to inspect all the keys contained within <code>/org/gnome/desktop/background</code> you could run:<syntaxhighlight lang="shell-session">
$ gsettings list-keys org.gnome.desktop.background
color-shading-type
picture-opacity
picture-options
picture-uri
picture-uri-dark
primary-color
secondary-color
show-desktop-icons


{{file|~/.config/home-manager/home.nix|nix|<nowiki>
</syntaxhighlight>Then to see the range of possible values for one of the keys such as <code>picture-options</code> you could then run:<syntaxhighlight lang="shell-session">
{
$ gsettings range org.gnome.desktop.background picture-options
  dconf = {
enum
    enable = true;
'none'
'wallpaper'
'centered'
'scaled'
'stretched'
'zoom'
'spanned'


    settings = {
      # You need quotes to escape '/'
      "org/gnome/desktop/interface" = {
        clock-show-weekday = true;
      };
    };
  };
}
</nowiki>}}


Same can be achieved by using system configuration.
</syntaxhighlight>Which tells you that the ''key'' <code>picture-options</code> located in ''schema'' <code>/org/gnome/desktop/background/</code> accepts a ''value'' of type enumeration (a single string value from a set of accepted values).  
 
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
{
  programs.dconf = {
    enable = true;
    profiles.user.databases = [
      {
        lockAll = true; # prevents overriding
        settings = {
          "org/gnome/desktop/interface" = {
            clock-show-weekday = true;
          };
        };
      }
    ];
  };
}
</nowiki>}}
 
{{Note|Since dconf have more data types than Nix language (for example, tuples), in some cases you'll need to convert Nix value to a GVariant value. You can achieve that by using function defined in <code>lib.gvariant</code>, they're documented [https://nixos.org/manual/nixpkgs/stable/#sec-functions-library-gvariant here].}}
 
== Tips and tricks ==


=== To run GNOME programs outside of GNOME ===
=== To run GNOME programs outside of GNOME ===
Line 181: Line 206:
=== Profiling (with sysprof) ===
=== Profiling (with sysprof) ===


Install {{ic|sysprof}} as a ''system'' package (it won't work properly if installed against users). Then enable the associated service with  
Install {{ic|sysprof}} as a ''system'' package (it won't work properly if installed against users). Then enable the associated service with


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">