perf(ags): replace exec with execAsync

This commit is contained in:
matt1432 2023-09-26 13:33:30 -04:00
commit b9807c29cf
5 changed files with 21 additions and 31 deletions

View file

@ -1,5 +1,5 @@
const { Label, Icon, Stack, ProgressBar, Overlay, Box } = ags.Widget;
const { exec } = ags.Utils;
const { ProgressBar, Overlay, Box } = ags.Widget;
const { execAsync } = ags.Utils;
import { Separator } from '../misc/separator.js';
import { Heart } from './heart.js';
@ -11,14 +11,16 @@ export const Brightness = Overlay({
className: 'toggle-off brightness',
connections: [
[200, progress => {
let br = exec('brightnessctl get') / 255;
if (br > 0.33) {
progress.value = br;
}
else {
progress.value = 0.33;
}
}]
execAsync('brightnessctl get').then(out => {
let br = out / 255;
if (br > 0.33) {
progress.value = br;
}
else {
progress.value = 0.33;
}
}).catch(print);
}],
],
}),
overlays: [

View file

@ -1,5 +1,5 @@
const { Box, Label } = ags.Widget;
const { subprocess, exec } = ags.Utils;
const { subprocess, execAsync } = ags.Utils;
const deflisten = subprocess;
import { EventBox } from '../misc/cursorbox.js';
@ -13,7 +13,7 @@ deflisten(
export const Heart = EventBox({
halign: 'center',
onPrimaryClickRelease: () => {
exec("bash -c '$AGS_PATH/heart.sh toggle'");
execAsync(['bash', '-c', '$AGS_PATH/heart.sh toggle']).catch(print);
},
child: Box({
className: 'heart-toggle',

View file

@ -1,5 +1,5 @@
const { Box, Label } = ags.Widget;
const { subprocess, exec } = ags.Utils;
const { subprocess } = ags.Utils;
const deflisten = subprocess;
import { EventBox } from '../misc/cursorbox.js';