Xfce: Difference between revisions
imported>Vater mNo edit summary |
Add xfconf and Home Manager usage |
||
| (4 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
[http://www.xfce.org Xfce] is a lightweight desktop environment based on GTK+. It includes a window manager, a file manager, desktop and panel. | [http://www.xfce.org Xfce] is a lightweight desktop environment based on GTK+. It includes a window manager, a file manager, desktop and panel. | ||
This article is an extension of the documentation in the [https://nixos.org/manual/nixos/stable/#sec-xfce NixOS manual]. | |||
== Enabling == | == Enabling == | ||
| Line 16: | Line 18: | ||
xfce.enable = true; | xfce.enable = true; | ||
}; | }; | ||
}; | }; | ||
services.displayManager.defaultSession = "xfce"; | |||
... | ... | ||
} | } | ||
| Line 23: | Line 25: | ||
}} | }} | ||
{{Evaluate}} | {{Evaluate}} | ||
=== Excluding xfce applications === | |||
Xfce does not include as many applications by default as some other desktop environments. Still, those can be excluded as demonstrated in the example below. Place this before the <code>services.xserver</code> snippet from above. | |||
{{file|/etc/nixos/configuration.nix|nix| | |||
<nowiki> | |||
{ | |||
environment.xfce.excludePackages = with pkgs.xfce; [ | |||
mousepad | |||
parole | |||
# ristretto | |||
xfce4-appfinder | |||
# xfce4-notifyd | |||
xfce4-screenshooter | |||
# xfce4-session | |||
# xfce4-settings | |||
# xfce4-taskmanager | |||
# xfce4-terminal | |||
]; | |||
} | |||
</nowiki> | |||
}} | |||
=== Using as a desktop manager and not a window manager === | === Using as a desktop manager and not a window manager === | ||
| Line 42: | Line 65: | ||
}; | }; | ||
}; | }; | ||
windowManager.i3.enable = true; | windowManager.i3.enable = true; | ||
}; | }; | ||
services.displayManager.defaultSession = "xfce"; | |||
... | ... | ||
} | } | ||
| Line 90: | Line 113: | ||
}; | }; | ||
}; | }; | ||
}; | }; | ||
services.displayManager.defaultSession = "xfce+xmonad"; | |||
... | ... | ||
} | } | ||
| Line 156: | 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 | ||
| Line 163: | Line 275: | ||
[[Category:Desktop environment]] | [[Category:Desktop environment]] | ||
[[Category:NixOS Manual]] | |||