Xfce: Difference between revisions

A subsection on how to exclude packages in xfce.
Tags: Mobile edit Mobile web edit
Add xfconf and Home Manager usage
 
Line 179: Line 179:


[https://wiki.haskell.org/Xmonad/Frequently_asked_questions#Problems_with_Java_applications.2C_Applet_java_console Haskell Wiki FAQ: Problems with Java applications]
[https://wiki.haskell.org/Xmonad/Frequently_asked_questions#Problems_with_Java_applications.2C_Applet_java_console Haskell Wiki FAQ: Problems with Java applications]
== Customizing xfce declaratively ==
Xfce adheres to [https://en.wikipedia.org/wiki/Freedesktop.org XDG] desktop configuration, making it easy to declare user home directory configurations via [[Home Manager]]. xfce-specific configurations are stored in an [https://docs.xfce.org/xfce/xfconf/start xfconf database].
=== Defining xfconf value ===
Below assumes you have already enabled Home Manager in your NixOS configuration.
Launching <code>xfce4-settings-editor</code> you can view xfce personalizations already applied to the system. They're displayed in a tree view, but stored in a flat string format. You can query these same values from the command line with <code>xfconf-query</code> to quickly get the full key and value in a friendlier format. For instance:
{{file|||
<nowiki>
$ xfconf-query -c ristretto -lv
/window/navigationbar/position  left
/window/statusbar/show          true
/window/toolbar/show            false
</nowiki>
}}
Can be translated like so:
{{file|/etc/nixos/configuration.nix|nix|
<nowiki>
# Xfce Home Manager customizations
home-manager.users.${PRIMARY-USER} = { config, ... }: ({
  xfconf = {
    enable = true;
    settings = {
      ristretto = {
        "window/navigationbar/position" = "left";
        "window/statusbar/show" = true;
        "window/toolbar/show" = false;
      };
    };
  };
})
</nowiki>
}}
=== Using built-in wallpapers ===
Similarly, if you wish to use a built-in wallpaper declaratively you could follow this same pattern:
{{file|/etc/nixos/configuration.nix|nix|
<nowiki>
# Values based on `xfconf-query -c xfce4-desktop -lv`
home-manager.users.${PRIMARY-USER} = { config, ... }: ({
  xfconf = {
    enable = true;
    settings = {
      xfce4-desktop = {
        "backdrop/screen0/monitor0/workspace0/color-style" = 0;
        "backdrop/screen0/monitor0/workspace0/image-style" = 5;
        "backdrop/screen0/monitor0/workspace0/last-image" = "${pkgs.xfce.xfdesktop}/share/backgrounds/xfce/xfce-cp-dark.svg";
      };
    };
  };
})
</nowiki>
}}
However, the xfce settings seem to persist across system rebuilds which can lead to the wallpaper being set to a nix store that is cleaned up when older system generations are cleaned up. In other words, the wallpaper may be replaced by a blank screen upon reboot seemingly randomly. One workaround for this is to set a static directory path for the images via a symlink and using that within xfconf.
{{file|/etc/nixos/configuration.nix|nix|
<nowiki>
# ".xfce-wallpaper" directory is created below so that xfce's
# settings aren't pointed to a dynamic, moving nix store path
let background-dir = "/home/${PRIMARY-USER}/.xfce4-wallpapers";
  background-image = "${background-dir}/xfce-cp-dark.svg";
in {
  home-manager.users.${PRIMARY-USER} = { config, ... }: ({
    home.file.".xfce4-wallpapers".source = config.lib.file.mkOutOfStoreSymlink "${pkgs.xfce.xfdesktop}/share/backgrounds/xfce";
    xfconf = {
      enable = true;
      settings = {
        xfce4-desktop = {
          "backdrop/screen0/monitor0/workspace0/color-style" = 0;
          "backdrop/screen0/monitor0/workspace0/image-style" = 5;
          "backdrop/screen0/monitor0/workspace0/last-image" = background-image;
        };
      };
    };
  })
</nowiki>
}}


== Troubleshooting ==
== Troubleshooting ==
=== Pulseaudio ===
=== Pulseaudio ===
If you use pulse audio, set <code>nixpkgs.config.pulseaudio = true</code> as shown above. Otherwise, you may
If you use pulse audio, set <code>nixpkgs.config.pulseaudio = true</code> as shown above. Otherwise, you may