aboutsummaryrefslogtreecommitdiff
path: root/modules/xsession.nix
diff options
context:
space:
mode:
authorRobert Helgesson <robert@rycee.net>2017-09-29 00:15:57 +0200
committerRobert Helgesson <robert@rycee.net>2017-10-04 20:36:31 +0200
commit9c859d26553aebe56bb669f275af04cc1dbc4af5 (patch)
tree45a7155b5e55f8dfd7bbc59c4db2f57968a8fc61 /modules/xsession.nix
parentfb5dbe13c24b4ae09d908389804ba559a6a152da (diff)
xmonad: add module
Adapted from #78 and originally authored by Infinisil.
Diffstat (limited to 'modules/xsession.nix')
-rw-r--r--modules/xsession.nix35
1 files changed, 34 insertions, 1 deletions
diff --git a/modules/xsession.nix b/modules/xsession.nix
index 4899ad2ea76..5c9ee777881 100644
--- a/modules/xsession.nix
+++ b/modules/xsession.nix
@@ -1,6 +1,7 @@
{ config, lib, pkgs, ... }:
with lib;
+with import ./lib/dag.nix { inherit lib; };
let
@@ -32,6 +33,10 @@ let
};
};
+ xmonadModule = import ./services/window-managers/xmonad.nix {
+ inherit pkgs;
+ };
+
in
{
@@ -46,7 +51,7 @@ in
types.coercedTo
types.str
(command: { inherit command; usesDeprecated = true; })
- (types.submodule wmBaseModule);
+ (types.submodule [ wmBaseModule xmonadModule ]);
description = ''
Window manager start command. DEPRECATED: Use
<varname>xsession.windowManager.command</varname> instead.
@@ -69,6 +74,34 @@ in
];
})
+ # Hack to support xsession.windowManager as a string. Once that is
+ # removed this code should go back into the xmonad.nix file.
+ (mkIf (cfg.windowManager.xmonad.enable
+ && cfg.windowManager.xmonad.config != null) {
+ home.file.".xmonad/xmonad.hs".source = cfg.windowManager.xmonad.config;
+
+ home.activation.checkXmonad = dagEntryBefore [ "linkGeneration" ] ''
+ if ! cmp --quiet \
+ "${cfg.windowManager.xmonad.config}" \
+ "$HOME/.xmonad/xmonad.hs"; then
+ xmonadChanged=1
+ fi
+ '';
+
+ home.activation.applyXmonad = dagEntryAfter [ "linkGeneration" ] ''
+ if [[ -v xmonadChanged ]]; then
+ echo "Recompiling xmonad"
+ ${cfg.windowManager.command} --recompile
+
+ # Attempt to restart xmonad if X is running.
+ if [[ -v DISPLAY ]] ; then
+ echo "Restarting xmonad"
+ ${cfg.windowManager.command} --restart
+ fi
+ fi
+ '';
+ })
+
{
systemd.user.services.setxkbmap = {
Unit = {