kovidgoyal/kitty · error

must specify the new contrast value

Error message

must specify the new contrast value

What it means

Thrown by the `set-contrast` subcommand of the desktop-ui kitten when it is invoked without exactly one argument. The command expects either `normal` or `high` as the contrast value, so any other argument count aborts with this error after printing help.

Source

Thrown at kittens/desktop_ui/main.go:124

			if len(args) != 1 {
				cmd.ShowHelp()
				return 1, fmt.Errorf("must specify the new accent color value")
			}
			var v dbus.Variant
			if v, err = to_color(args[0]); err == nil {
				err = set_variant_setting(PORTAL_APPEARANCE_NAMESPACE, PORTAL_ACCENT_COLOR_KEY, v, false)
			}
			return utils.IfElse(err == nil, 0, 1), err
		},
	})
	parent.AddSubCommand(&cli.Command{
		Name:             "set-contrast",
		ShortDescription: "Change the contrast. Can be high or normal.",
		Usage:            " high|normal",
		Run: func(cmd *cli.Command, args []string) (rc int, err error) {
			if len(args) != 1 {
				cmd.ShowHelp()
				return 1, fmt.Errorf("must specify the new contrast value")
			}

			var v dbus.Variant
			switch args[0] {
			case "normal":
				v = dbus.MakeVariant(uint32(0))
			case "high":
				v = dbus.MakeVariant(uint32(1))
			default:
				return 1, fmt.Errorf("%s is not a valid contrast value", args[0])
			}
			err = set_variant_setting(PORTAL_APPEARANCE_NAMESPACE, PORTAL_CONTRAST_KEY, v, false)
			return utils.IfElse(err == nil, 0, 1), err
		},
	})
	st := parent.AddSubCommand(&cli.Command{
		Name:             "set-setting",
		ShortDescription: "Change an arbitrary setting",

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Run `kitten desktop-ui set-contrast high` or `kitten desktop_ui set-contrast normal` with exactly one argument
  2. Check your shell variable expansion (e.g. unset `$CONTRAST`) before invoking the command

Example fix

# before
kitten desktop-ui set-contrast
# after
kitten desktop-ui set-contrast high
Defensive patterns

Strategy: validation

Validate before calling

if len(args) != 1 || (args[0] != "normal" && args[0] != "high") {
    fmt.Fprintln(os.Stderr, "usage: set-contrast high|normal")
    os.Exit(1)
}

Prevention

When it happens

Trigger: Running `kitten desktop-ui set-contrast` with zero arguments or with more than one argument (e.g. `set-contrast high extra`).

Common situations: Scripts that build the command dynamically and pass an empty/unset variable as the contrast value; users forgetting the required value.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/4023b9b74377822d. Report an issue: GitHub.