summaryrefslogtreecommitdiffstats
path: root/configs/x11
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-12-04 01:30:49 +0000
committertv <tv@krebsco.de>2026-12-04 03:05:12 +0000
commitb25c2abad084fa6d2fc930e27998533010b50708 (patch)
tree9fde45348b6c9eb2753489486bc978f085023aa5 /configs/x11
parent607fb1010baae845910e75ba31687bffb259636b (diff)
x11: xmonad
From the dirt. Hosts set what's specific to them: XMONAD_MASTER_* by the unit's environment, and shortcuts by hrm.xmonad.shortcuts. hrm.xresources replaces tv.Xresources: X resources per display, and "*" for all, loaded by the session service xresources@ instead of a system service.
Diffstat (limited to 'configs/x11')
-rw-r--r--configs/x11/default.nix1
-rw-r--r--configs/x11/xmonad.nix84
2 files changed, 85 insertions, 0 deletions
diff --git a/configs/x11/default.nix b/configs/x11/default.nix
index 8ee40c22..22630ae5 100644
--- a/configs/x11/default.nix
+++ b/configs/x11/default.nix
@@ -1,5 +1,6 @@
{
imports = [
+ ./xmonad.nix
./xserver.nix
];
diff --git a/configs/x11/xmonad.nix b/configs/x11/xmonad.nix
new file mode 100644
index 00000000..8616fa59
--- /dev/null
+++ b/configs/x11/xmonad.nix
@@ -0,0 +1,84 @@
+{ config, mylib, lib, pkgs, ... }: let
+ xmonad-main =
+ mylib.haskell.substitutePkgs "main.hs" {
+ inherit pkgs;
+ path = cfg.pkg.src + "/main.hs";
+ };
+
+ cfg = {
+ pkg = pkgs.haskellPackages.xmonad-tv;
+ };
+in {
+ options.hrm.xmonad.shortcuts = lib.mkOption {
+ default = {};
+ type = lib.types.attrsOf lib.types.str;
+ example = {
+ "M4-<F7>" = "/run/current-system/sw/bin/xtoggledpms";
+ };
+ description = ''
+ Programs to run, by key, in the notation of XMonad.Util.EZConfig.
+ '';
+ };
+
+ config = {
+ hrm.xsession.services = [ "xmonad" ];
+
+ systemd.user.services."xmonad@" = {
+ after = [ "xresources@%i.service" ];
+ serviceConfig = {
+ ExecStart = pkgs.writeDash "xmonad-start" ''
+ ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CACHE_DIR"
+ ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_CONFIG_DIR"
+ ${pkgs.coreutils}/bin/mkdir -p "$XMONAD_DATA_DIR"
+
+ case $(${pkgs.desktop-pager}/bin/desktops) in
+ null|[])
+ ${pkgs.desktop-pager}/bin/desktops set ${lib.concatMapStringsSep " " mylib.shell.escape [
+ "Dashboard" # we start here
+ ]}
+ ;;
+ esac
+
+ exec ${cfg.pkg}/bin/xmonad
+ '';
+ ExecStop = "${cfg.pkg}/bin/xmonad --shutdown";
+ ExecReload = "${pkgs.coreutils}/bin/echo RELOAD, lol";
+ Slice = "session.slice";
+ };
+
+ environment = {
+ XOUTINFO_OVERRIDE = config.hrm.environment.variables.XOUTINFO_OVERRIDE or "{}";
+
+ TMPDIR = "/run/user/%U";
+ FZMENU_FZF_DEFAULT_OPTS = toString [
+ "--color=dark,border:126,bg+:090"
+ "--inline-info"
+ ];
+ XMONAD_CACHE_DIR = "/run/user/%U/xmonad-%i";
+ XMONAD_CONFIG_DIR = "/var/empty";
+ XMONAD_DATA_DIR = "/run/user/%U/xmonad-%i";
+ XMONAD_SHORTCUTS =
+ pkgs.writeJSON "xmonad-shortcuts.json" config.hrm.xmonad.shortcuts;
+ XMONAD_STARTUP_HOOK = pkgs.writeDash "xmonad-ready" ''
+ if ! ${pkgs.xhost}/bin/xhost | ${pkgs.gnugrep}/bin/grep -q "^SI:localuser:$USER\$"; then
+ ${pkgs.xhost}/bin/xhost "+SI:localuser:$USER"
+ ${pkgs.xhost}/bin/xhost -LOCAL:
+ fi
+ case $DISPLAY in
+ :11) bgColor=#1c1c1c;;
+ *) bgColor=#231c23;;
+ esac
+ ${pkgs.hsetroot}/bin/hsetroot -solid "$bgColor" &
+ ${pkgs.xsetroot}/bin/xsetroot -cursor_name plus &
+ wait
+ '';
+ };
+
+ path = xmonad-main.dependencies ++ [ config.tv.slock.package ];
+ };
+
+ hrm.xresources."*" = {
+ "Xcursor.size" = "64";
+ };
+ };
+}