Skip to content

Commit e819066

Browse files
authored
Merge pull request #13 from Ory0n/gnome-3.34
Gnome 3.38
2 parents 62e2214 + 7d5ffac commit e819066

File tree

8 files changed

+108
-29
lines changed

8 files changed

+108
-29
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ You can get this extension:
1515
### Using the latest release
1616
1. Unzip the file `Resource_Monitor-x.zip`.
1717
2. Move the `Resource_Monitor-x` folder to `~/.local/share/gnome-shell/extensions/Resource_Monitor@Ory0n`.
18-
3. Activate the extensions with Gnome Tweak Tool.
18+
3. Activate the extensions with Gnome Extensions.
1919

2020
For example...
2121
```
2222
unzip Resource_Monitor-x.zip
2323
mv Resource_Monitor-x ~/.local/share/gnome-shell/extensions/Resource_Monitor@Ory0n
2424
25-
gnome-shell-extension-tool -e Resource_Monitor@Ory0n
25+
gnome-extensions enable Resource_Monitor@Ory0n
2626
```
2727

2828
### Cloning the repository
2929
1. Clone the Master repository.
3030
2. Move the `Resource_Monitor` folder to `~/.local/share/gnome-shell/extensions/Resource_Monitor@Ory0n`.
31-
3. Activate the extensions with Gnome Tweak Tool.
31+
3. Activate the extensions with Gnome Extensions.
3232

3333
For example...
3434
```
3535
git clone https://github.com/Ory0n/Resource_Monitor
3636
mv Resource_Monitor ~/.local/share/gnome-shell/extensions/Resource_Monitor@Ory0n
3737
38-
gnome-shell-extension-tool -e Resource_Monitor@Ory0n
38+
gnome-extensions enable Resource_Monitor@Ory0n
3939
```
4040
Might require a Gnome restart. Press `ALT+F2` and type `r` and hit enter.
4141

@@ -44,6 +44,7 @@ Might require a Gnome restart. Press `ALT+F2` and type `r` and hit enter.
4444

4545
- **Refresh Time:** Choose the refresh interval, from 1 to 30 seconds.
4646
- **Display Icons:** Display or hide the icons.
47+
- **Display Decimals:** Display or hide decimal numbers.
4748
- **Display Cpu:** Display or hide the Cpu field.
4849
- **Modify Width Cpu:** Resize the Cpu field.
4950
- **Display Ram:** Display or hide the Ram field.
@@ -64,6 +65,11 @@ Might require a Gnome restart. Press `ALT+F2` and type `r` and hit enter.
6465
Use the GitHub [Issues](https://github.com/Ory0n/Resource_Monitor/issues) tracker to report issues or ask for features.
6566

6667
# Change Log
68+
**version 9 (Nov 6, 2020)**
69+
- Added support for gnome 3.38.
70+
- Added Display Decimals function.
71+
- Text Bug fixed.
72+
6773
**version 8 (Apr 6, 2020)**
6874
- Added support for gnome 3.36.
6975
- Added CPU temperature monitoring.

extension.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var IndicatorName = Me.metadata['name'];
3737

3838
const INTERVAL = 'interval';
3939
const ICONS = 'icons';
40+
const DECIMALS = 'decimals';
4041
const CPU = 'cpu';
4142
const RAM = 'ram';
4243
const DISK = 'disk';
@@ -105,6 +106,11 @@ var ResourceMonitor = GObject.registerClass(
105106
this.sigId[this.numSigId++] = this._settings.connect(`changed::${ICONS}`, this.iconsChange.bind(this));
106107
this.iconsChange();
107108

109+
// Decimals
110+
this.displayDecimals;
111+
this.sigId[this.numSigId++] = this._settings.connect(`changed::${DECIMALS}`, this.decimalsChange.bind(this));
112+
this.decimalsChange();
113+
108114
// Cpu
109115
this.enCpu;
110116
this.sigId[this.numSigId++] = this._settings.connect(`changed::${CPU}`, this.cpuChange.bind(this));
@@ -394,6 +400,10 @@ var ResourceMonitor = GObject.registerClass(
394400
}
395401
}
396402

403+
decimalsChange() {
404+
this.displayDecimals = this._settings.get_boolean(DECIMALS);
405+
}
406+
397407
cpuChange() {
398408
this.enCpu = this._settings.get_boolean(CPU);
399409
if (this.enCpu) {
@@ -610,7 +620,11 @@ var ResourceMonitor = GObject.registerClass(
610620
this.cpuTotOld = cpuTot;
611621
this.idleOld = idle;
612622

613-
this.cpu.text = `${cpuCurr.toFixed(1)}`;
623+
if (this.displayDecimals) {
624+
this.cpu.text = `${cpuCurr.toFixed(1)}`;
625+
} else {
626+
this.cpu.text = `${cpuCurr.toFixed(0)}`;
627+
}
614628
}
615629

616630
refreshRam() {
@@ -638,7 +652,11 @@ var ResourceMonitor = GObject.registerClass(
638652

639653
used = total - free - buffer - cached;
640654

641-
this.ram.text = `${(100*used/total).toFixed(1)}`;
655+
if (this.displayDecimals) {
656+
this.ram.text = `${(100*used/total).toFixed(1)}`;
657+
} else {
658+
this.ram.text = `${(100*used/total).toFixed(0)}`;
659+
}
642660
}
643661

644662
refreshDisk() {
@@ -699,7 +717,11 @@ var ResourceMonitor = GObject.registerClass(
699717

700718
this.idleDiskOld = idle;
701719

702-
this.disk.text = `${rw[0].toFixed(1)}|${rw[1].toFixed(1)}`;
720+
if (this.displayDecimals) {
721+
this.disk.text = `${rw[0].toFixed(1)}|${rw[1].toFixed(1)}`;
722+
} else {
723+
this.disk.text = `${rw[0].toFixed(0)}|${rw[1].toFixed(0)}`;
724+
}
703725
}
704726

705727
refreshEth() {
@@ -748,7 +770,11 @@ var ResourceMonitor = GObject.registerClass(
748770

749771
this.idleEthOld = idle;
750772

751-
this.eth.text = `${du[0].toFixed(1)}|${du[1].toFixed(1)}`;
773+
if (this.displayDecimals) {
774+
this.eth.text = `${du[0].toFixed(1)}|${du[1].toFixed(1)}`;
775+
} else {
776+
this.eth.text = `${du[0].toFixed(0)}|${du[1].toFixed(0)}`;
777+
}
752778
}
753779

754780
refreshWlan() {
@@ -797,7 +823,11 @@ var ResourceMonitor = GObject.registerClass(
797823

798824
this.idleWlanOld = idle;
799825

800-
this.wlan.text = `${du[0].toFixed(1)}|${du[1].toFixed(1)}`;
826+
if (this.displayDecimals) {
827+
this.wlan.text = `${du[0].toFixed(1)}|${du[1].toFixed(1)}`;
828+
} else {
829+
this.wlan.text = `${du[0].toFixed(0)}|${du[1].toFixed(0)}`;
830+
}
801831
}
802832

803833
refreshCpuTemperature() {
@@ -809,10 +839,14 @@ var ResourceMonitor = GObject.registerClass(
809839
var temperature = parseInt(contents[1]) / 1000;
810840

811841
if (this.cpuTemperatureFahrenheit) {
812-
temperature = (temperature * 1,8) + 32;
842+
temperature = (temperature * 1.8) + 32;
813843
}
814844

815-
this.cpuTemperature.text = `[${temperature.toFixed(1)}`;
845+
if (this.displayDecimals) {
846+
this.cpuTemperature.text = `[${temperature.toFixed(1)}`;
847+
} else {
848+
this.cpuTemperature.text = `[${temperature.toFixed(0)}`;
849+
}
816850
});
817851
} else {
818852
this.cpuTemperature.text = '[Error';

metadata.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"shell-version": [
66
"3.32",
77
"3.34",
8-
"3.36"
8+
"3.36",
9+
"3.38"
910
],
1011
"gettext-domain": "com-github-Ory0n-Resource_Monitor",
1112
"settings-schema": "com.github.Ory0n.Resource_Monitor",
1213
"url": "https://github.com/Ory0n/Resource_Monitor/",
1314
"author": "Giuseppe Silvestro",
14-
"version": 9
15+
"version": 10
1516
}

prefs.js

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,36 @@ const ResourceMonitorPrefsWidget = GObject.registerClass(
114114
this._settings.bind('icons', valueIcons, 'active', Gio.SettingsBindFlags.DEFAULT);
115115
gridIcons.attach(valueIcons, 1, 0, 1, 1);
116116

117+
// DECIMALS
118+
let alignmentDecimals = new Gtk.Alignment({
119+
left_padding: 12,
120+
right_padding: 12
121+
});
122+
123+
globalFrame.add(new Gtk.Label({
124+
label: '<b>%s</b>'.format(_('Decimals')),
125+
use_markup: true,
126+
halign: Gtk.Align.START
127+
}));
128+
globalFrame.add(alignmentDecimals);
129+
130+
let gridDecimals = new Gtk.Grid({
131+
row_spacing: 6
132+
});
133+
alignmentDecimals.add(gridDecimals);
134+
135+
gridDecimals.attach(new Gtk.Label({
136+
label: '%s'.format(_('Display')),
137+
halign: Gtk.Align.START,
138+
hexpand: true
139+
}), 0, 0, 1, 1);
140+
141+
let valueDecimals = new Gtk.Switch({
142+
halign: Gtk.Align.END
143+
});
144+
this._settings.bind('decimals', valueDecimals, 'active', Gio.SettingsBindFlags.DEFAULT);
145+
gridDecimals.attach(valueDecimals, 1, 0, 1, 1);
146+
117147
this.append_page(globalFrame, new Gtk.Label({
118148
label: '<b>%s</b>'.format(_('Global')),
119149
use_markup: true,
@@ -154,8 +184,8 @@ const ResourceMonitorPrefsWidget = GObject.registerClass(
154184

155185
let widthCpu = new Gtk.SpinButton({
156186
adjustment: new Gtk.Adjustment({
157-
lower: 22,
158-
upper: 40,
187+
lower: 1,
188+
upper: 500,
159189
step_increment: 1
160190
}),
161191
halign: Gtk.Align.END,
@@ -206,8 +236,8 @@ const ResourceMonitorPrefsWidget = GObject.registerClass(
206236

207237
let widthRam = new Gtk.SpinButton({
208238
adjustment: new Gtk.Adjustment({
209-
lower: 22,
210-
upper: 40,
239+
lower: 1,
240+
upper: 500,
211241
step_increment: 1
212242
}),
213243
halign: Gtk.Align.END,
@@ -259,8 +289,8 @@ const ResourceMonitorPrefsWidget = GObject.registerClass(
259289

260290
let widthDisk = new Gtk.SpinButton({
261291
adjustment: new Gtk.Adjustment({
262-
lower: 22,
263-
upper: 80,
292+
lower: 1,
293+
upper: 500,
264294
step_increment: 1
265295
}),
266296
halign: Gtk.Align.END,
@@ -401,8 +431,8 @@ const ResourceMonitorPrefsWidget = GObject.registerClass(
401431

402432
let widthEth = new Gtk.SpinButton({
403433
adjustment: new Gtk.Adjustment({
404-
lower: 22,
405-
upper: 80,
434+
lower: 1,
435+
upper: 500,
406436
step_increment: 1
407437
}),
408438
halign: Gtk.Align.END,
@@ -454,7 +484,7 @@ const ResourceMonitorPrefsWidget = GObject.registerClass(
454484
let widthWlan = new Gtk.SpinButton({
455485
adjustment: new Gtk.Adjustment({
456486
lower: 22,
457-
upper: 80,
487+
upper: 500,
458488
step_increment: 1
459489
}),
460490
halign: Gtk.Align.END,
@@ -518,8 +548,8 @@ const ResourceMonitorPrefsWidget = GObject.registerClass(
518548

519549
let widthTemperature = new Gtk.SpinButton({
520550
adjustment: new Gtk.Adjustment({
521-
lower: 22,
522-
upper: 44,
551+
lower: 1,
552+
upper: 500,
523553
step_increment: 1
524554
}),
525555
halign: Gtk.Align.END,
@@ -528,7 +558,7 @@ const ResourceMonitorPrefsWidget = GObject.registerClass(
528558
this._settings.bind('widthcputemperature', widthTemperature, 'value', Gio.SettingsBindFlags.DEFAULT);
529559

530560
gridTemperature.attach(new Gtk.Label({
531-
label: '%s'.format(_('Fahrenait Unit')),
561+
label: '%s'.format(_('Fahrenheit Unit')),
532562
halign: Gtk.Align.START,
533563
hexpand: true
534564
}), 0, 3, 1, 1);

schemas/com.github.Ory0n.Resource_Monitor.gschema.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,11 @@
123123
<description>
124124
</description>
125125
</key>
126+
<key name="decimals" type="b">
127+
<default>true</default>
128+
<summary>Show Decimals</summary>
129+
<description>
130+
</description>
131+
</key>
126132
</schema>
127133
</schemalist>

schemas/gschemas.compiled

72 Bytes
Binary file not shown.

settings.png

-401 Bytes
Loading

stylesheet.css

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
*/
1919

2020
.unit {
21-
font-size: 8pt;
22-
font-weight: normal;
23-
padding-top: 5px;
21+
font-size: 0.625em;
22+
padding-top: 0.4em;
23+
min-width: 1em;
2424
}
2525

2626
.label {
2727
text-align: right;
28-
padding-right: 1px;
28+
font-size: 1em;
29+
padding-right: 0.125em;
30+
min-width: 1em;
2931
}

0 commit comments

Comments
 (0)