From 2f0634ed856c08d0ebc860639b6e2a45c1563966 Mon Sep 17 00:00:00 2001 From: Andreas Fruhwirt Date: Sat, 25 Jul 2026 23:00:00 +0200 Subject: [PATCH] added graph width option and hdd usage/space options --- files/system-monitor-graph@mount/desklet.js | 21 ++++++++++++++----- .../settings-schema.json | 19 +++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/files/system-monitor-graph@mount/desklet.js b/files/system-monitor-graph@mount/desklet.js index 5aa9dee..13a6b63 100644 --- a/files/system-monitor-graph@mount/desklet.js +++ b/files/system-monitor-graph@mount/desklet.js @@ -112,6 +112,7 @@ SystemMonitorGraph.prototype = { this.settings.bindProperty(Settings.BindingDirection.IN, "battery-name", "battery_name", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "filesystem", "filesystem", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "filesystem-label", "filesystem_label", this.on_setting_changed); + this.settings.bindProperty(Settings.BindingDirection.IN, "filesystem-variable", "filesystem_variable", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "gpu-manufacturer", "gpu_manufacturer", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "gpu-variable", "gpu_variable", this.on_setting_changed); this.settings.bindProperty(Settings.BindingDirection.IN, "temperature-units-gpu", "temperature_units_gpu", this.on_setting_changed); @@ -122,6 +123,7 @@ SystemMonitorGraph.prototype = { 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, "scale-size", "scale_size", this.on_setting_changed); + this.settings.bindProperty(Settings.BindingDirection.IN, "graph-width", "graph_width", 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, "line-color-cpu", "line_color_cpu", this.on_setting_changed); @@ -256,7 +258,7 @@ SystemMonitorGraph.prototype = { let unit_size = 15 * this.scale_size * global.ui_scale; // pixels var line_width = unit_size / 15; var margin_up = 3 * unit_size; - var graph_w = 20 * unit_size; + var graph_w = this.graph_width * unit_size; var graph_h = 4 * unit_size; let desklet_w = graph_w + (2 * unit_size); let desklet_h = graph_h + (4 * unit_size); @@ -365,7 +367,16 @@ SystemMonitorGraph.prototype = { if(dir_path == null || dir_path == "") dir_path = "/"; this.get_hdd_values(dir_path); let hdd_use = Math.min(this.hdd_values[1], 100); //already in % - value = hdd_use / 100; + let hdd_free = this.hdd_values[3].toFixed(0); + let hdd_total = this.hdd_values[2].toFixed(0); + switch (this.filesystem_variable) { + case "usage": + value = hdd_use / 100; + break; + case "space": + value = hdd_free / hdd_total; + break; + } let hdd_prefix = ""; if (this.data_prefix_hdd == 1) { // decimal prefix @@ -377,8 +388,8 @@ SystemMonitorGraph.prototype = { text1 = this.filesystem_label; if (text1 == "") text1 = this.hdd_values[0].toString(); text2 = Math.round(hdd_use).toString() + "%" - text3 = this.hdd_values[3].toFixed(0) + " " + hdd_prefix + " " + _("free of") + " " - + this.hdd_values[2].toFixed(0) + " " + hdd_prefix; + text3 = hdd_free + " " + hdd_prefix + " " + _("free of") + " " + + hdd_total + " " + hdd_prefix; break; case "gpu": @@ -562,7 +573,7 @@ SystemMonitorGraph.prototype = { this.text3.style = "font-size: " + text3_size + "px;" + "color: " + this.text_color + ";"; this.text3.set_position( - Math.round((21 * unit_size) - this.text3.get_width()), + Math.round(((this.graph_width+1) * unit_size) - this.text3.get_width()), Math.round((2.5 * unit_size) - this.text3.get_height())); diff --git a/files/system-monitor-graph@mount/settings-schema.json b/files/system-monitor-graph@mount/settings-schema.json index dd0b485..eceacf8 100644 --- a/files/system-monitor-graph@mount/settings-schema.json +++ b/files/system-monitor-graph@mount/settings-schema.json @@ -121,6 +121,17 @@ "tooltip": "Empty uses the filesystem name from df.", "dependency": "type=hdd" }, + "filesystem-variable": { + "type": "combobox", + "default": "usage", + "description": "HDD variable to monitor", + "tooltip": "Select the HDD variable to monitor.", + "options" : { + "Usage" : "usage", + "Space": "space" + }, + "dependency": "type=hdd" + }, "gpu-manufacturer": { "type": "combobox", "default": "nvidia", @@ -305,5 +316,13 @@ "max": 5, "step": 0.1, "description": "Scale factor for desklet size (scale factor of 1 = 330 x 120 px)" + }, + "graph-width": { + "type": "scale", + "default": 20, + "min": 1, + "max": 50, + "step": 1, + "description": "Graph width" } }