Xfce: Difference between revisions
imported>Symphorien →Using as a desktop manager and not a window manager: mention that i3-msg exit does not work anymore. |
Add xfconf and Home Manager usage |
||
| (16 intermediate revisions by 10 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 == | ||
To use xfce set <code> | To use xfce set <code>services.xserver.desktopManager.xfce.enable</code> to <code>true</code>. For example: | ||
{{file|/etc/nixos/configuration.nix|nix| | {{file|/etc/nixos/configuration.nix|nix| | ||
<nowiki> | <nowiki> | ||
| Line 14: | Line 15: | ||
enable = true; | enable = true; | ||
desktopManager = { | desktopManager = { | ||
xterm.enable = false; | xterm.enable = false; | ||
xfce.enable = true; | xfce.enable = true; | ||
}; | }; | ||
}; | }; | ||
services.displayManager.defaultSession = "xfce"; | |||
... | ... | ||
} | } | ||
| Line 24: | 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 36: | Line 58: | ||
enable = true; | enable = true; | ||
desktopManager = { | desktopManager = { | ||
xterm.enable = false; | xterm.enable = false; | ||
xfce = { | xfce = { | ||
| Line 46: | Line 67: | ||
windowManager.i3.enable = true; | windowManager.i3.enable = true; | ||
}; | }; | ||
services.displayManager.defaultSession = "xfce"; | |||
... | ... | ||
} | } | ||
| Line 58: | Line 80: | ||
Note that xfce manages your session instead of i3: exiting i3 will blank your screen but not terminate your session. | Note that xfce manages your session instead of i3: exiting i3 will blank your screen but not terminate your session. | ||
In your i3 config, replace <code>i3-msg exit</code> with <code>xfce4-session-logout</code>. | In your i3 config, replace <code>i3-msg exit</code> with <code>xfce4-session-logout</code>. | ||
==== With xmonad as the window manager ==== | |||
One of the possibilities is to use <code>xmonad</code> as a window manager in a <code>Xfce</code> desktop environment. | |||
===== Without xfce desktop ===== | |||
The previously described configuration is extended with the part that configures xmonad: | |||
{{file|/etc/nixos/configuration.nix|nix| | |||
<nowiki> | |||
{ config, pkgs, callPackage, ... }: { | |||
... | |||
services.xserver = { | |||
enable = true; | |||
desktopManager = { | |||
xterm.enable = false; | |||
xfce = { | |||
enable = true; | |||
noDesktop = true; | |||
enableXfwm = false; | |||
}; | |||
}; | |||
windowManager = { | |||
xmonad = { | |||
enable = true; | |||
enableContribAndExtras = true; | |||
extraPackages = haskellPackages : [ | |||
haskellPackages.xmonad-contrib | |||
haskellPackages.xmonad-extras | |||
haskellPackages.xmonad | |||
]; | |||
}; | |||
}; | |||
}; | |||
services.displayManager.defaultSession = "xfce+xmonad"; | |||
... | |||
} | |||
</nowiki> | |||
}} | |||
Xmonad's contrib package comes with a config to integrate seamlessly into Xfce, like connecting workspaces to xfce's top panel's preview of workspaces. To enable this config, put the following into the user's xmonad config file: | |||
{{file|~/.xmonad/xmonad.hs|haskell| | |||
<nowiki> | |||
import XMonad | |||
import XMonad.Config.Xfce | |||
main = xmonad xfceConfig | |||
{ terminal = "xfce4-terminal" | |||
, modMask = mod4Mask -- optional: use Win key instead of Alt as MODi key | |||
} | |||
</nowiki> | |||
}} | |||
Since Xfce uses Alt for a lot of keybindings, using the Win key for xmonad hotkeys may be preferred. | |||
{{Evaluate}} | |||
After choosing the <code>xfce+xmonad</code> session in your display manager, you will be taken to a clean screen, where you can open a terminal with <code>MOD+Shift+Enter</code> or launch an application with <code>MOD(+SHIFT)+p</code>. | |||
===== With xfce desktop ===== | |||
If you instead prefer to have panels (like the top panel) in addition to the main clean display area managed by xmonad, you can remove the <code>xfce.noDesktop = true;</code> option from the configuration. | |||
{{Evaluate}} | |||
After switching to your new configuration, reboot and clean your sessions with <code>rm -rf ~/.cache/sessions/*</code> before logging in to a graphical session. | |||
After logging in you will be greeted by xfce's desktop which interferes with xmonad. To solve this issue you have to remove the <code>xfdesktop</code> process from being started in the session. | |||
Open the session manager in the application launcher with <code>MOD(+SHIFT)+p</code> and then typing in "Session and Startup". Go to tab "Session" and set the restart style of <code>xfdesktop</code> to "Never". Kill the process with "Quit program", then "Save session." After this, xfce4 and xmonad will work together nicely. | |||
===== Java-based GUI applications ===== | |||
Java-based applications may not work properly with xmonad. The applications main window may stay blank or gray on startup. This is a known issue with some versions of Java, where xmonad is not recognized as a "non-reparenting" window manager. There are multiple solutions to this problem as described on xmonad's FAQ page. | |||
One alternative is to fake xmonad's window manager name, after running the EMWH initialization. This particular approach works well when running xmonad alongside the xfce-based desktop (described above). | |||
{{file|~/.xmonad/xmonad.hs|haskell| | |||
<nowiki> | |||
import XMonad | |||
import XMonad.Config.Xfce | |||
import XMonad.Hooks.EwmhDesktops | |||
import XMonad.Hooks.SetWMName | |||
main = xmonad xfceConfig | |||
{ terminal = "xfce4-terminal" | |||
, modMask = mod4Mask -- Use Win as MOD key | |||
, startupHook = ewmhDesktopsStartup >> setWMName "LG3D" -- for some reason the double greater sign is escaped here due to wiki formatting, replace this with proper greater signs! | |||
} | |||
</nowiki> | |||
}} | |||
===== Additional resources ===== | |||
Note that, unlike suggested in additional resources, the xmonad packages should not be installed in the environment (neither as systemPackages nor user packages), since that leads to errors when (re)compiling xmonad's config file. | |||
Additional resources: | |||
[https://wiki.haskell.org/Xmonad/Installing_xmonad#NixOS Haskell Wiki: Installing xmonad on NixOS] | |||
[https://wiki.haskell.org/Xmonad/Using_xmonad_in_XFCE Haskell Wiki: Using xmonad in Xfce] | |||
[https://wiki.haskell.org/File:Xmbindings.png Haskell Wiki: Xmonad default key bindings] | |||
[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 | ||
experience glitches like being able to mute the sound card but not unmute it. | experience glitches like being able to mute the sound card but not unmute it. | ||
[[Category:Desktop environment]] | |||
[[Category:NixOS Manual]] | |||