perf(ags): replace exec with execAsync

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

View file

@ -1,4 +1,4 @@
import { exec } from 'resource:///com/github/Aylur/ags/utils.js';
import { exec, execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
import { Powermenu } from './js/powermenu.js';
import { Bar } from './js/bar/main.js';
import { NotificationCenter } from './js/notifications/center.js';
@ -15,7 +15,7 @@ const css = ags.App.configDir + '/style.css';
exec(`sassc ${scss} ${css}`);
exec(`bash -c "$AGS_PATH/startup.sh"`);
execAsync(['bash', '-c', '$AGS_PATH/startup.sh']).catch(print);
export default {
style: css,

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;
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';

View file

@ -1,6 +1,6 @@
const { Box, Slider, Label, Icon, EventBox } = ags.Widget;
const { Box, Slider, Icon, EventBox } = ags.Widget;
const { Audio } = ags.Service;
const { exec } = ags.Utils;
const { execAsync } = ags.Utils;
const items = {
101: 'audio-volume-overamplified-symbolic',
@ -10,18 +10,6 @@ const items = {
0: 'audio-volume-muted-symbolic',
};
let throttleTimer;
const throttle = (callback, time) => {
if (throttleTimer) return;
throttleTimer = true;
setTimeout(() => {
callback();
throttleTimer = false;
}, time);
}
export const SliderBox = Box({
className: 'slider-box',
vertical: true,
@ -84,11 +72,11 @@ export const SliderBox = Box({
['canChange', true],
],
onChange: ({ value }) => {
throttle(() => exec('brightnessctl set ' + value + ' %'), 20);
execAsync(`brightnessctl set ${value}`).catch(print);
},
connections: [[1000, slider => {
if (slider._canChange) {
slider.value = exec('brightnessctl get');
execAsync('brightnessctl get').then(out => slider.value = out).catch(print);
}
}]],
min: 0,