Skip to content

Commit

Permalink
follow suggestion from extension.gnome.org review
Browse files Browse the repository at this point in the history
  • Loading branch information
biji committed Feb 22, 2022
1 parent 5d1afa7 commit 46e7a9f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 182 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Harddisk LED
Gnome extension to Show harddisk activity (IO speed read/write and LED). Click to change led size
# Harddisk LED

Gnome extension to Show harddisk activity (IO speed read/write and LED). Click to change modes

https://extensions.gnome.org/extension/988/harddisk-led/
92 changes: 0 additions & 92 deletions convenience.js

This file was deleted.

111 changes: 53 additions & 58 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const Mainloop = imports.mainloop;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;

const PREFS_SCHEMA = 'org.gnome.shell.extensions.harddiskled';
const refreshTime = 2.0;
Expand All @@ -25,66 +24,9 @@ let lastCount, lastSpeed;
let mode;
let layoutManager;
let ioSpeedStaticIcon;
let ioSpeedStaticIconx;
let ioSpeedIcon;

function init() {

settings = Convenience.getSettings(PREFS_SCHEMA);

mode = settings.get_int('mode'); // default mode

button = new St.Button({
style_class: 'panel-button',
reactive: true,
can_focus: true,
x_expand: true,
y_expand: false,
track_hover: true
});

layoutManager = new St.BoxLayout({
vertical: false,
style_class: 'harddiskled-container'});

/*
icon = new St.Icon({
gicon: Gio.icon_new_for_string(Me.path + "/icons/harddisk.svg")
});
iconDark = new St.Icon({
gicon: Gio.icon_new_for_string(Me.path + "/icons/harddisk-dark.svg")
});*/

ioSpeedStaticIcon = new St.Icon({
style_class: 'system-status-icon',
y_align: Clutter.ActorAlign.CENTER,
gicon: Gio.icon_new_for_string('drive-harddisk-symbolic')
});

ioSpeed = new St.Label({
text: '---',
y_align: Clutter.ActorAlign.CENTER,
style_class: 'harddiskled-label'
});

ioSpeedStaticIconx = new St.Label({
text: '💾',
style_class: 'harddiskled-static-icon'
});

ioSpeedIcon = new St.Label({
text: '',
y_align: Clutter.ActorAlign.CENTER,
style_class: 'harddiskled-icon'
});

layoutManager.add(ioSpeedStaticIcon);
layoutManager.add(ioSpeedIcon);
layoutManager.add(ioSpeed);
button.connect('button-press-event', changeMode);

button.set_child(layoutManager);

cur = 0;
lastCount = 0;
}
Expand Down Expand Up @@ -206,11 +148,64 @@ function speedToString(amount) {
}

function enable() {
settings = ExtensionUtils.getSettings(PREFS_SCHEMA);

mode = settings.get_int('mode'); // default mode

button = new St.Button({
style_class: 'panel-button',
reactive: true,
can_focus: true,
x_expand: true,
y_expand: false,
track_hover: true
});

layoutManager = new St.BoxLayout({
vertical: false,
style_class: 'harddiskled-container'});

/*
icon = new St.Icon({
gicon: Gio.icon_new_for_string(Me.path + "/icons/harddisk.svg")
});
iconDark = new St.Icon({
gicon: Gio.icon_new_for_string(Me.path + "/icons/harddisk-dark.svg")
});*/

ioSpeedStaticIcon = new St.Icon({
style_class: 'system-status-icon',
y_align: Clutter.ActorAlign.CENTER,
gicon: Gio.icon_new_for_string('drive-harddisk-symbolic')
});

ioSpeed = new St.Label({
text: '---',
y_align: Clutter.ActorAlign.CENTER,
style_class: 'harddiskled-label'
});

ioSpeedIcon = new St.Label({
text: '',
y_align: Clutter.ActorAlign.CENTER,
style_class: 'harddiskled-icon'
});

layoutManager.add(ioSpeedStaticIcon);
layoutManager.add(ioSpeedIcon);
layoutManager.add(ioSpeed);
button.connect('button-press-event', changeMode);

button.set_child(layoutManager);

Main.panel._rightBox.insert_child_at_index(button, 0);
timeout = Mainloop.timeout_add_seconds(refreshTime, parseStat);
}

function disable() {
Mainloop.source_remove(timeout);
timeout = null;
Main.panel._rightBox.remove_child(button);
button.destroy();
settings = button = layoutManager = ioSpeedStaticIcon = ioSpeed = ioSpeedIcon = null;
}
32 changes: 2 additions & 30 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,14 @@
"description": "Show harddisk activity (IO speed read/write and LED). Click to change led size",
"name": "Harddisk LED",
"shell-version": [
"3.14",
"3.16",
"3.18",
"3.20",
"3.22",
"3.24",
"3.26",
"3.28",
"3.30",
"3.32",
"3.34",
"3.36",
"3.38",
"40",
"41",
"42",
"43",
"44",
"45",
"46",
"47",
"48",
"49",
"50",
"51",
"52",
"53",
"54",
"55",
"56",
"57",
"58",
"59",
"60"
"41"
],
"url": "https://github.com/biji/harddiskled",
"uuid": "[email protected]",
"version": 27
"version": 29
}

0 comments on commit 46e7a9f

Please sign in to comment.