add swap option
This commit is contained in:
parent
9f269c1cf6
commit
381e652959
@ -56,6 +56,7 @@ SystemMonitorGraph.prototype = {
|
||||
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);
|
||||
this.settings.bindProperty(Settings.BindingDirection.IN, "line-color-ram", "line_color_ram", this.on_setting_changed);
|
||||
this.settings.bindProperty(Settings.BindingDirection.IN, "line-color-swap", "line_color_swap", this.on_setting_changed);
|
||||
this.settings.bindProperty(Settings.BindingDirection.IN, "line-color-hdd", "line_color_hdd", this.on_setting_changed);
|
||||
this.settings.bindProperty(Settings.BindingDirection.IN, "line-color-gpu", "line_color_gpu", this.on_setting_changed);
|
||||
|
||||
@ -105,6 +106,9 @@ SystemMonitorGraph.prototype = {
|
||||
case "ram":
|
||||
this.line_color = this.line_color_ram;
|
||||
break;
|
||||
case "swap":
|
||||
this.line_color = this.line_color_swap;
|
||||
break;
|
||||
case "hdd":
|
||||
this.line_color = this.line_color_hdd;
|
||||
break;
|
||||
@ -160,6 +164,16 @@ SystemMonitorGraph.prototype = {
|
||||
+ ram_values[0].toFixed(1) + " " + _("GiB");
|
||||
break;
|
||||
|
||||
case "swap":
|
||||
let swap_values = this.get_swap_values();
|
||||
let swap_use = 100 * swap_values[1] / swap_values[0];
|
||||
value = swap_use / 100;
|
||||
text1 = _("Swap");
|
||||
text2 = Math.round(swap_use).toString() + "%"
|
||||
text3 = swap_values[1].toFixed(1) + " / "
|
||||
+ swap_values[0].toFixed(1) + " " + _("GiB");
|
||||
break;
|
||||
|
||||
case "hdd":
|
||||
let dir_path = decodeURIComponent(this.filesystem.replace("file://", "").trim());
|
||||
if(dir_path == null || dir_path == "") dir_path = "/";
|
||||
@ -326,6 +340,17 @@ SystemMonitorGraph.prototype = {
|
||||
return [ram_tot, ram_usd];
|
||||
},
|
||||
|
||||
get_swap_values: function() {
|
||||
// used = total - available
|
||||
let mem_out = Cinnamon.get_file_contents_utf8_sync("/proc/meminfo");
|
||||
let mem_tot = parseInt(mem_out.match(/(SwapTotal):\D+(\d+)/)[2]);
|
||||
let mem_usd = mem_tot - parseInt(mem_out.match(/(SwapFree):\D+(\d+)/)[2]);
|
||||
|
||||
let swap_tot = mem_tot / GIB_TO_KIB;
|
||||
let swap_usd = mem_usd / GIB_TO_KIB;
|
||||
return [swap_tot, swap_usd];
|
||||
},
|
||||
|
||||
get_hdd_values: function(dir_path) {
|
||||
let subprocess = new Gio.Subprocess({
|
||||
argv: ['/bin/df', dir_path],
|
||||
|
||||
@ -31,6 +31,11 @@ msgstr "RAM"
|
||||
msgid "GiB"
|
||||
msgstr "GiB"
|
||||
|
||||
#. settings-schema.json->type->options
|
||||
#: desklet.js:171
|
||||
msgid "Swap"
|
||||
msgstr "Swap"
|
||||
|
||||
#: desklet.js:172
|
||||
msgid "GB free of"
|
||||
msgstr "GB frei von"
|
||||
@ -229,6 +234,10 @@ msgstr "RGB oder RGBA. Alpha wird ignoriert"
|
||||
msgid "Line color RAM"
|
||||
msgstr "RAM-Linienfarbe"
|
||||
|
||||
#. settings-schema.json->line-color-swap->description
|
||||
msgid "Line color Swap"
|
||||
msgstr "Swap-Linienfarbe"
|
||||
|
||||
#. settings-schema.json->line-color-hdd->description
|
||||
msgid "Line color HDD"
|
||||
msgstr "HDD-Linienfarbe"
|
||||
|
||||
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-11-28 13:30-0500\n"
|
||||
"POT-Creation-Date: 2022-04-17 23:21+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -18,33 +18,37 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#. settings-schema.json->type->options
|
||||
#: desklet.js:149
|
||||
#: desklet.js:153
|
||||
msgid "CPU"
|
||||
msgstr ""
|
||||
|
||||
#. settings-schema.json->type->options
|
||||
#: desklet.js:157
|
||||
#: desklet.js:161
|
||||
msgid "RAM"
|
||||
msgstr ""
|
||||
|
||||
#: desklet.js:160
|
||||
#: desklet.js:193
|
||||
#: desklet.js:164 desklet.js:174 desklet.js:207
|
||||
msgid "GiB"
|
||||
msgstr ""
|
||||
|
||||
#: desklet.js:172
|
||||
#. settings-schema.json->type->options
|
||||
#: desklet.js:171
|
||||
msgid "Swap"
|
||||
msgstr ""
|
||||
|
||||
#: desklet.js:186
|
||||
msgid "GB free of"
|
||||
msgstr ""
|
||||
|
||||
#: desklet.js:173
|
||||
#: desklet.js:187
|
||||
msgid "GB"
|
||||
msgstr ""
|
||||
|
||||
#: desklet.js:183
|
||||
#: desklet.js:197
|
||||
msgid "GPU Usage"
|
||||
msgstr ""
|
||||
|
||||
#: desklet.js:190
|
||||
#: desklet.js:204
|
||||
msgid "GPU Memory"
|
||||
msgstr ""
|
||||
|
||||
@ -221,6 +225,7 @@ msgstr ""
|
||||
|
||||
#. settings-schema.json->line-color-cpu->tooltip
|
||||
#. settings-schema.json->line-color-ram->tooltip
|
||||
#. settings-schema.json->line-color-swap->tooltip
|
||||
#. settings-schema.json->line-color-hdd->tooltip
|
||||
#. settings-schema.json->line-color-gpu->tooltip
|
||||
msgid "RGB or RGBA. Alpha is ignored"
|
||||
@ -230,6 +235,10 @@ msgstr ""
|
||||
msgid "Line color RAM"
|
||||
msgstr ""
|
||||
|
||||
#. settings-schema.json->line-color-swap->description
|
||||
msgid "Line color Swap"
|
||||
msgstr ""
|
||||
|
||||
#. settings-schema.json->line-color-hdd->description
|
||||
msgid "Line color HDD"
|
||||
msgstr ""
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
"options" : {
|
||||
"CPU" : "cpu",
|
||||
"RAM" : "ram",
|
||||
"Swap" : "swap",
|
||||
"HDD" : "hdd",
|
||||
"GPU" : "gpu"
|
||||
}
|
||||
@ -125,6 +126,13 @@
|
||||
"dependency": "type=ram",
|
||||
"tooltip": "RGB or RGBA. Alpha is ignored"
|
||||
},
|
||||
"line-color-swap": {
|
||||
"type": "colorchooser",
|
||||
"default": "rgba(137,190,67,1.0)",
|
||||
"description": "Line color Swap",
|
||||
"dependency": "type=swap",
|
||||
"tooltip": "RGB or RGBA. Alpha is ignored"
|
||||
},
|
||||
"line-color-hdd": {
|
||||
"type": "colorchooser",
|
||||
"default": "rgba(197,86,33,1.0)",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user