tuigreet icon indicating copy to clipboard operation
tuigreet copied to clipboard

config file

Open mock1328 opened this issue 1 year ago • 5 comments

IMO, would be great if we had a /etc/greetd/tuigreet.toml config file alongside running with args. Options line gets too long and ugly very quickly, managing config file could be easier

mock1328 avatar Sep 26 '24 06:09 mock1328

Thanks for the issue. I was actually thinking about doing something like it, since this also bothers me.

I'll categorize this as a feature request and I'll probably work on it for 0.11.

apognu avatar Sep 26 '24 07:09 apognu

This is being worked on and, on the relevant branch, it is at a stage where it can be tested and polished. I'll still ask that, if someone wanted to give it a go, they be careful, it is still very much a work in progress.

I plan on having this ready for 0.11 (so not the next version).

apognu avatar Oct 16 '24 18:10 apognu

I have used tuigreet from NixOS before, and have just set it up again (thus finding my way here, finding to my great delight this had already been handled :smiley:). It would be really good if there was a structured way of setting configs from the configuration.nix -- more structured than just writing a string. Has that been thought of? Should I open a new issue?

I'm imaging that something like this would write the config file in the relevant way (perhaps overwriting everything previously, perhaps only setting the keys which are explicit set herein):

services.greetd = {
  enable = true;
  settings = {
    default_session = {
      command = "${lib.makeBinPath [pkgs.greetd.tuigreet] }/tuigreet";
      user = "greeter";
    }; 
    vt = 1;
  };
 # Not sure where the best place for this would be. Perhaps not inside greetd? IDK.
  tuigreet.config = {
    time = true;
    asterisks = true;
    command = "bash";
    # Note structured theme, I think this would be handy for applying
    # system-wide colour schemes
    theme = {
      border = magenta;
      text = cyan;
      prompt = green;
      time = red;
      action = blue;
      button = yellow;
      container = black;
      input = red;
    };
  };
};

ETA: I've just seen that the implementation uses a TOML file. The decision was made not to include a write-to-TOML function in the nix builtins, though there is a toTOML function function in nix-std.

Hugo-Heagren avatar Nov 05 '24 04:11 Hugo-Heagren

@Hugo-Heagren Yes, this is ongoing (albeit taking a bit more time than I anticipated) and will use TOML indeed.

As far as custom Nix derivations for tuigreet config, I am not really sure what I can do here since I do not maintain the packaging for various distributions.

apognu avatar Nov 06 '24 21:11 apognu

@Hugo-Heagren If/when TOML config file support is added in tuigreet, changes would need to be made in the Nixpkgs repo, rather than this one. Separate programs.tuigreet.* options will need to be created, like for ReGreet, another greetd greeter. TOML is a Nix-representable format, so pkgs.formats.toml can be used (relevant manual section). pkgs.formats.* is used for the settings option in various NixOS and Home Manager modules.

For a slightly cleaner config (in the current state), I use the concatStringsSep function:

{ lib, pkgs, ... }:

let
  inherit (lib) getExe concatStringsSep;
in

{
  services.greetd = {
    enable = true;
    settings = {
      default_session = {
        command = concatStringsSep " " [
          (getExe pkgs.greetd.tuigreet)
          "--time"
          "--asterisks"
          "--cmd 'bash'"
          "--theme ${
            concatStringsSep ";" [
              "border=magenta"
              "text=cyan"
              "prompt=green"
              "time=red"
              "action=blue"
              "button=yellow"
              "container=black"
              "input=red"
            ]
          }"
        ];
        user = "greeter";
      };
      vt = 1;
    };
  };
}

Brisingr05 avatar Apr 16 '25 05:04 Brisingr05