| 1 | //! A bunch of constants used throughout the application. |
| 2 | //! |
| 3 | //! FIXME: Move these to where it makes more sense. |
| 4 | |
| 5 | // Default widget ID |
| 6 | pub const DEFAULT_WIDGET_ID: u64 = 56709; |
| 7 | |
| 8 | // Limits for when we should stop showing table gaps/labels (anything less means |
| 9 | // not shown) |
| 10 | pub const TABLE_GAP_HEIGHT_LIMIT: u16 = 7; |
| 11 | |
| 12 | // Help text |
| 13 | const HELP_CONTENTS_TEXT: [&str; 12] = [ |
| 14 | "Scroll to browse or press the number key to go to the corresponding help menu section:", |
| 15 | "1 - General", |
| 16 | "2 - CPU widget", |
| 17 | "3 - Process widget", |
| 18 | "4 - Process search widget", |
| 19 | "5 - Process sort widget", |
| 20 | "6 - Temperature widget", |
| 21 | "7 - Disk widget", |
| 22 | "8 - Battery widget", |
| 23 | "9 - Basic memory widget", |
| 24 | "", |
| 25 | "Press 'Ctrl-f' or '/' to search for a keyword in the help text.", |
| 26 | ]; |
| 27 | |
| 28 | // TODO [Help]: Move to using tables for easier formatting? |
| 29 | pub(crate) const GENERAL_HELP_TEXT: [&str; 24] = [ |
| 30 | "1 - General", |
| 31 | "q, Q, Ctrl-c Quit", |
| 32 | "Esc Close dialog windows, search, widgets, or exit expanded mode", |
| 33 | "Ctrl-r Reset display and any collected data", |
| 34 | "f Freeze/unfreeze updating with new data", |
| 35 | "Shift/Ctrl-Left, H, A Move widget selection left", |
| 36 | "Shift/Ctrl-Right, L, D Move widget selection right", |
| 37 | "Shift/Ctrl-Up, K, W Move widget selection up", |
| 38 | "Shift/Ctrl-Down, J, S Move widget selection down", |
| 39 | "Left, h Move left within widget", |
| 40 | "Down, j Move down within widget", |
| 41 | "Up, k Move up within widget", |
| 42 | "Right, l Move right within widget", |
| 43 | "? Open help menu", |
| 44 | "gg Jump to the first entry", |
| 45 | "G Jump to the last entry", |
| 46 | "e Toggle expanding the currently selected widget", |
| 47 | "+ Zoom in on chart (decrease time range)", |
| 48 | "- Zoom out on chart (increase time range)", |
| 49 | "= Reset zoom", |
| 50 | "PgUp, PgDown Scroll up/down a table by a page", |
| 51 | "Ctrl-u, Ctrl-d Scroll up/down a table by half a page", |
| 52 | "Mouse scroll Scroll through the tables or zoom in/out of charts by scrolling up/down", |
| 53 | "Mouse click Selects the clicked widget, table entry, dialog option, or tab", |
| 54 | ]; |
| 55 | |
| 56 | const CPU_HELP_TEXT: [&str; 2] = [ |
| 57 | "2 - CPU widget", |
| 58 | "Mouse scroll Scrolling over a CPU core/average shows only that entry on the chart", |
| 59 | ]; |
| 60 | |
| 61 | const PROCESS_HELP_TEXT: [&str; 20] = [ |
| 62 | "3 - Process widget", |
| 63 | "dd, F9, Delete Kill the selected process", |
| 64 | "c Sort by CPU usage, press again to reverse", |
| 65 | "m Sort by memory usage, press again to reverse", |
| 66 | "p Sort by PID name, press again to reverse", |
| 67 | "n Sort by process name, press again to reverse", |
| 68 | "Tab Group/un-group processes with the same name", |
| 69 | "Ctrl-f, / Open process search widget", |
| 70 | "P Toggle between showing the full command or just the process name", |
| 71 | "s, F6 Open process sort widget", |
| 72 | "I Invert current sort", |
| 73 | "% Toggle between values and percentages for memory usage", |
| 74 | "t, F5 Toggle tree mode", |
| 75 | "Right Collapse a branch while in tree mode", |
| 76 | "Left Expand a branch while in tree mode", |
| 77 | "+, -, click, Space Toggle whether a branch is expanded or collapsed in tree mode", |
| 78 | "click on header Sorts the entries by that column, click again to invert the sort", |
| 79 | "C Sort by GPU usage, press again to reverse", |
| 80 | "M Sort by GPU memory usage, press again to reverse", |
| 81 | "z Toggle the display of kernel threads", |
| 82 | ]; |
| 83 | |
| 84 | const SEARCH_HELP_TEXT: [&str; 53] = [ |
| 85 | "4 - Process search widget", |
| 86 | "Esc Close the search widget (retains the filter)", |
| 87 | "Ctrl-a Skip to the start of the search query", |
| 88 | "Ctrl-e Skip to the end of the search query", |
| 89 | "Ctrl-u Clear the current search query", |
| 90 | "Ctrl-w Delete a word behind the cursor", |
| 91 | "Ctrl-h Delete the character behind the cursor", |
| 92 | "Backspace Delete the character behind the cursor", |
| 93 | "Delete Delete the character at the cursor", |
| 94 | "Alt-c, F1 Toggle matching case", |
| 95 | "Alt-w, F2 Toggle matching the entire word", |
| 96 | "Alt-r, F3 Toggle using regex", |
| 97 | "Left, Alt-h Move cursor left", |
| 98 | "Right, Alt-l Move cursor right", |
| 99 | "", |
| 100 | "Supported search types:", |
| 101 | "<by name/cmd> ex: btm", |
| 102 | "pid ex: pid 825", |
| 103 | "cpu, cpu% ex: cpu > 4.2", |
| 104 | "mem, mem% ex: mem < 4.2", |
| 105 | "memb ex: memb < 100 kb", |
| 106 | "read, r/s, rps ex: read >= 1 b", |
| 107 | "write, w/s, wps ex: write <= 1 tb", |
| 108 | "tread, t.read ex: tread = 1", |
| 109 | "twrite, t.write ex: twrite = 1", |
| 110 | "user ex: user = root", |
| 111 | "state ex: state = running", |
| 112 | "gpu% ex: gpu% < 4.2", |
| 113 | "gmem ex: gmem < 100 kb", |
| 114 | "gmem% ex: gmem% < 4.2", |
| 115 | "", |
| 116 | "Comparison operators:", |
| 117 | "= ex: cpu = 1", |
| 118 | "!= ex: cpu != 1", |
| 119 | "> ex: cpu > 1", |
| 120 | "< ex: cpu < 1", |
| 121 | ">= ex: cpu >= 1", |
| 122 | "<= ex: cpu <= 1", |
| 123 | "", |
| 124 | "Logical operators:", |
| 125 | "and, &&, <Space> ex: btm and cpu > 1 and mem > 1", |
| 126 | "or, || ex: btm or firefox", |
| 127 | "! ex: !firefox, !(cpu > 5 or btm)", |
| 128 | "", |
| 129 | "Supported units:", |
| 130 | "B ex: read > 1 b", |
| 131 | "KB ex: read > 1 kb", |
| 132 | "MB ex: read > 1 mb", |
| 133 | "TB ex: read > 1 tb", |
| 134 | "KiB ex: read > 1 kib", |
| 135 | "MiB ex: read > 1 mib", |
| 136 | "GiB ex: read > 1 gib", |
| 137 | "TiB ex: read > 1 tib", |
| 138 | ]; |
| 139 | |
| 140 | const SORT_HELP_TEXT: [&str; 6] = [ |
| 141 | "5 - Sort widget", |
| 142 | "Down, 'j' Scroll down in list", |
| 143 | "Up, 'k' Scroll up in list", |
| 144 | "Mouse scroll Scroll through sort widget", |
| 145 | "Esc Close the sort widget", |
| 146 | "Enter Sort by current selected column", |
| 147 | ]; |
| 148 | |
| 149 | const TEMP_HELP_WIDGET: [&str; 3] = [ |
| 150 | "6 - Temperature widget", |
| 151 | "'s' Sort by sensor name, press again to reverse", |
| 152 | "'t' Sort by temperature, press again to reverse", |
| 153 | ]; |
| 154 | |
| 155 | const DISK_HELP_WIDGET: [&str; 9] = [ |
| 156 | "7 - Disk widget", |
| 157 | "'d' Sort by disk name, press again to reverse", |
| 158 | "'m' Sort by disk mount, press again to reverse", |
| 159 | "'u' Sort by disk usage, press again to reverse", |
| 160 | "'n' Sort by disk free space, press again to reverse", |
| 161 | "'t' Sort by total disk space, press again to reverse", |
| 162 | "'p' Sort by disk usage percentage, press again to reverse", |
| 163 | "'r' Sort by disk read activity, press again to reverse", |
| 164 | "'w' Sort by disk write activity, press again to reverse", |
| 165 | ]; |
| 166 | |
| 167 | const BATTERY_HELP_TEXT: [&str; 3] = [ |
| 168 | "8 - Battery widget", |
| 169 | "Left Go to previous battery", |
| 170 | "Right Go to next battery", |
| 171 | ]; |
| 172 | |
| 173 | const BASIC_MEM_HELP_TEXT: [&str; 2] = [ |
| 174 | "9 - Basic memory widget", |
| 175 | "% Toggle between values and percentages for memory usage", |
| 176 | ]; |
| 177 | |
| 178 | /// The number of help sections. |
| 179 | const HELP_SECTIONS: usize = 10; |
| 180 | |
| 181 | // TODO: Add temp graph help section. |
| 182 | pub(crate) const HELP_TEXT: [&[&str]; HELP_SECTIONS] = [ |
| 183 | &HELP_CONTENTS_TEXT, |
| 184 | &GENERAL_HELP_TEXT, |
| 185 | &CPU_HELP_TEXT, |
| 186 | &PROCESS_HELP_TEXT, |
| 187 | &SEARCH_HELP_TEXT, |
| 188 | &SORT_HELP_TEXT, |
| 189 | &TEMP_HELP_WIDGET, |
| 190 | &DISK_HELP_WIDGET, |
| 191 | &BATTERY_HELP_TEXT, |
| 192 | &BASIC_MEM_HELP_TEXT, |
| 193 | ]; |
| 194 | |
| 195 | pub(crate) const DEFAULT_LAYOUT: &str = r#" |
| 196 | [[row]] |
| 197 | ratio=30 |
| 198 | [[row.child]] |
| 199 | type="cpu" |
| 200 | [[row]] |
| 201 | ratio=40 |
| 202 | [[row.child]] |
| 203 | ratio=4 |
| 204 | type="mem" |
| 205 | [[row.child]] |
| 206 | ratio=3 |
| 207 | [[row.child.child]] |
| 208 | type="temp" |
| 209 | [[row.child.child]] |
| 210 | type="disk" |
| 211 | [[row]] |
| 212 | ratio=30 |
| 213 | [[row.child]] |
| 214 | type="net" |
| 215 | [[row.child]] |
| 216 | type="proc" |
| 217 | default=true |
| 218 | "#; |
| 219 | |
| 220 | pub(crate) const DEFAULT_BATTERY_LAYOUT: &str = r#" |
| 221 | [[row]] |
| 222 | ratio=30 |
| 223 | [[row.child]] |
| 224 | ratio=2 |
| 225 | type="cpu" |
| 226 | [[row.child]] |
| 227 | ratio=1 |
| 228 | type="battery" |
| 229 | [[row]] |
| 230 | ratio=40 |
| 231 | [[row.child]] |
| 232 | ratio=4 |
| 233 | type="mem" |
| 234 | [[row.child]] |
| 235 | ratio=3 |
| 236 | [[row.child.child]] |
| 237 | type="temp" |
| 238 | [[row.child.child]] |
| 239 | type="disk" |
| 240 | [[row]] |
| 241 | ratio=30 |
| 242 | [[row.child]] |
| 243 | type="net" |
| 244 | [[row.child]] |
| 245 | type="proc" |
| 246 | default=true |
| 247 | "#; |
| 248 | |
| 249 | // TODO: Eventually deprecate this, or grab from a file. |
| 250 | pub(crate) const CONFIG_TEXT: &str = r#"# This is a default config file for bottom. All of the settings are commented |
| 251 | # out by default; if you wish to change them uncomment and modify as you see |
| 252 | # fit. |
| 253 | |
| 254 | # This group of options represents a command-line option. Flags explicitly |
| 255 | # added when running (ie: btm -a) will override this config file if an option |
| 256 | # is also set here. |
| 257 | #[flags] |
| 258 | # Deprecated - use cpu.hide_avg_cpu. |
| 259 | # Whether to hide the average cpu entry. |
| 260 | #hide_avg_cpu = false |
| 261 | |
| 262 | # Deprecated - use cpu.basic_average_cpu_row. |
| 263 | # Whether to use a dedicated row for the average cpu entry |
| 264 | #average_cpu_row = false |
| 265 | |
| 266 | # Whether to use dot markers rather than braille. |
| 267 | #dot_marker = false |
| 268 | |
| 269 | # The update rate of the application. |
| 270 | #rate = "1s" |
| 271 | |
| 272 | # Deprecated - use cpu.left_legend. |
| 273 | # Whether to put the CPU legend to the left. |
| 274 | #cpu_left_legend = false |
| 275 | |
| 276 | # Deprecated - use processes.current_usage. |
| 277 | # Whether to set CPU% on a process to be based on the total CPU or just current usage. |
| 278 | #current_usage = false |
| 279 | |
| 280 | # Deprecated - use processes.unnormalized_cpu. |
| 281 | # 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). |
| 282 | #unnormalized_cpu = false |
| 283 | |
| 284 | # Deprecated - use processes.default_grouped. |
| 285 | # Whether to group processes with the same name together by default. Doesn't do anything |
| 286 | # if tree is set to true or --tree is set. |
| 287 | #group_processes = false |
| 288 | |
| 289 | # Deprecated - use processes.case_sensitive. |
| 290 | # Whether to make process searching case sensitive by default. |
| 291 | #case_sensitive = false |
| 292 | |
| 293 | # Deprecated - use processes.whole_word. |
| 294 | # Whether to make process searching look for matching the entire word by default. |
| 295 | #whole_word = false |
| 296 | |
| 297 | # Deprecated - use processes.regex. |
| 298 | # Whether to make process searching use regex by default. |
| 299 | #regex = false |
| 300 | |
| 301 | # The temperature unit. One of the following, defaults to "c" for Celsius: |
| 302 | #temperature_type = "c" |
| 303 | ##temperature_type = "k" |
| 304 | ##temperature_type = "f" |
| 305 | ##temperature_type = "kelvin" |
| 306 | ##temperature_type = "fahrenheit" |
| 307 | ##temperature_type = "celsius" |
| 308 | |
| 309 | # The default time interval (in milliseconds). |
| 310 | #default_time_value = "60s" |
| 311 | |
| 312 | # The time delta on each zoom in/out action (in milliseconds). |
| 313 | #time_delta = 15000 |
| 314 | |
| 315 | # Hides the time scale. |
| 316 | #hide_time = false |
| 317 | |
| 318 | # Override layout default widget |
| 319 | #default_widget_type = "proc" |
| 320 | #default_widget_count = 1 |
| 321 | |
| 322 | # Expand selected widget upon starting the app |
| 323 | #expanded = true |
| 324 | |
| 325 | # Use basic mode |
| 326 | #basic = false |
| 327 | |
| 328 | # Use the old network legend style |
| 329 | #use_old_network_legend = false |
| 330 | |
| 331 | # Controls the gap between table headers and data rows. |
| 332 | # Options: "none", "space" (default), "line" |
| 333 | #table_gap = "space" |
| 334 | |
| 335 | # Show the battery widgets |
| 336 | #battery = false |
| 337 | |
| 338 | # Disable mouse clicks |
| 339 | #disable_click = false |
| 340 | |
| 341 | # Disable keyboard shortcuts |
| 342 | #disable_keys = false |
| 343 | |
| 344 | # Deprecated - use processes.default_memory_value. |
| 345 | # Show memory values in the processes widget as values by default |
| 346 | #process_memory_as_value = false |
| 347 | |
| 348 | # Deprecated - use processes.default_tree. |
| 349 | # Show tree mode by default in the processes widget. |
| 350 | #tree = false |
| 351 | |
| 352 | # Shows an indicator in table widgets tracking where in the list you are. |
| 353 | #show_table_scroll_position = false |
| 354 | |
| 355 | # Show a scroll bar on the right edge of table widgets. |
| 356 | #show_table_scroll_bar = false |
| 357 | |
| 358 | # Deprecated - use processes.process_command. |
| 359 | # Show processes as their commands by default in the process widget. |
| 360 | #process_command = false |
| 361 | |
| 362 | # Deprecated - use network_graph.use_binary_prefix. |
| 363 | # Displays the network widget with binary prefixes. |
| 364 | #network_use_binary_prefix = false |
| 365 | |
| 366 | # Deprecated - use network_graph.use_bytes. |
| 367 | # Displays the network widget using bytes. |
| 368 | #network_use_bytes = false |
| 369 | |
| 370 | # Deprecated - use network_graph.use_log. |
| 371 | # Displays the network widget with a log scale. |
| 372 | #network_use_log = false |
| 373 | |
| 374 | # Deprecated - use processes.disable_advanced_kill. |
| 375 | # Hides advanced options to stop a process on Unix-like systems. |
| 376 | #disable_advanced_kill = false |
| 377 | |
| 378 | # Prevents performing any actions that affect the system (e.g. stopping processes). |
| 379 | #read_only = false |
| 380 | |
| 381 | # Deprecated - use processes.hide_k_threads. |
| 382 | # Hide kernel threads from being shown. |
| 383 | #hide_k_threads = false |
| 384 | |
| 385 | # Hide GPU(s) information |
| 386 | #disable_gpu = false |
| 387 | |
| 388 | # Deprecated - use memory.cache_memory. |
| 389 | # Shows cache and buffer memory |
| 390 | #enable_cache_memory = false |
| 391 | |
| 392 | # Deprecated - use memory.free_arc. |
| 393 | # Subtract ARC memory that can be freed from memory usage. |
| 394 | #free_arc = false |
| 395 | |
| 396 | # How much data is stored at once in terms of time. |
| 397 | #retention = "10m" |
| 398 | |
| 399 | # Deprecated - use memory_graph.legend_position or memory.legend_position. |
| 400 | # Where to place the legend for the memory widget. One of "none", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right". |
| 401 | #memory_legend = "top-right" |
| 402 | |
| 403 | # Deprecated - use network_graph.legend_position or network.legend_position. |
| 404 | # Where to place the legend for the network widget. One of "none", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right". |
| 405 | #network_legend = "top-right" |
| 406 | |
| 407 | |
| 408 | # Processes widget configuration |
| 409 | #[processes] |
| 410 | # The columns shown by the process widget. The following columns are supported (the GPU columns are only available if the GPU feature is enabled when built): |
| 411 | # PID, Name, CPU%, Mem%, R/s, W/s, T.Read, T.Write, User, State, Time, GMem%, GPU%, Nice, Priority |
| 412 | #columns = ["PID", "Name", "CPU%", "Mem%", "Virt", "R/s", "W/s", "T.Read", "T.Write", "User", "State", "GMem%", "GPU%", "Priority"] |
| 413 | |
| 414 | # The default sort column when bottom starts. Accepts any of the column names above. |
| 415 | # If unset, defaults to CPU%. |
| 416 | #default_sort = "CPU%" |
| 417 | |
| 418 | # The default sort order. Can be either "Ascending" or "Descending". |
| 419 | # Defaults to sensible defaults for the data type (e.g. descending for CPU/memory usage, ascending for process names). |
| 420 | #sort_order = "Ascending" |
| 421 | |
| 422 | # Gather process child thread information |
| 423 | #get_threads = false |
| 424 | |
| 425 | # Hide kernel threads from being shown. Linux only. |
| 426 | #hide_k_threads = false |
| 427 | |
| 428 | # Collapse the process tree by default when tree mode is set. |
| 429 | #tree_collapse = false |
| 430 | |
| 431 | # Shows the full command name instead of the process name by default. |
| 432 | #process_command = false |
| 433 | |
| 434 | # Disable the advanced kill dialog and just show the basic one with no options. Only available on Linux, macOS, and FreeBSD. |
| 435 | #disable_advanced_kill = false |
| 436 | |
| 437 | # Defaults to showing process memory usage by value. |
| 438 | #default_memory_value = false |
| 439 | |
| 440 | # Groups processes with the same name by default. No effect if tree is set. |
| 441 | #default_grouped = false |
| 442 | |
| 443 | # Enables regex by default while searching. |
| 444 | #regex = false |
| 445 | |
| 446 | # Enables case sensitivity by default when searching. |
| 447 | #case_sensitive = false |
| 448 | |
| 449 | # Enables whole-word matching by default while searching. |
| 450 | #whole_word = false |
| 451 | |
| 452 | # Makes the process widget use tree mode by default. |
| 453 | #default_tree = false |
| 454 | |
| 455 | # Calculates process CPU usage as a percentage of current usage rather than total usage. |
| 456 | #current_usage = false |
| 457 | |
| 458 | # Show process CPU% usage without averaging over the number of CPU cores. |
| 459 | #unnormalized_cpu = false |
| 460 | |
| 461 | |
| 462 | # CPU widget configuration |
| 463 | #[cpu] |
| 464 | # One of "all" (default), "average"/"avg" |
| 465 | #default = "average" |
| 466 | |
| 467 | # Whether to show a decimal place for CPU usage values. |
| 468 | #show_decimal = false |
| 469 | |
| 470 | |
| 471 | # Disk widget configuration |
| 472 | #[disk] |
| 473 | |
| 474 | # The columns shown by the process widget. The following columns are supported: |
| 475 | # Disk, Mount, Used, Free, Total, Used%, Free%, R/s, W/s |
| 476 | #columns = ["Disk", "Mount", "Used", "Free", "Total", "Used%", "R/s", "W/s"] |
| 477 | |
| 478 | # The default sort type. Can be one of the following: |
| 479 | # Disk, Mount, Used, Free, Total, Used%, Free%, R/s, W/s |
| 480 | # |
| 481 | # Defaults to "Disk". |
| 482 | #default_sort = "Disk" |
| 483 | |
| 484 | # The default sort order. Can be either "Ascending" or "Descending". |
| 485 | # Defaults to ascending. |
| 486 | #sort_order = "Ascending" |
| 487 | |
| 488 | # Whether to include block devices that aren't currently mounted (currently Linux only). Defaults to false. |
| 489 | #include_unmounted = false |
| 490 | |
| 491 | # By default, there are no disk name filters enabled. These can be turned on to filter out specific data entries if you |
| 492 | # don't want to see them. An example use case is provided below. |
| 493 | #[disk.name_filter] |
| 494 | # Whether to ignore any matches. Defaults to true. |
| 495 | #is_list_ignored = true |
| 496 | |
| 497 | # A list of filters to try and match. |
| 498 | #list = ["/dev/sda\\d+", "/dev/nvme0n1p2"] |
| 499 | |
| 500 | # Whether to use regex. Defaults to false. |
| 501 | #regex = true |
| 502 | |
| 503 | # Whether to be case-sensitive. Defaults to false. |
| 504 | #case_sensitive = false |
| 505 | |
| 506 | # Whether to require matching the whole word. Defaults to false. |
| 507 | #whole_word = false |
| 508 | |
| 509 | # By default, there are no mount name filters enabled. An example use case is provided below. |
| 510 | #[disk.mount_filter] |
| 511 | # Whether to ignore any matches. Defaults to true. |
| 512 | #is_list_ignored = true |
| 513 | |
| 514 | # A list of filters to try and match. |
| 515 | #list = ["/mnt/.*", "/boot"] |
| 516 | |
| 517 | # Whether to use regex. Defaults to false. |
| 518 | #regex = true |
| 519 | |
| 520 | # Whether to be case-sensitive. Defaults to false. |
| 521 | #case_sensitive = false |
| 522 | |
| 523 | # Whether to require matching the whole word. Defaults to false. |
| 524 | #whole_word = false |
| 525 | |
| 526 | |
| 527 | # Disk I/O graph widget configuration |
| 528 | #[disk_io_graph] |
| 529 | |
| 530 | # Whether to show the read rate line. Defaults to true. |
| 531 | #show_read = true |
| 532 | |
| 533 | # Whether to show the write rate line. Defaults to true. |
| 534 | #show_write = true |
| 535 | |
| 536 | # Whether to label legend entries by device name ("disk") or mount point ("mount"). Defaults to "disk". |
| 537 | #legend = "disk" |
| 538 | |
| 539 | # Whether to use a logarithmic scale on the y-axis. Defaults to false. |
| 540 | #use_log = false |
| 541 | |
| 542 | # Where to place the legend. One of "none", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right". |
| 543 | #legend_position = "top-right" |
| 544 | |
| 545 | # Whether to include block devices that aren't currently mounted (currently Linux only). Defaults to false. |
| 546 | #include_unmounted = false |
| 547 | |
| 548 | # By default, there are no disk I/O name filters enabled. An example use case is provided below. |
| 549 | #[disk_io_graph.name_filter] |
| 550 | # Whether to ignore any matches. Defaults to true. |
| 551 | #is_list_ignored = true |
| 552 | |
| 553 | # A list of filters to try and match. |
| 554 | #list = ["/dev/sda\\d+", "/dev/nvme0n1p2"] |
| 555 | |
| 556 | # Whether to use regex. Defaults to false. |
| 557 | #regex = true |
| 558 | |
| 559 | # Whether to be case-sensitive. Defaults to false. |
| 560 | #case_sensitive = false |
| 561 | |
| 562 | # Whether to require matching the whole word. Defaults to false. |
| 563 | #whole_word = false |
| 564 | |
| 565 | |
| 566 | # Temperature widget configuration |
| 567 | #[temperature] |
| 568 | |
| 569 | # The default sort type. Can be one of the following: |
| 570 | # Temp, Temperature, Sensor |
| 571 | # |
| 572 | # Defaults to "Sensor". |
| 573 | #default_sort = "Sensor" |
| 574 | |
| 575 | # The default sort order. Can be either "Ascending" or "Descending". |
| 576 | # Defaults to ascending. |
| 577 | #sort_order = "Ascending" |
| 578 | |
| 579 | # By default, there are no temperature sensor filters enabled. An example use case is provided below. |
| 580 | #[temperature.sensor_filter] |
| 581 | # Whether to ignore any matches. Defaults to true. |
| 582 | #is_list_ignored = true |
| 583 | |
| 584 | # A list of filters to try and match. |
| 585 | #list = ["cpu", "wifi"] |
| 586 | |
| 587 | # Whether to use regex. Defaults to false. |
| 588 | #regex = false |
| 589 | |
| 590 | # Whether to be case-sensitive. Defaults to false. |
| 591 | #case_sensitive = false |
| 592 | |
| 593 | # Whether to require matching the whole word. Defaults to false. |
| 594 | #whole_word = false |
| 595 | |
| 596 | |
| 597 | # Temperature graph widget configuration |
| 598 | #[temperature_graph] |
| 599 | |
| 600 | # Where to place the legend for the temperature graph widget. One of "none", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right". |
| 601 | #legend_position = "top-right" |
| 602 | |
| 603 | # An upper temperature value for the graph; entries higher than this will be hidden. If not set, |
| 604 | # there is no limit. Is in the configured temperature unit. |
| 605 | #max_temp = 100.0 |
| 606 | |
| 607 | # By default, there are no temperature sensor filters enabled. An example use case is provided below. |
| 608 | #[temperature_graph.sensor_filter] |
| 609 | # Whether to ignore any matches. Defaults to true. |
| 610 | #is_list_ignored = true |
| 611 | |
| 612 | # A list of filters to try and match. |
| 613 | #list = ["cpu", "wifi"] |
| 614 | |
| 615 | # Whether to use regex. Defaults to false. |
| 616 | #regex = false |
| 617 | |
| 618 | # Whether to be case-sensitive. Defaults to false. |
| 619 | #case_sensitive = false |
| 620 | |
| 621 | # Whether to require matching the whole word. Defaults to false. |
| 622 | #whole_word = false |
| 623 | |
| 624 | |
| 625 | # Memory widget configuration |
| 626 | #[memory_graph] |
| 627 | |
| 628 | # Where to place the legend for the memory widget. One of "none", "top-left", "top", "top-right", "left", "right", "bottom-left", "bottom", "bottom-right". |
| 629 | #legend_position = "top-right" |
| 630 | |
| 631 | # Shows cache and buffer memory. Linux only. |
| 632 | #cache_memory = false |
| 633 | |
| 634 | # Subtract ARC memory that can be freed from memory usage. Only available if the ZFS feature is enabled when built. |
| 635 | #free_arc = false |
| 636 | |
| 637 | # Use short GPU names (e.g. "GPU" or "GPU0", "GPU1") instead of full GPU names. Only available if the GPU feature is enabled when built. |
| 638 | #short_gpu_names = false |
| 639 | |
| 640 | |
| 641 | # Network widget configuration |
| 642 | #[network_graph] |
| 643 | |
| 644 | # Whether to display packet rate and average packet size info. Defaults to false. |
| 645 | #show_packets = false |
| 646 | |
| 647 | # Zeroes out the total network usage ("All") counters so it shows the total usage\nsince the app is started, rather than the total usage since boot. |
| 648 | #start_zeroed = false |
| 649 | |
| 650 | # By default, there are no network interface filters enabled. An example use case is provided below. |
| 651 | #[network_graph.interface_filter] |
| 652 | # Whether to ignore any matches. Defaults to true. |
| 653 | #is_list_ignored = true |
| 654 | |
| 655 | # A list of filters to try and match. |
| 656 | #list = ["virbr0.*"] |
| 657 | |
| 658 | # Whether to use regex. Defaults to false. |
| 659 | #regex = true |
| 660 | |
| 661 | # Whether to be case-sensitive. Defaults to false. |
| 662 | #case_sensitive = false |
| 663 | |
| 664 | # Whether to require matching the whole word. Defaults to false. |
| 665 | #whole_word = false |
| 666 | |
| 667 | |
| 668 | # These are all the components that support custom theming. Note that colour support |
| 669 | # will depend on terminal support. |
| 670 | #[styles] # Uncomment if you want to use custom styling |
| 671 | # Built-in themes. Valid values are: |
| 672 | # - "default" |
| 673 | # - "default-light" |
| 674 | # - "gruvbox" |
| 675 | # - "gruvbox-light" |
| 676 | # - "nord" |
| 677 | # - "nord-light". |
| 678 | # |
| 679 | # This will have the lowest precedence if a custom colour palette is set, |
| 680 | # or overridden if the command-line flag for a built-in theme is set. |
| 681 | #theme = "default" |
| 682 | |
| 683 | # Styling options. You can control things like colour choices, text styling (bold, italic, etc), and more. |
| 684 | # Note that any setting that uses the word "colour" can be substituted for "color" and it will still work fine. |
| 685 | |
| 686 | #[styles.cpu] |
| 687 | #all_entry_colour = "green" |
| 688 | #avg_entry_colour = "red" |
| 689 | #cpu_core_colours = ["light magenta", "light yellow", "light cyan", "light green", "light blue", "cyan", "green", "blue"] |
| 690 | |
| 691 | #[styles.temp_graph] |
| 692 | #temp_graph_colour_styles = ["light magenta", "light yellow", "light cyan", "light green", "light blue", "cyan", "green", "blue"] |
| 693 | |
| 694 | #[styles.memory] |
| 695 | #ram_colour = "light magenta" |
| 696 | #cache_colour = "light red" |
| 697 | #swap_colour = "light yellow" |
| 698 | #arc_colour = "light cyan" |
| 699 | #gpu_colours = ["light blue", "light red", "cyan", "green", "blue", "red"] |
| 700 | |
| 701 | #[styles.network] |
| 702 | #rx_colour = "light magenta" |
| 703 | #tx_colour = "light yellow" |
| 704 | #rx_total_colour = "light cyan" |
| 705 | #tx_total_colour = "light green" |
| 706 | |
| 707 | #[styles.battery] |
| 708 | #high_battery_colour = "green" |
| 709 | #medium_battery_colour = "yellow" |
| 710 | #low_battery_colour = "red" |
| 711 | |
| 712 | #[styles.tables] |
| 713 | #headers = {colour = "light blue", bold = true} |
| 714 | |
| 715 | #[styles.graphs] |
| 716 | #graph_colour = "gray" |
| 717 | #legend_text = {colour = "gray"} |
| 718 | |
| 719 | #[styles.widgets] |
| 720 | #border_colour = "gray" |
| 721 | #selected_border_colour = "light blue" |
| 722 | #widget_title = {colour = "gray"} |
| 723 | #text = {colour = "gray"} |
| 724 | #selected_text = {colour = "black", bg_colour = "light blue"} |
| 725 | #disabled_text = {colour = "dark gray"} |
| 726 | # Disabled by default |
| 727 | #bg_colour = "black" |
| 728 | # Only on Linux |
| 729 | #thread_text = {colour = "green"} |
| 730 | |
| 731 | # Layout - layouts follow a pattern like this: |
| 732 | # [[row]] represents a row in the application. |
| 733 | # [[row.child]] represents either a widget or a column. |
| 734 | # [[row.child.child]] represents a widget. |
| 735 | # |
| 736 | # All widgets must have the type value set to one of ["cpu", "mem", "proc", "net", "temp", "temp_graph", "disk", "empty"]. |
| 737 | # All layout components have a ratio value - if this is not set, then it defaults to 1. |
| 738 | # The default widget layout: |
| 739 | #[[row]] |
| 740 | # ratio=30 |
| 741 | # [[row.child]] |
| 742 | # type="cpu" |
| 743 | #[[row]] |
| 744 | # ratio=40 |
| 745 | # [[row.child]] |
| 746 | # ratio=4 |
| 747 | # type="mem" |
| 748 | # [[row.child]] |
| 749 | # ratio=3 |
| 750 | # [[row.child.child]] |
| 751 | # type="temp" |
| 752 | # [[row.child.child]] |
| 753 | # type="disk" |
| 754 | #[[row]] |
| 755 | # ratio=30 |
| 756 | # [[row.child]] |
| 757 | # type="net" |
| 758 | # [[row.child]] |
| 759 | # type="proc" |
| 760 | # default=true |
| 761 | "#; |
| 762 | |
| 763 | #[cfg(test)] |
| 764 | mod test { |
| 765 | use super::*; |
| 766 | |
| 767 | #[test] |
| 768 | fn help_menu_matches_entry_len() { |
| 769 | // Subtract 2 to account for the extra newline + search instructions at the bottom. |
| 770 | const HELP_CONTENTS_TEXT_LEN: usize = HELP_CONTENTS_TEXT.len() - 2; |
| 771 | |
| 772 | assert_eq!( |
| 773 | HELP_CONTENTS_TEXT_LEN, |
| 774 | HELP_TEXT.len(), |
| 775 | "the two should be equal, or this test should be updated" |
| 776 | ) |
| 777 | } |
| 778 | |
| 779 | #[test] |
| 780 | fn help_menu_text_has_sections() { |
| 781 | for (itx, line) in HELP_TEXT.iter().enumerate() { |
| 782 | if itx > 0 { |
| 783 | assert!(line.len() >= 2, "each section should be at least 2 lines"); |
| 784 | assert!(line[0].contains(" - "), "each section should have a header"); |
| 785 | } |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | /// Checks that the default config is valid. |
| 790 | #[test] |
| 791 | #[cfg(feature = "default")] |
| 792 | fn check_default_config() { |
| 793 | use regex::Regex; |
| 794 | |
| 795 | use crate::options::Config; |
| 796 | |
| 797 | // Trim off the starting comment if it's a "#" directly following an |
| 798 | // alphabetical character or '['. |
| 799 | let default_config = Regex::new(r"(?m)^#([a-zA-Z\[])") |
| 800 | .unwrap() |
| 801 | .replace_all(CONFIG_TEXT, "$1"); |
| 802 | |
| 803 | // Then, trim off anything that has more than 2 spaces + alphabetical character |
| 804 | // or '[' following a "#". |
| 805 | let default_config = Regex::new(r"(?m)^#(\s\s+)([a-zA-Z\[])") |
| 806 | .unwrap() |
| 807 | .replace_all(&default_config, "$2"); |
| 808 | |
| 809 | let _config: Config = |
| 810 | toml_edit::de::from_str(&default_config).expect("can parse default config"); |
| 811 | |
| 812 | // TODO: Check this. |
| 813 | // assert_eq!(config, Config::default()); |
| 814 | } |
| 815 | } |