()
| 88 | } |
| 89 | |
| 90 | function isUsingBatteryUpower() { |
| 91 | try { |
| 92 | const { stdout } = execa.sync('upower', ['--enumerate']); |
| 93 | const devices = stdout.split('\n').filter(Boolean); |
| 94 | |
| 95 | return devices.some((device) => { |
| 96 | const { stdout } = execa.sync('upower', ['--show-info', device]); |
| 97 | |
| 98 | return /\bpower supply:\s+yes\b/.test(stdout) && /\bstate:\s+discharging\b/.test(stdout); |
| 99 | }); |
| 100 | } catch (ex) { |
| 101 | logger.warn(`Could not get battery status from upower: ${ex}`); |
| 102 | logger.warn(ex.stack); |
| 103 | |
| 104 | return null; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | function isUsingBatteryWindows() { |
| 109 | try { |
no test coverage detected
searching dependent graphs…