diff options
| author | tv <tv@krebsco.de> | 2026-12-04 01:30:49 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-12-04 03:05:12 +0000 |
| commit | b25c2abad084fa6d2fc930e27998533010b50708 (patch) | |
| tree | 9fde45348b6c9eb2753489486bc978f085023aa5 /configs | |
| parent | 607fb1010baae845910e75ba31687bffb259636b (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')
| -rw-r--r-- | configs/x11/default.nix | 1 | ||||
| -rw-r--r-- | configs/x11/xmonad.nix | 84 | ||||
| -rw-r--r-- | configs/xserver/nsxiv.nix | 2 | ||||
| -rw-r--r-- | configs/xserver/urxvt.nix | 2 |
4 files changed, 87 insertions, 2 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"; + }; + }; +} diff --git a/configs/xserver/nsxiv.nix b/configs/xserver/nsxiv.nix index 477429fd..83ab5a13 100644 --- a/configs/xserver/nsxiv.nix +++ b/configs/xserver/nsxiv.nix @@ -1,7 +1,7 @@ { config, pkgs, ... }: let cfg.user = config.krebs.build.user; in { - tv.Xresources = { + hrm.xresources."*" = { "Nsxiv.window.foreground" = "#232323"; "Nsxiv.window.background" = "#424242"; }; diff --git a/configs/xserver/urxvt.nix b/configs/xserver/urxvt.nix index df5affab..f143da78 100644 --- a/configs/xserver/urxvt.nix +++ b/configs/xserver/urxvt.nix @@ -13,7 +13,7 @@ in { User = cfg.user.name; }; }; - tv.Xresources = { + hrm.xresources."*" = { "URxvt*cutchars" = ''"\\`\"'&()*,;<=>?@[]^{|}‘’"''; "URxvt*eightBitInput" = "false"; "URxvt*font" = "-*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-1"; |
