From 98d4c4498b2bf01ff14fdb4f1a66199b0dea134e Mon Sep 17 00:00:00 2001 From: wzy <32936898+Freed-Wu@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:24:23 +0800 Subject: [PATCH] other: add json schema (#1382) (#1394) * other: add json schema (#1382) * docs: add some screenshots * other: move around schema files * docs: move around some docs around config files --------- Co-authored-by: ClementTsang <34804052+ClementTsang@users.noreply.github.com> --- .../{default-config.md => index.md} | 16 +- docs/mkdocs.yml | 8 +- docs/requirements.txt | 2 +- schema/README.md | 7 + schema/nightly/bottom.json | 385 ++++++++++++++++++ 5 files changed, 413 insertions(+), 5 deletions(-) rename docs/content/configuration/config-file/{default-config.md => index.md} (57%) create mode 100644 schema/README.md create mode 100644 schema/nightly/bottom.json diff --git a/docs/content/configuration/config-file/default-config.md b/docs/content/configuration/config-file/index.md similarity index 57% rename from docs/content/configuration/config-file/default-config.md rename to docs/content/configuration/config-file/index.md index 85fb3f42..8ccf31f4 100644 --- a/docs/content/configuration/config-file/default-config.md +++ b/docs/content/configuration/config-file/index.md @@ -1,6 +1,10 @@ -# Default Config +# Config File -A default config file is automatically generated at the following locations that bottom checks by default: +For persistent configuration, and for certain configuration options, bottom supports config files. + +## Default Config File + +If no config file argument is given, it will automatically look for a config file at these locations: | OS | Default Config Location | | ------- | -------------------------------------------------------------------------------------------------------------------------------------- | @@ -8,4 +12,10 @@ A default config file is automatically generated at the following locations that | Linux | `~/.config/bottom/bottom.toml`
`$XDG_CONFIG_HOME/bottom/bottom.toml` | | Windows | `C:\Users\\AppData\Roaming\bottom\bottom.toml` | -Furthermore, if a custom config path that does not exist is given (using `-C` or `--config`), bottom will attempt to create a default config file at that location. +Like if a path is passed with `-C`/`--config`, if a file doesn't exist at the path, bottom will automatically create a +new, default config file at that location. + +## JSON Schema + +The configuration file also has [JSON Schema](https://json-schema.org/) support to make it easier to manage, if your +IDE/editor supports it. diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index b8cc263c..c87b6c94 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -20,6 +20,7 @@ theme: - content.action.edit - navigation.expand - navigation.footer + - navigation.indexes - navigation.instant - navigation.instant.progress - navigation.sections @@ -28,6 +29,7 @@ theme: - search.highlight - search.suggest - toc.integrate + - toc.follow icon: edit: material/pencil palette: @@ -39,12 +41,16 @@ theme: name: Switch to light mode # Light mode - media: "(prefers-color-scheme: light)" + primary: indigo + accent: indigo toggle: icon: material/weather-sunny name: Switch to dark mode # Dark mode - media: "(prefers-color-scheme: dark)" scheme: slate + primary: black + accent: indigo toggle: icon: material/weather-night name: Switch to system preference @@ -158,7 +164,7 @@ nav: - "Configuration": - "Command-line Options": configuration/command-line-options.md - "Config File": - - "Default Config": configuration/config-file/default-config.md + - configuration/config-file/index.md - "Flags": configuration/config-file/flags.md - "Theming": configuration/config-file/theming.md - "Layout": configuration/config-file/layout.md diff --git a/docs/requirements.txt b/docs/requirements.txt index 0c9bcadf..cd767f69 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,5 @@ mkdocs == 1.5.3 -mkdocs-material == 9.5.3 +mkdocs-material == 9.5.6 mdx_truly_sane_lists == 1.3 mike == 2.0.0 mkdocs-git-revision-date-localized-plugin == 1.2.2 diff --git a/schema/README.md b/schema/README.md new file mode 100644 index 00000000..2f767f8b --- /dev/null +++ b/schema/README.md @@ -0,0 +1,7 @@ +# Config Schema + +## Usage + +## Development + +### How to add a new version diff --git a/schema/nightly/bottom.json b/schema/nightly/bottom.json new file mode 100644 index 00000000..1f0aeac6 --- /dev/null +++ b/schema/nightly/bottom.json @@ -0,0 +1,385 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://github.com/ClementTsang/bottom/tree/main/schema/nightly/schema.json", + "$comment": "https://clementtsang.github.io/bottom/nightly/configuration/config-file", + "title": "Schema for bottom's configs (nightly)", + "type": "object", + "definitions": { + "row": { + "items": { + "properties": { + "ratio": { + "default": 1, + "type": "integer" + }, + "type": { + "enum": ["cpu", "mem", "proc", "net", "temp", "disk", "empty"], + "type": "string" + }, + "default": { + "default": true, + "type": "boolean" + } + }, + "patternProperties": { + "row(.child)+": { + "$ref": "#/definitions/row" + } + }, + "type": "object" + }, + "type": "array" + }, + "filter": { + "description": "hide specific temperature sensors, network interfaces, and disks using filters", + "properties": { + "is_list_ignored": { + "default": true, + "type": "boolean" + }, + "list": { + "type": "array" + }, + "regex": { + "default": true, + "type": "boolean" + }, + "case_sensitive": { + "default": false, + "type": "boolean" + }, + "whole_word": { + "default": false, + "type": "boolean" + } + }, + "type": "object" + } + }, + "properties": { + "flags": { + "description": "This group of options represents a command-line flag/option. Flags explicitly added when running (ie: btm -a) will override this config file if an option is also set here", + "properties": { + "hide_avg_cpu": { + "default": false, + "description": "Whether to hide the average cpu entry", + "type": "boolean" + }, + "dot_marker": { + "default": false, + "description": "Whether to use dot markers rather than braille", + "type": "boolean" + }, + "rate": { + "default": 1000, + "description": "The update rate of the application", + "type": "integer" + }, + "left_legend": { + "default": false, + "description": "Whether to put the CPU legend to the left", + "type": "boolean" + }, + "current_usage": { + "default": false, + "description": "Whether to set CPU% on a process to be based on the total CPU or just current usage", + "type": "boolean" + }, + "unnormalized_cpu": { + "default": false, + "description": "Whether to set CPU% on a process to be based on the total CPU or per-core CPU% (not divided by the number of cpus)", + "type": "boolean" + }, + "group_processes": { + "default": false, + "description": "Whether to group processes with the same name together by default", + "type": "boolean" + }, + "case_sensitive": { + "default": false, + "description": "Whether to make process searching case sensitive by default", + "type": "boolean" + }, + "whole_word": { + "default": false, + "description": "Whether to make process searching look for matching the entire word by default", + "type": "boolean" + }, + "regex": { + "default": false, + "description": "Whether to make process searching use regex by default", + "type": "boolean" + }, + "temperature_type": { + "default": "k", + "enum": ["k", "f", "c", "kelvin", "fahrenheit", "celsius"], + "description": "Defaults to Celsius", + "type": "string" + }, + "default_time_value": { + "default": 60000, + "description": "The default time interval in milliseconds", + "type": "integer" + }, + "time_delta": { + "default": 15000, + "description": "The time delta on each zoom in/out action in milliseconds", + "type": "integer" + }, + "hide_time": { + "default": false, + "description": "Hides the time scale", + "type": "boolean" + }, + "default_widget_type": { + "default": "proc", + "description": "Override layout default widget", + "type": "string" + }, + "default_widget_count": { + "default": 1, + "description": "Override layout default widget", + "type": "integer" + }, + "expanded_on_startup": { + "default": true, + "description": "Expand selected widget upon starting the app", + "type": "boolean" + }, + "basic": { + "default": false, + "description": "Use basic mode", + "type": "boolean" + }, + "use_old_network_legend": { + "default": false, + "description": "Use the old network legend style", + "type": "boolean" + }, + "hide_table_gap": { + "default": false, + "description": "Remove space in tables", + "type": "boolean" + }, + "battery": { + "default": false, + "description": "Show the battery widgets", + "type": "boolean" + }, + "disable_click": { + "default": false, + "description": "Disable mouse clicks", + "type": "boolean" + }, + "color": { + "default": "default", + "enum": [ + "default", + "default-light", + "gruvbox", + "gruvbox-light", + "nord", + "nord-light" + ], + "description": "Built-in themes", + "type": "string" + }, + "mem_as_value": { + "default": false, + "description": "Show memory values in the processes widget as values by default", + "type": "boolean" + }, + "tree": { + "default": false, + "description": "Show tree mode by default in the processes widget", + "type": "boolean" + }, + "show_table_scroll_position": { + "default": false, + "description": "Shows an indicator in table widgets tracking where in the list you are", + "type": "boolean" + }, + "process_command": { + "default": false, + "description": "Show processes as their commands by default in the process widget", + "type": "boolean" + }, + "network_use_binary_prefix": { + "default": false, + "description": "Displays the network widget with binary prefixes", + "type": "boolean" + }, + "network_use_bytes": { + "default": false, + "description": "Displays the network widget using bytes", + "type": "boolean" + }, + "network_use_log": { + "default": false, + "description": "Displays the network widget with a log scale", + "type": "boolean" + }, + "disable_advanced_kill": { + "default": false, + "description": "Hides advanced options to stop a process on Unix-like systems", + "type": "boolean" + }, + "enable_gpu_memory": { + "default": false, + "description": "Shows GPU(s) memory", + "type": "boolean" + }, + "retention": { + "default": "10m", + "description": "How much data is stored at once in terms of time", + "type": "string" + } + }, + "type": "object" + }, + "colors": { + "description": "These are all the components that support custom theming. Note that colour support will depend on terminal support", + "properties": { + "table_header_color": { + "default": "LightBlue", + "description": "Represents the colour of table headers (processes, CPU, disks, temperature)", + "type": "string" + }, + "widget_title_color": { + "default": "Gray", + "description": "Represents the colour of the label each widget has", + "type": "string" + }, + "avg_cpu_color": { + "default": "Red", + "description": "Represents the average CPU color", + "type": "string" + }, + "cpu_core_colors": { + "items": { + "uniqueItems": true, + "minItems": 1, + "type": "string" + }, + "default": [ + "LightMagenta", + "LightYellow", + "LightCyan", + "LightGreen", + "LightBlue", + "LightRed", + "Cyan", + "Green", + "Blue", + "Red" + ], + "description": "Represents the colour the core will use in the CPU legend and graph", + "type": "array" + }, + "ram_color": { + "default": "LightMagenta", + "description": "Represents the colour RAM will use in the memory legend and graph", + "type": "string" + }, + "swap_color": { + "default": "LightYellow", + "description": "Represents the colour SWAP will use in the memory legend and graph", + "type": "string" + }, + "arc_color": { + "default": "LightCyan", + "description": "Represents the colour ARC will use in the memory legend and graph", + "type": "string" + }, + "gpu_core_colors": { + "items": { + "uniqueItems": true, + "minItems": 1, + "type": "string" + }, + "default": [ + "LightGreen", + "LightBlue", + "LightRed", + "Cyan", + "Green", + "Blue", + "Red" + ], + "description": "Represents the colour the GPU will use in the memory legend and graph", + "type": "array" + }, + "rx_color": { + "default": "LightCyan", + "description": "Represents the colour rx will use in the network legend and graph", + "type": "string" + }, + "tx_color": { + "default": "LightGreen", + "description": "Represents the colour tx will use in the network legend and graph", + "type": "string" + }, + "border_color": { + "default": "Gray", + "description": "Represents the colour of the border of unselected widgets", + "type": "string" + }, + "highlighted_border_color": { + "default": "LightBlue", + "description": "Represents the colour of the border of selected widgets", + "type": "string" + }, + "text_color": { + "default": "Gray", + "description": "Represents the colour of most text", + "type": "string" + }, + "selected_text_color": { + "default": "Black", + "description": "Represents the colour of text that is selected", + "type": "string" + }, + "selected_bg_color": { + "default": "LightBlue", + "description": "Represents the background colour of text that is selected", + "type": "string" + }, + "graph_color": { + "default": "Gray", + "description": "Represents the colour of the lines and text of the graph", + "type": "string" + }, + "high_battery_color": { + "default": "green", + "description": "Represents the colours of the battery based on charge", + "type": "string" + }, + "medium_battery_color": { + "default": "yellow", + "description": "Represents the colours of the battery based on charge", + "type": "string" + }, + "low_battery_color": { + "default": "red", + "description": "Represents the colours of the battery based on charge", + "type": "string" + } + } + }, + "row": { + "$ref": "#/definitions/row" + }, + "disk_filter": { + "$ref": "#/definitions/filter" + }, + "mount_filter": { + "$ref": "#/definitions/filter" + }, + "temp_filter": { + "$ref": "#/definitions/filter" + }, + "net_filter": { + "$ref": "#/definitions/filter" + } + } +}