Skip to content

Commit

Permalink
diskspace@schorschii: option to display reserved blocks as free space (
Browse files Browse the repository at this point in the history
…#942)

* add option to display reserved blocks as free space
  • Loading branch information
schorschii authored Oct 29, 2023
1 parent 62c66e9 commit 38ae871
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
7 changes: 6 additions & 1 deletion diskspace@schorschii/files/diskspace@schorschii/desklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ MyDesklet.prototype = {
// initialize settings
this.settings = new Settings.DeskletSettings(this, this.metadata["uuid"], desklet_id);
this.settings.bindProperty(Settings.BindingDirection.IN, "size-prefix", "size_prefix", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "reserved-blocks-as-used-space", "reserved_blocks_as_used_space", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "hide-decorations", "hide_decorations", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "use-custom-label", "use_custom_label", this.on_setting_changed);
this.settings.bindProperty(Settings.BindingDirection.IN, "custom-label", "custom_label", this.on_setting_changed);
Expand Down Expand Up @@ -149,7 +150,11 @@ MyDesklet.prototype = {
let fileInfo = file.query_filesystem_info_finish(response);
avail = fileInfo.get_attribute_uint64(Gio.FILE_ATTRIBUTE_FILESYSTEM_FREE);
size = fileInfo.get_attribute_uint64(Gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE);
use = size - avail;
if(this.reserved_blocks_as_used_space) {
use = size - avail;
} else {
use = fileInfo.get_attribute_uint64(Gio.FILE_ATTRIBUTE_FILESYSTEM_USED);
}
percentString = Math.round(use * 100 / size) + "%";
} catch(err) {
// e.g. file not found (= not mounted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"max-instances": "10",
"description": "Displays the usage of a filesystem or RAM.",
"name": "Disk Space",
"version": "1.14",
"version": "1.15",
"uuid": "diskspace@schorschii"
}
6 changes: 6 additions & 0 deletions diskspace@schorschii/files/diskspace@schorschii/po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ msgstr "Dateisystem, welches angezeigt werden soll"
msgid "Select the file system, which you want to monitor."
msgstr "Wählen Sie das Dateisystem, welches Sie anzeigen möchten."

msgid "Show reserved blocks as used space"
msgstr "Zeige reservierte Blöcke als verwendeten Speicher"

msgid "Reserved blocks are useable for the root user only and that's why displayed as used space by default."
msgstr "Reservierte Blöcke sind nur vom root-Benutzer verwendbar und daher standardmäßig ausgeblendet."

msgid "Visual"
msgstr "Visuelle Einstellungen"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ msgstr ""
msgid "Select the file system, which you want to monitor."
msgstr ""

msgid "Show reserved blocks as used space"
msgstr ""

msgid "Reserved blocks are useable for the root user only and that's why displayed as used space by default."
msgstr ""

msgid "Visual"
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@
"Nothing" : "nothing"
}
},
"size-prefix": {
"type": "combobox",
"default": "binary",
"description": "Size Prefix",
"options" : {
"Decimal" : "decimal",
"Binary": "binary"
}
},
"reserved-blocks-as-used-space": {
"type": "checkbox",
"description": "Show reserved blocks as used space",
"tooltip": "Reserved blocks are useable for the root user only and that's why displayed as used space by default.",
"default": true
},

"head2": {
"type": "header",
Expand Down Expand Up @@ -67,15 +82,6 @@
"No text": "none"
}
},
"size-prefix": {
"type": "combobox",
"default": "binary",
"description": "Size Prefix",
"options" : {
"Decimal" : "decimal",
"Binary": "binary"
}
},
"hide-decorations": {
"type": "checkbox",
"description": "Hide decorations",
Expand Down

0 comments on commit 38ae871

Please sign in to comment.