I3

From NixOS Wiki
Jump to: navigation, search

i3 is a tiling window manager for X.

Enabling

To use i3 set services.xserver.windowManager.i3.enable to true. For example:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
{ config, pkgs, callPackage, ... }: 

  environment.pathsToLink = [ "/libexec" ]; # links /libexec from derivations to /run/current-system/sw 
  ...
  services.xserver = {
    enable = true;

    desktopManager = {
      default = "none";
      xterm.enable = false;
    };

    windowManager.i3 = {
      enable = true;
      extraPackages = with pkgs; [
        dmenu #application launcher most people use
        i3status # gives you the default i3 status bar
        i3lock #default i3 screen locker
        i3blocks #if you are planning on using i3blocks over i3status
     ];
    };
  };
  ...
}

Using home-manager

See example: https://github.com/srid/nix-config/blob/master/nix/home/i3.nix

With a desktop manager

i3 is a window manager and does not provide "cosmetic" services like managing multiple monitor configuration or media keys. This is what is usually delegated to a desktop manager. To use xfce as a desktop manager on top of i3, see Xfce#Using_as_a_desktop_manager_and_not_a_window_manager.

I3-gaps fork

To use i3-gaps fork, the following line should be added to the configuration.nix:

services.xserver.windowManager.i3.package = pkgs.i3-gaps;

Tips & tricks

i3blocks

After installing and enabling i3blocks, you may notice that i3block won't work. why?

It seems that i3blocks read it's contents from a hardcoded path in /etc by default. Since in nixos, this path look something like:

Breeze-text-x-plain.png
Path of i3blocks in nixos
  /nix/store/k78nc1bplhy4yjblqwlc14h6rdisix3w-i3blocks-1.4/libexec/i3blocks/[BLOCKS]


And it can't find this path, so we have to create a link to this path by adding this line to configuration.nix file:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
  environment.pathsToLink = [ "/libexec" ];


Finally, your block may looks like:

Breeze-text-x-plain.png
~/.config/i3/i3blocks.conf
[battery]                                                                                                        
label=                                                                                                         
command=/run/current-system/sw/libexec/i3blocks/battery                                                          
interval=10                                                                                                      
instance=1


DConf

If your settings aren't being saved for some applications (gtk3 applications, firefox), like the size of file selection windows, or the size of the save dialog, you will need to enable dconf:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
  programs.dconf.enable = true;


Lxappearance

To change the icon and themes you can install lxappearance:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
environment.systemPackages = with pkgs; [
    #---- i3
    lxappearance
    ...
]


Solve inconsistency between gtk2 and gtk3 themes

If enabling dconf or installing Lxappearance but still see inconsistency between themes, you have to manually edit their configurations. In fact, It is possible to install some gtk3 themes but when you start another gtk2 application, your theme not effected properly. It's because there is no .gtkrc-2.0 in your home directory. First create it and paste these lines to it:

Breeze-text-x-plain.png
~/.gtkrc-2.0
gtk-theme-name="Sierra-compact-light"
gtk-icon-theme-name="ePapirus"
gtk-font-name="Ubuntu 11"
gtk-cursor-theme-name="Deepin"
gtk-cursor-theme-size=0
gtk-toolbar-style=GTK_TOOLBAR_BOTH
gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR
gtk-button-images=1
gtk-menu-images=1
gtk-enable-event-sounds=1
gtk-enable-input-feedback-sounds=1
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle="hintfull"
gtk-xft-rgba="rgb"
gtk-modules="gail:atk-bridge"


Change the options based on your installed themes and icon packs.

Wallpaper

If ~/.background-image exists then it will be displayed as a wallpaper. Options services.xserver.desktopManager.wallpaper.combineScreens and .mode control exactly how it is displayed.