summaryrefslogtreecommitdiffstats
path: root/src/constants.rs
blob: 09d20d60351d0ad54980984c296b69346eec9842 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
use lazy_static::lazy_static;

// Default widget ID
pub const DEFAULT_WIDGET_ID: u64 = 56709;

// How long to store data.
pub const STALE_MAX_MILLISECONDS: u64 = 600 * 1000; // Keep 10 minutes of data.

// How much data is SHOWN
pub const DEFAULT_TIME_MILLISECONDS: u64 = 60 * 1000; // Defaults to 1 min.
pub const STALE_MIN_MILLISECONDS: u64 = 30 * 1000; // Lowest is 30 seconds
pub const TIME_CHANGE_MILLISECONDS: u64 = 15 * 1000; // How much to increment each time
pub const AUTOHIDE_TIMEOUT_MILLISECONDS: u64 = 5000; // 5 seconds to autohide

pub const TICK_RATE_IN_MILLISECONDS: u64 = 200;
// How fast the screen refreshes
pub const DEFAULT_REFRESH_RATE_IN_MILLISECONDS: u64 = 1000;
pub const MAX_KEY_TIMEOUT_IN_MILLISECONDS: u64 = 1000;
// Number of colours to generate for the CPU chart/table
pub const NUM_COLOURS: i32 = 256;

// Canvas stuff
// The minimum threshold when resizing tables
pub const FORCE_MIN_THRESHOLD: usize = 5;

// Side borders
lazy_static! {
    pub static ref SIDE_BORDERS: tui::widgets::Borders =
        tui::widgets::Borders::from_bits_truncate(20);
    pub static ref TOP_LEFT_RIGHT: tui::widgets::Borders =
        tui::widgets::Borders::from_bits_truncate(22);
    pub static ref BOTTOM_LEFT_RIGHT: tui::widgets::Borders =
        tui::widgets::Borders::from_bits_truncate(28);
    pub static ref DEFAULT_TEXT_STYLE: tui::style::Style =
        tui::style::Style::default().fg(tui::style::Color::Gray);
    pub static ref DEFAULT_HEADER_STYLE: tui::style::Style =
        tui::style::Style::default().fg(tui::style::Color::LightBlue);
}

// Help text
pub const HELP_CONTENTS_TEXT: [&str; 6] = [
    "Press the corresponding numbers to jump to the section, or scroll:\n",
    "1 - General\n",
    "2 - CPU widget\n",
    "3 - Process widget\n",
    "4 - Process search widget\n",
    "5 - Battery widget",
];

pub const GENERAL_HELP_TEXT: [&str; 20] = [
    "1 - General\n",
    "q, Ctrl-c      Quit\n",
    "Esc            Close dialog windows, search, widgets, or exit expanded mode\n",
    "Ctrl-r         Reset display and any collected data\n",
    "f              Freeze/unfreeze updating with new data\n",
    "Ctrl-Arrow     \n",
    "Shift-Arrow    Move to a different widget\n",
    "H/J/K/L        \n",
    "Left, h        Move left within widget\n",
    "Down, j        Move down within widget\n",
    "Up, k          Move up within widget\n",
    "Right, l       Move right within widget\n",
    "?              Open help menu\n",
    "gg             Jump to the first entry\n",
    "G              Jump to the last entry\n",
    "e              Expand the currently selected widget\n",
    "+              Zoom in on chart (decrease time range)\n",
    "-              Zoom out on chart (increase time range)\n",
    "=              Reset zoom\n",
    "Mouse scroll   Scroll through the tables or zoom in/out of charts by scrolling up/down",
];

pub const CPU_HELP_TEXT: [&str; 4] = [
    "2 - CPU widget\n",
    "/              Open filtering for showing certain CPU cores\n",
    "Space          Toggle enabled/disabled cores\n",
    "Esc            Exit filtering mode",
];

pub const PROCESS_HELP_TEXT: [&str; 8] = [
    "3 - Process widget\n",
    "dd             Kill the selected process\n",
    "c              Sort by memory usage, press again to reverse sorting order\n",
    "m              Sort by memory usage\n",
    "p              Sort by PID name, press again to reverse sorting order\n",
    "n              Sort by process name, press again to reverse sorting order\n",
    "Tab            Group/un-group processes with the same name\n",
    "Ctrl-f, /      Open process search widget",
];

pub const SEARCH_HELP_TEXT: [&str; 40] = [
    "4 - Process search widget\n",
    "Tab            Toggle between searching for PID and name\n",
    "Esc            Close the search widget (retains the filter)\n",
    "Ctrl-a         Skip to the start of the search query\n",
    "Ctrl-e         Skip to the end of the search query\n",
    "Ctrl-u         Clear the current search query\n",
    "Backspace      Delete the character behind the cursor\n",
    "Delete         Delete the character at the cursor\n",
    "Alt-c/F1       Toggle matching case\n",
    "Alt-w/F2       Toggle matching the entire word\n",
    "Alt-r/F3       Toggle using regex\n",
    "Left, Alt-h    Move cursor left\n",
    "Right, Alt-l   Move cursor right\n",
    "Search keywords\n",
    "pid\n",
    "cpu\n",
    "mem\n",
    "pid\n",
    "read\n",
    "write\n",
    "tread\n",
    "twrite\n\n",
    "\nComparison operators\n",
    "=\n",
    ">\n",
    "<\n",
    ">=\n",
    "<=\n",
    "\nLogical operators\n",
    "and/&&\n",
    "or/||\n",
    "\nSupported units\n",
    "B\n",
    "KB\n",
    "MB\n",
    "TB\n",
    "KiB\n",
    "MiB\n",
    "GiB\n",
    "TiB\n",
];

pub const BATTERY_HELP_TEXT: [&str; 3] = [
    "5 - Battery widget\n",
    "Left           Go to previous battery\n",
    "Right          Go to next battery",
];

lazy_static! {
    pub static ref HELP_TEXT: Vec<Vec<&'static str>> = vec![
        HELP_CONTENTS_TEXT.to_vec(),
        GENERAL_HELP_TEXT.to_vec(),
        CPU_HELP_TEXT.to_vec(),
        PROCESS_HELP_TEXT.to_vec(),
        SEARCH_HELP_TEXT.to_vec(),
        BATTERY_HELP_TEXT.to_vec(),
    ];
}

// Config and flags
pub const DEFAULT_UNIX_CONFIG_FILE_PATH: &str = ".config/bottom/bottom.toml";
pub const DEFAULT_WINDOWS_CONFIG_FILE_PATH: &str = "bottom/bottom.toml";

// Default config file
pub const DEFAULT_CONFIG_CONTENT: &str = r##"
# This is a default config file for bottom.  All of the settings are commented
# out by default; if you wish to change them uncomment and modify as you see
# fit.

# 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.
[flags]

# Whether to display an average cpu entry.
#avg_cpu = false

# Whether to use dot markers rather than braille.
#dot_marker = false

# The update rate of the application.
#rate = 1000

# Whether to put the CPU legend to the left.
#left_legend = false

# Whether to set CPU% on a process to be based on the total CPU or just current usage.
#current_usage = false

# Whether to group processes with the same name together by default.
#group_processes = false

# Whether to make process searching case sensitive by default.
#case_sensitive = false

# Whether to make process searching look for matching the entire word by default.
#whole_word = false

# Whether to make process searching use regex by default.
#regex = false

# Whether to show CPU entries in the legend when they are hidden.
#show_disabled_data = false

# Defaults to Celsius.  Temperature is one of:
#temperature_type = "k"
#temperature_type = "f"
#temperature_type = "c"
#temperature_type = "kelvin"
#temperature_type = "fahrenheit"
#temperature_type = "celsius"

# The default time interval (in milliseconds).
#default_time_value = 60000

# The time delta on each zoom in/out action (in milliseconds).
#time_delta = 15000

# Override layout default widget
#default_widget_type = "proc"
#default_widget_count = 1

# Use basic mode
#basic = false

# Use the old network legend style
#use_old_network_legend = false

# Remove space in tables
#hide_table_gap = false

##########################################################

# These are all the components that support custom theming.  Note that colour support
# will, at the end of the day, depend on terminal support - for example, the
# macOS default Terminal does NOT like custom colours and it will glitch out.
[colors]

# Represents the colour of table headers (processes, CPU, disks, temperature).
#table_header_color="LightBlue"

# Represents the colour of the label each widget has.
#widget_title_color="Gray"

# Represents the average CPU color.
#avg_cpu_color="Red"

# Represents the colour the core will use in the CPU legend and graph.
#cpu_core_colors=["LightMagenta", "LightYellow", "LightCyan", "LightGreen", "LightBlue", "LightRed", "Cyan", "Green", "Blue", "Red"]

# Represents the colour RAM will use in the memory legend and graph.
#ram_color="LightMagenta"

# Represents the colour SWAP will use in the memory legend and graph.
#swap_color="LightYellow"

# Represents the colour rx will use in the network legend and graph.
#rx_color="LightCyan"

# Represents the colour tx will use in the network legend and graph.
#tx_color="LightGreen"

# Represents the colour of the border of unselected widgets.
#border_color="Gray"

# Represents the colour of the border of selected widgets.
#highlighted_border_color="LightBlue"

# Represents the colour of most text.
#text_color="Gray"

# Represents the colour of text that is selected.
#selected_text_color="Black"

# Represents the background colour of text that is selected.
#selected_bg_color="LightBlue"

# Represents the colour of the lines and text of the graph.
#graph_color="Gray"

# Represents the colours of the battery based on charge
#battery_colors = ["red", "yellow", "yellow", "green", "green", "green"]

##########################################################

# Layout - layouts follow a pattern like this:
# [[row]] represents a row in the application.
# [[row.child]] represents either a widget or a column.
# [[row.child.child]] represents a widget.
#
# All widgets must have the type value set to one of ["cpu", "mem", "proc", "net", "temp", "disk", "empty"].
# All layout components have a ratio value - if this is not set, then it defaults to 1. 

# The default widget layout:
#[[row]]
#  ratio=30
#  [[row.child]]
#  type="cpu"
#[[row]]
#    ratio=40
#    [[row.child]]
#      ratio=4
#      type="mem"
#    [[row.child]]
#      ratio=3
#      [[row.child.child]]
#        type="temp"
#      [[row.child.child]]
#        type="disk"
#[[row]]
#  ratio=30
#  [[row.child]]
#    type="net"
#  [[row.child]]
#    type="proc"
#    default=true
"##;