Add defaults colors depending on the variable to monitor

This commit is contained in:
Raymundo Cassani 2020-05-29 18:13:58 -04:00
parent 9bb24a1d63
commit ea8a932c20
2 changed files with 43 additions and 17 deletions

View File

@ -28,13 +28,18 @@ MyDesklet.prototype = {
this.settings.bindProperty(Settings.BindingDirection.IN, "refresh-interval", "refresh_interval", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "refresh-interval", "refresh_interval", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "duration", "duration", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "duration", "duration", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "custom-line-color", "custom_line_color", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "custom-line-color", "custom_line_color", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "line-color", "line_color", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "background-color", "background_color", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "background-color", "background_color", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "h-midlines", "h_midlines", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "h-midlines", "h_midlines", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "v-midlines", "v_midlines", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "v-midlines", "v_midlines", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "scale-size", "scale_size", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "scale-size", "scale_size", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "midline-color", "midline_color", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "midline-color", "midline_color", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "text-color", "text_color", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "text-color", "text_color", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "line-color-ram", "line_color_ram", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "line-color-cpu", "line_color_cpu", this.on_setting_changed);
// initialize desklet GUI // initialize desklet GUI
this.setupUI(); this.setupUI();
@ -71,6 +76,17 @@ MyDesklet.prototype = {
let cpu_values = this.get_cpu_times(); let cpu_values = this.get_cpu_times();
this.cpu_tot = cpu_values[0]; this.cpu_tot = cpu_values[0];
this.cpu_idl = cpu_values[1]; this.cpu_idl = cpu_values[1];
// set colors
switch (this.type) {
case "cpu":
this.line_color = this.line_color_cpu;
break;
case "ram":
this.line_color = this.line_color_ram;
break;
case "hdd":
this.line_color = this.line_color_hdd;
}
this.first_run = false; this.first_run = false;
} }
@ -96,7 +112,7 @@ MyDesklet.prototype = {
var value = 0.0; var value = 0.0;
var text1 = ''; var text1 = '';
var text2 = ''; var text2 = '';
var line_colors; var line_colors = this.parse_rgba_seetings(this.line_color);
// current values // current values
switch (this.type) { switch (this.type) {
@ -111,7 +127,6 @@ MyDesklet.prototype = {
value = cpu_use / 100; value = cpu_use / 100;
text1 = "CPU"; text1 = "CPU";
text2 = Math.round(cpu_use).toString() + "%"; text2 = Math.round(cpu_use).toString() + "%";
line_colors = [0.09, 0.57, 0.81];
break; break;
case "ram": case "ram":
@ -137,11 +152,6 @@ MyDesklet.prototype = {
values.shift(); values.shift();
this.values = values; this.values = values;
// overrides the line_color if custom_line_color
if (this.custom_line_color){
line_colors = this.parse_rgba_seetings(this.line_color);
}
var background_colors = this.parse_rgba_seetings(this.background_color); var background_colors = this.parse_rgba_seetings(this.background_color);
var midline_colors = this.parse_rgba_seetings(this.midline_color); var midline_colors = this.parse_rgba_seetings(this.midline_color);

View File

@ -15,9 +15,19 @@
"tooltip": "Select the system variable to monitor.", "tooltip": "Select the system variable to monitor.",
"options" : { "options" : {
"CPU" : "cpu", "CPU" : "cpu",
"RAM": "ram" "RAM" : "ram",
"HHD" : "hdd"
} }
}, },
"filesystem": {
"type": "filechooser",
"default": "/",
"description": "Filesystem to monitor",
"tooltip": "Select the file system, which you want to monitor.",
"allow-none" : true,
"select-dir" : true,
"dependency": "type=hdd"
},
"duration": { "duration": {
"type": "combobox", "type": "combobox",
"default": 60, "default": 60,
@ -63,17 +73,23 @@
"default": "rgba(255,255,255,1)", "default": "rgba(255,255,255,1)",
"description": "Text color" "description": "Text color"
}, },
"custom-line-color": { "line-color-cpu": {
"type": "checkbox", "type": "colorchooser",
"default": false, "default": "rgba(23,147,208,1.0)",
"description": "Use a custom line color", "description": "Line color CPU",
"value": false "dependency": "type=cpu"
}, },
"line-color": { "line-color-ram": {
"type": "colorchooser", "type": "colorchooser",
"default": "rgba(137,190,67,1.0)", "default": "rgba(137,190,67,1.0)",
"description": "Line color", "description": "Line color RAM",
"dependency": "custom-line-color" "dependency": "type=ram"
},
"line-color-hdd": {
"type": "colorchooser",
"default": "rgba(197,86,33,1.0)",
"description": "Line color HDD",
"dependency": "type=hdd"
}, },
"midline-color": { "midline-color": {
"type": "colorchooser", "type": "colorchooser",