Skip to content

Commit

Permalink
Merge pull request #3 from DimseBoms/master
Browse files Browse the repository at this point in the history
Fix reinstate battery threshold
  • Loading branch information
egormanga authored Jun 23, 2022
2 parents 9e5305b + fd3815c commit 6d2281e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,17 @@ class HuaweiWmiIndicator extends PanelMenu.Button { // TODO: move to system batt
}

_set_bpm(low, high) {
let file = Gio.File.new_for_path("/sys/devices/platform/huawei-wmi/charge_control_thresholds");
let file_sys = Gio.File.new_for_path("/sys/devices/platform/huawei-wmi/charge_control_thresholds");
let file_def = Gio.File.new_for_path("/etc/default/huawei-wmi/charge_control_thresholds");

if (low || high)
try {
file.replace_contents(`${low} ${high}`, null, false, 0, null);
file_sys.replace_contents(`${low} ${high}`, null, false, 0, null);
file_def.replace_contents(`${low} ${high}`, null, false, 0, null);
} catch (e) {}

try {
[low, high] = ByteArray.toString(file.load_contents(null)[1]).split(' ').map(Number);
[low, high] = ByteArray.toString(file_sys.load_contents(null)[1]).split(' ').map(Number);
} catch (e) {
this._bpm.setSensitive(false);
this._bpm.label.set_text(this._BPM);
Expand Down

0 comments on commit 6d2281e

Please sign in to comment.