Skip to content

Commit

Permalink
Storage and Network Header IO Speed Number Max Figures
Browse files Browse the repository at this point in the history
  • Loading branch information
ljuzig committed Jan 15, 2024
1 parent fb8dd76 commit 87a2531
Show file tree
Hide file tree
Showing 9 changed files with 160 additions and 63 deletions.
4 changes: 3 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
### New features
- New option for Storage Header: an indicator that shows the global read and write speed through a pair of bars [[#14](https://github.com/AstraExt/astra-monitor/issues/14)]
- Graph Width customization: now you can choose the width of the header graphs individually
- Storage and Network Header IO Speed Number Max Figures: now you can choose the maximum number of figures to show in the IO Speed number
- Header Height and Margis customization: as experimental feature, you can now change the height of the header's button and its margins to better fit your desktop environment's theme [[#7](https://github.com/AstraExt/astra-monitor/issues/7)]
- Icon size customization: as experimental feature, now you can choose the size of the icons in the header
- Preference panel reorganized to better fit more options and to organize them in a more logical way

### Bug fixes
- Fixes a bug where the icon and the unit was missing in current sensor value [[#16](https://github.com/AstraExt/astra-monitor/issues/16)]
- Fixed a bug where the icon and the unit was missing in current sensor value [[#16](https://github.com/AstraExt/astra-monitor/issues/16)]
- Fixed a sizing bug when headers have a label that changes often

# Astra Monitor 3 - January 14 2024

Expand Down
92 changes: 48 additions & 44 deletions po/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: AstraMonitor 1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-01-14 23:42+0100\n"
"POT-Creation-Date: 2024-01-15 00:57+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -161,15 +161,15 @@ msgstr[1] ""
msgid "now"
msgstr ""

#: src/sensors/sensorsMenu.js:37 prefs.js:389 prefs.js:391
#: src/sensors/sensorsMenu.js:37 prefs.js:391 prefs.js:393
msgid "Sensors"
msgstr ""

#: src/sensors/sensorsMenu.js:41
msgid "No sensor found"
msgstr ""

#: src/network/networkMenu.js:33 prefs.js:344 prefs.js:346
#: src/network/networkMenu.js:33 prefs.js:345 prefs.js:347
msgid "Network"
msgstr ""

Expand Down Expand Up @@ -420,7 +420,7 @@ msgid "Headers Height"
msgstr ""

#: prefs.js:147 prefs.js:152 prefs.js:180 prefs.js:245 prefs.js:324
#: prefs.js:373 prefs.js:408
#: prefs.js:374 prefs.js:410
msgid "Experimental feature: may require to disable/enable the extension."
msgstr ""

Expand All @@ -444,32 +444,32 @@ msgstr ""
msgid "Processors"
msgstr ""

#: prefs.js:169 prefs.js:226 prefs.js:274 prefs.js:347 prefs.js:392
#: prefs.js:422 prefs.js:426
#: prefs.js:169 prefs.js:226 prefs.js:274 prefs.js:348 prefs.js:394
#: prefs.js:424 prefs.js:428
msgid "Show"
msgstr ""

#: prefs.js:170 prefs.js:227 prefs.js:275 prefs.js:348 prefs.js:393
#: prefs.js:170 prefs.js:227 prefs.js:275 prefs.js:349 prefs.js:395
msgid "Update frequency (seconds)"
msgstr ""

#: prefs.js:174 prefs.js:239 prefs.js:318 prefs.js:402
#: prefs.js:174 prefs.js:239 prefs.js:318 prefs.js:404
msgid "Header"
msgstr ""

#: prefs.js:176 prefs.js:241 prefs.js:320 prefs.js:369 prefs.js:404
#: prefs.js:176 prefs.js:241 prefs.js:320 prefs.js:370 prefs.js:406
msgid "Icon"
msgstr ""

#: prefs.js:177 prefs.js:242 prefs.js:321 prefs.js:370 prefs.js:405
#: prefs.js:177 prefs.js:242 prefs.js:321 prefs.js:371 prefs.js:407
msgid "Show Icon"
msgstr ""

#: prefs.js:179 prefs.js:244 prefs.js:323 prefs.js:372 prefs.js:407
#: prefs.js:179 prefs.js:244 prefs.js:323 prefs.js:373 prefs.js:409
msgid "Icon Size"
msgstr ""

#: prefs.js:180 prefs.js:245 prefs.js:324 prefs.js:373 prefs.js:408
#: prefs.js:180 prefs.js:245 prefs.js:324 prefs.js:374 prefs.js:410
msgid "Default value is 18"
msgstr ""

Expand Down Expand Up @@ -525,7 +525,7 @@ msgstr ""
msgid "Core Bars Breakdown"
msgstr ""

#: prefs.js:204 prefs.js:417
#: prefs.js:204 prefs.js:419
msgid "None"
msgstr ""

Expand All @@ -545,51 +545,51 @@ msgstr ""
msgid "Used Memory"
msgstr ""

#: prefs.js:278 prefs.js:351
#: prefs.js:278 prefs.js:352
msgid "kB/s"
msgstr ""

#: prefs.js:279 prefs.js:352
#: prefs.js:279 prefs.js:353
msgid "KiB/s"
msgstr ""

#: prefs.js:280 prefs.js:353
#: prefs.js:280 prefs.js:354
msgid "kb/s"
msgstr ""

#: prefs.js:281 prefs.js:354
#: prefs.js:281 prefs.js:355
msgid "Kibit/s"
msgstr ""

#: prefs.js:282 prefs.js:355
#: prefs.js:282 prefs.js:356
msgid "kBps"
msgstr ""

#: prefs.js:283 prefs.js:356
#: prefs.js:283 prefs.js:357
msgid "KiBps"
msgstr ""

#: prefs.js:284 prefs.js:357
#: prefs.js:284 prefs.js:358
msgid "Kibps"
msgstr ""

#: prefs.js:285 prefs.js:358
#: prefs.js:285 prefs.js:359
msgid "kbps"
msgstr ""

#: prefs.js:286 prefs.js:359
#: prefs.js:286 prefs.js:360
msgid "Kibitps"
msgstr ""

#: prefs.js:287 prefs.js:360
#: prefs.js:287 prefs.js:361
msgid "k (as kB/s)"
msgstr ""

#: prefs.js:288 prefs.js:361
#: prefs.js:288 prefs.js:362
msgid "Ki (as KiB/s)"
msgstr ""

#: prefs.js:290 prefs.js:363
#: prefs.js:290 prefs.js:364
msgid "Data Unit"
msgstr ""

Expand All @@ -605,78 +605,82 @@ msgstr ""
msgid "Show Storage Usage Percentage"
msgstr ""

#: prefs.js:332 prefs.js:377
#: prefs.js:332 prefs.js:378
msgid "IO"
msgstr ""

#: prefs.js:333 prefs.js:378
#: prefs.js:333 prefs.js:379
msgid "Show Realtime IO Bar"
msgstr ""

#: prefs.js:334 prefs.js:379
#: prefs.js:334 prefs.js:380
msgid "Show IO History Graph"
msgstr ""

#: prefs.js:335 prefs.js:380
#: prefs.js:335 prefs.js:381
msgid "IO History Graph Width"
msgstr ""

#: prefs.js:336 prefs.js:381
#: prefs.js:336 prefs.js:382
msgid "Show IO Speed"
msgstr ""

#: prefs.js:396
#: prefs.js:337 prefs.js:383
msgid "IO Speed Number Max Figures"
msgstr ""

#: prefs.js:398
msgid "Celsius"
msgstr ""

#: prefs.js:397
#: prefs.js:399
msgid "Fahrenheit"
msgstr ""

#: prefs.js:399
#: prefs.js:401
msgid "Temperature Unit"
msgstr ""

#: prefs.js:421
#: prefs.js:423
msgid "Sensor 1"
msgstr ""

#: prefs.js:423 prefs.js:427
#: prefs.js:425 prefs.js:429
msgid "Source"
msgstr ""

#: prefs.js:425
#: prefs.js:427
msgid "Sensor 2"
msgstr ""

#: prefs.js:436
#: prefs.js:438
msgid "Info"
msgstr ""

#: prefs.js:443
#: prefs.js:445
msgid "Version"
msgstr ""

#: prefs.js:444
#: prefs.js:446
msgid "Changelog"
msgstr ""

#: prefs.js:445
#: prefs.js:447
msgid "GitHub"
msgstr ""

#: prefs.js:446
#: prefs.js:448
msgid "GNOME Extensions page"
msgstr ""

#: prefs.js:447
#: prefs.js:449
msgid "Report a bug or suggest new feature"
msgstr ""

#: prefs.js:448
#: prefs.js:450
msgid "Buy us a coffee"
msgstr ""

#: prefs.js:449
#: prefs.js:451
msgid "Become a patron"
msgstr ""
4 changes: 3 additions & 1 deletion prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export default class AstraMonitorPrefs extends ExtensionPreferences {
subtitle: this.tab + _('Experimental feature: may require to disable/enable the extension.') + '\n' + this.tab + _('Default value is 18'),
icon_name: 'am-dialog-warning-symbolic'
}, 'storage-header-icon-size', iconSection, {min: 8, max: 30, digits: 0, step: 1, page: 1}, true);

const barsSection = this.addExpanderRow(_('Main Disk'), group);
this.addSwitchRow(this.tab + _('Show Storage Usage Bar'), 'storage-header-bars', barsSection);
this.addSwitchRow(this.tab + _('Show Storage Usage Percentage'), 'storage-header-percentage', barsSection);
Expand All @@ -334,6 +334,7 @@ export default class AstraMonitorPrefs extends ExtensionPreferences {
this.addSwitchRow(this.tab + _('Show IO History Graph'), 'storage-header-graph', ioSection);
this.addSpinRow({title: this.tab + _('IO History Graph Width')}, 'storage-header-graph-width', ioSection, {min: 10, max: 500, digits: 0, step: 1, page: 10}, true);
this.addSwitchRow(this.tab + _('Show IO Speed'), 'storage-header-io', ioSection);
this.addSpinRow({title: this.tab + _('IO Speed Number Max Figures')}, 'storage-header-io-figures', ioSection, {min: 2, max: 4, digits: 0, step: 1, page: 1}, true);

storagePage.add(group);

Expand Down Expand Up @@ -379,6 +380,7 @@ export default class AstraMonitorPrefs extends ExtensionPreferences {
this.addSwitchRow(this.tab + _('Show IO History Graph'), 'network-header-graph', ioSection);
this.addSpinRow({title: this.tab + _('IO History Graph Width')}, 'network-header-graph-width', ioSection, {min: 10, max: 500, digits: 0, step: 1, page: 10}, true);
this.addSwitchRow(this.tab + _('Show IO Speed'), 'network-header-io', ioSection);
this.addSpinRow({title: this.tab + _('IO Speed Number Max Figures')}, 'network-header-io-figures', ioSection, {min: 2, max: 4, digits: 0, step: 1, page: 1}, true);

networkPage.add(group);

Expand Down
12 changes: 12 additions & 0 deletions schemas/org.gnome.shell.extensions.astra-monitor.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,12 @@
<summary>Show Storage IO realtime speed</summary>
<description>Show the IO speed in realtime as a label</description>
</key>
<key name="storage-header-io-figures" type="i">
<default>2</default>
<summary>Max Number Figures</summary>
<description>Max number of figures to show on the IO label</description>
<range min="2" max="4"/>
</key>

<!-- NETWORK -->
<key name="network-update" type="d">
Expand Down Expand Up @@ -330,6 +336,12 @@
<summary>Show Network IO realtime speed</summary>
<description>Show the IO speed in realtime as a label</description>
</key>
<key name="network-header-io-figures" type="i">
<default>2</default>
<summary>Max Number Figures</summary>
<description>Max number of figures to show on the IO label</description>
<range min="2" max="4"/>
</key>

<!-- SENSORS -->
<key name="sensors-update" type="d">
Expand Down
46 changes: 42 additions & 4 deletions src/network/networkHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,26 @@ export const NetworkHeader = GObject.registerClass({
const menu = new NetworkMenu(this, 0.5, St.Side.TOP);
this.setMenu(menu);

this.resetMaxWidths();

Config.bind('network-header-show', this, 'visible', Gio.SettingsBindFlags.GET);

Config.connect(this, 'changed::visible', this.resetMaxWidths.bind(this));
Config.connect(this, 'changed::network-header-io', this.resetMaxWidths.bind(this));
}

resetMaxWidths() {
this.maxWidths = [];

if(!Config.get_boolean('network-header-io'))
return;

if(!this.upload.get_stage() || !this.download.get_stage())
return;

const uploadWidth = this.upload.get_preferred_width(-1);
const downloadWidth = this.download.get_preferred_width(-1);
this.fixSpeedContainerWidth(Math.max(uploadWidth?uploadWidth[1]:0, downloadWidth?downloadWidth[1]:0));
}

buildIcon() {
Expand Down Expand Up @@ -121,10 +140,9 @@ export const NetworkHeader = GObject.registerClass({
this.speedContainer = new St.BoxLayout({
style_class: 'astra-monitor-header-speed-container',
x_align: Clutter.ActorAlign.CENTER,
x_expand: true,
y_align: Clutter.ActorAlign.CENTER,
y_expand: true,
vertical: true,
width: 1
});

this.upload = new St.Label({
Expand Down Expand Up @@ -160,12 +178,32 @@ export const NetworkHeader = GObject.registerClass({
}
else {
const unit = Config.get_string('network-io-unit');
this.upload.text = Utils.formatBytesPerSec(usage.bytesUploadedPerSec, unit, 2, true);
this.download.text = Utils.formatBytesPerSec(usage.bytesDownloadedPerSec, unit, 2, true);
let maxFigures = Config.get_int('network-header-io-figures');
maxFigures = Math.max(1, Math.min(4, maxFigures));
this.upload.text = Utils.formatBytesPerSec(usage.bytesUploadedPerSec, unit, maxFigures, true);
this.download.text = Utils.formatBytesPerSec(usage.bytesDownloadedPerSec, unit, maxFigures, true);

const uploadWidth = this.upload.get_preferred_width(-1);
const downloadWidth = this.download.get_preferred_width(-1);
this.fixSpeedContainerWidth(Math.max(uploadWidth?uploadWidth[1]:0, downloadWidth?downloadWidth[1]:0));
}
});
}

fixSpeedContainerWidth(width) {
this.maxWidths.push(width);

if(this.maxWidths.length > Utils.networkMonitor.updateFrequency * 30)
this.maxWidths.shift();

let max = Math.max(...this.maxWidths);
if(max === this.speedContainer.width)
return;
if(max <= 0)
max = 1;
this.speedContainer.set_width(max);
}

update() {

}
Expand Down
Loading

0 comments on commit 87a2531

Please sign in to comment.