Difference between revisions of "Xorg"

From NixOS Wiki
Jump to: navigation, search
(link to graphic cards)
m (rollback unauthorized mass edits)
Tag: Rollback
 
(5 intermediate revisions by 4 users not shown)
Line 5: Line 5:
 
Not all software behaves well in high-resolution mode yet. Here are listed most common tweaks which make work on a HiDPI screen more pleasant:
 
Not all software behaves well in high-resolution mode yet. Here are listed most common tweaks which make work on a HiDPI screen more pleasant:
  
<pre>
+
<syntaxhighlight lang="nix">
 
   # bigger tty fonts
 
   # bigger tty fonts
 
   console.font =
 
   console.font =
Line 15: Line 15:
 
     _JAVA_OPTIONS = "-Dsun.java2d.uiScale=2";
 
     _JAVA_OPTIONS = "-Dsun.java2d.uiScale=2";
 
   };
 
   };
</pre>
+
</syntaxhighlight>
  
 
In NixOS unstable (but not in NixOS 20.03) there is also a dedicated [https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/hardware/video/hidpi.nix HiDPI module]:
 
In NixOS unstable (but not in NixOS 20.03) there is also a dedicated [https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/hardware/video/hidpi.nix HiDPI module]:
  
<pre>
+
<syntaxhighlight lang="nix">
 
{
 
{
 
   hardware.video.hidpi.enable = true;
 
   hardware.video.hidpi.enable = true;
 
}
 
}
</pre>
+
</syntaxhighlight>
  
 
This option will be included by default when using <code>nixos-config-generate</code> and it detects a screen larger than  
 
This option will be included by default when using <code>nixos-config-generate</code> and it detects a screen larger than  
 
fullhd. This will only set linux console fonts xserver dpi settings and environment variables still needs to be applied manually.
 
fullhd. This will only set linux console fonts xserver dpi settings and environment variables still needs to be applied manually.
  
== Disabling mouse acceleration ==
+
== Disabling touchpad and mouse accelerations ==
To disable mouse acceleration for a touchpad, it's as simple as
+
To disable touchpad and mouse accelerations just add the following lines to your <code>configuration.nix</code>
  
<pre>
+
<syntaxhighlight lang="nix">
   services.xserver.libinput.enable = true;
+
   services.xserver = {
  services.xserver.libinput.accelProfile = "flat";
+
    enable = true;
</pre>
 
  
But to disable it for a mouse, it's a bit more wordy -
+
    ...
  
<pre>
+
    libinput = {
  services.xserver.libinput.enable = true;
+
      enable = true;
  services.xserver.config = ''
+
 
    Section "InputClass"
+
      # disabling mouse acceleration
       Identifier "mouse accel"
+
      mouse = {
       Driver "libinput"
+
        accelProfile = "flat";
       MatchIsPointer "on"
+
       };
      Option "AccelProfile" "flat"
+
 
       Option "AccelSpeed" "0"
+
       # disabling touchpad acceleration
    EndSection
+
       touchpad = {
   '';
+
        accelProfile = "flat";
</pre>
+
       };
 +
    };
 +
 
 +
    ...
 +
 
 +
  };
 +
</syntaxhighlight>
 +
 
 +
To get more information see <code>man configuration.nix</code>.
 +
 
 +
== Exclude packages ==
 +
Some packages like xterm are included when enabling Xorg. To exclude packages, edit the <code>configuration.nix</code> as the example, but be sure to have another terminal enabled in your build before doing this.
 +
 
 +
<syntaxhighlight lang="nix">
 +
services.xserver.excludePackages = with pkgs; [
 +
   xterm
 +
];
 +
</syntaxhighlight>
  
 
== See also ==
 
== See also ==

Latest revision as of 10:59, 6 April 2024

HiDPI

HiDPI (High Dots Per Inch) displays, also known by Apple's "Retina Display" marketing name, are screens with a high resolution in a relatively small format. They are mostly found in high-end laptops and monitors.

Not all software behaves well in high-resolution mode yet. Here are listed most common tweaks which make work on a HiDPI screen more pleasant:

  # bigger tty fonts
  console.font =
    "${pkgs.terminus_font}/share/consolefonts/ter-u28n.psf.gz";
  services.xserver.dpi = 180;
  environment.variables = {
    GDK_SCALE = "2";
    GDK_DPI_SCALE = "0.5";
    _JAVA_OPTIONS = "-Dsun.java2d.uiScale=2";
  };

In NixOS unstable (but not in NixOS 20.03) there is also a dedicated HiDPI module:

{
  hardware.video.hidpi.enable = true;
}

This option will be included by default when using nixos-config-generate and it detects a screen larger than fullhd. This will only set linux console fonts xserver dpi settings and environment variables still needs to be applied manually.

Disabling touchpad and mouse accelerations

To disable touchpad and mouse accelerations just add the following lines to your configuration.nix

  services.xserver = {
    enable = true;

    ...

    libinput = {
      enable = true;

      # disabling mouse acceleration
      mouse = {
        accelProfile = "flat";
      };

      # disabling touchpad acceleration
      touchpad = {
        accelProfile = "flat";
      };
    };

    ...

  };

To get more information see man configuration.nix.

Exclude packages

Some packages like xterm are included when enabling Xorg. To exclude packages, edit the configuration.nix as the example, but be sure to have another terminal enabled in your build before doing this.

services.xserver.excludePackages = with pkgs; [
  xterm
];

See also