Xfce: Difference between revisions
imported>Mucaho No edit summary |
m warning: The option `services.xserver.displayManager.defaultSession' defined in `/etc/nixos/configuration.nix' has been renamed to `services.displayManager.defaultSession'. |
||
(13 intermediate revisions by 9 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 36: | Line 37: | ||
enable = true; | enable = true; | ||
desktopManager = { | desktopManager = { | ||
xterm.enable = false; | xterm.enable = false; | ||
xfce = { | xfce = { | ||
Line 46: | Line 46: | ||
windowManager.i3.enable = true; | windowManager.i3.enable = true; | ||
}; | }; | ||
services.displayManager.defaultSession = "xfce"; | |||
... | ... | ||
} | } | ||
Line 59: | Line 60: | ||
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. | 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: | The previously described configuration is extended with the part that configures xmonad: | ||
{{file|/etc/nixos/configuration.nix|nix| | {{file|/etc/nixos/configuration.nix|nix| | ||
Line 70: | Line 74: | ||
enable = true; | enable = true; | ||
desktopManager = { | desktopManager = { | ||
xterm.enable = false; | xterm.enable = false; | ||
xfce = { | xfce = { | ||
Line 79: | Line 82: | ||
}; | }; | ||
windowManager = { | windowManager = { | ||
xmonad = { | xmonad = { | ||
enable = true; | enable = true; | ||
Line 91: | Line 93: | ||
}; | }; | ||
}; | }; | ||
services.displayManager.defaultSession = "xfce+xmonad"; | |||
... | ... | ||
} | } | ||
Line 103: | Line 106: | ||
main = xmonad xfceConfig | main = xmonad xfceConfig | ||
{ terminal = "xfce4-terminal" | { terminal = "xfce4-terminal" | ||
, modMask = mod4Mask -- optional: use Win key instead of Alt as | , modMask = mod4Mask -- optional: use Win key instead of Alt as MODi key | ||
} | } | ||
</nowiki> | </nowiki> | ||
Line 109: | Line 112: | ||
Since Xfce uses Alt for a lot of keybindings, using the Win key for xmonad hotkeys may be preferred. | Since Xfce uses Alt for a lot of keybindings, using the Win key for xmonad hotkeys may be preferred. | ||
{{Evaluate}} | {{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. | 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. | ||
Line 117: | Line 154: | ||
[https://wiki.haskell.org/Xmonad/Using_xmonad_in_XFCE Haskell Wiki: Using xmonad in Xfce] | [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] | |||
== Troubleshooting == | == Troubleshooting == | ||
Line 122: | Line 163: | ||
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]] |
Latest revision as of 10:55, 11 November 2024
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 NixOS manual.
Enabling
To use xfce set services.xserver.desktopManager.xfce.enable
to true
. For example:
/etc/nixos/configuration.nix
{ config, pkgs, callPackage, ... }: {
...
# if you use pulseaudio
nixpkgs.config.pulseaudio = true;
services.xserver = {
enable = true;
desktopManager = {
xterm.enable = false;
xfce.enable = true;
};
};
services.displayManager.defaultSession = "xfce";
...
}
Using as a desktop manager and not a window manager
You can use xfce purely as a desktop manager, leaving window management to another window manager like i3 for example. In this scenario, xfce's role is to answer to media keys, prompt when plugging a new monitor and so on.
Example config:
/etc/nixos/configuration.nix
{ config, pkgs, callPackage, ... }: {
...
services.xserver = {
enable = true;
desktopManager = {
xterm.enable = false;
xfce = {
enable = true;
noDesktop = true;
enableXfwm = false;
};
};
windowManager.i3.enable = true;
};
services.displayManager.defaultSession = "xfce";
...
}
On first login, make sure to choose the session xfce+i3
in your display manager.
If you choose xfce
you will end up in xfce without panels nor window manager, which
is unusable.
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 i3-msg exit
with xfce4-session-logout
.
With xmonad as the window manager
One of the possibilities is to use xmonad
as a window manager in a Xfce
desktop environment.
Without xfce desktop
The previously described configuration is extended with the part that configures xmonad:
/etc/nixos/configuration.nix
{ 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";
...
}
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:
~/.xmonad/xmonad.hs
import XMonad
import XMonad.Config.Xfce
main = xmonad xfceConfig
{ terminal = "xfce4-terminal"
, modMask = mod4Mask -- optional: use Win key instead of Alt as MODi key
}
Since Xfce uses Alt for a lot of keybindings, using the Win key for xmonad hotkeys may be preferred.
After choosing the xfce+xmonad
session in your display manager, you will be taken to a clean screen, where you can open a terminal with MOD+Shift+Enter
or launch an application with MOD(+SHIFT)+p
.
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 xfce.noDesktop = true;
option from the configuration.
After switching to your new configuration, reboot and clean your sessions with rm -rf ~/.cache/sessions/*
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 xfdesktop
process from being started in the session.
Open the session manager in the application launcher with MOD(+SHIFT)+p
and then typing in "Session and Startup". Go to tab "Session" and set the restart style of xfdesktop
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).
~/.xmonad/xmonad.hs
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!
}
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:
Haskell Wiki: Installing xmonad on NixOS
Haskell Wiki: Using xmonad in Xfce
Haskell Wiki: Xmonad default key bindings
Haskell Wiki FAQ: Problems with Java applications
Troubleshooting
Pulseaudio
If you use pulse audio, set nixpkgs.config.pulseaudio = true
as shown above. Otherwise, you may
experience glitches like being able to mute the sound card but not unmute it.