Added a command to adjust volume that respects hyprpanel settings and made bar module settings for click events apply immediately. (#619)
This commit is contained in:
@@ -7,7 +7,6 @@ import { runAsyncCommand, throttledScrollHandler } from 'src/components/bar/util
|
||||
import Variable from 'astal/variable';
|
||||
import { bind } from 'astal/binding.js';
|
||||
import AstalBattery from 'gi://AstalBattery?version=0.1';
|
||||
import { useHook } from 'src/lib/shared/hookHandler';
|
||||
import { onMiddleClick, onPrimaryClick, onScroll, onSecondaryClick } from 'src/lib/shared/eventHandlers';
|
||||
import { getBatteryIcon } from './helpers';
|
||||
|
||||
@@ -102,29 +101,43 @@ const BatteryLabel = (): BarBoxChild => {
|
||||
boxClass: 'battery',
|
||||
props: {
|
||||
setup: (self: Astal.Button): void => {
|
||||
useHook(self, options.bar.scrollSpeed, () => {
|
||||
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.get());
|
||||
let disconnectFunctions: (() => void)[] = [];
|
||||
|
||||
const disconnectPrimary = onPrimaryClick(self, (clicked, event) => {
|
||||
openMenu(clicked, event, 'energymenu');
|
||||
});
|
||||
Variable.derive(
|
||||
[
|
||||
bind(rightClick),
|
||||
bind(middleClick),
|
||||
bind(scrollUp),
|
||||
bind(scrollDown),
|
||||
bind(options.bar.scrollSpeed),
|
||||
],
|
||||
() => {
|
||||
disconnectFunctions.forEach((disconnect) => disconnect());
|
||||
disconnectFunctions = [];
|
||||
|
||||
const disconnectSecondary = onSecondaryClick(self, (clicked, event) => {
|
||||
runAsyncCommand(rightClick.get(), { clicked, event });
|
||||
});
|
||||
const throttledHandler = throttledScrollHandler(options.bar.scrollSpeed.get());
|
||||
|
||||
const disconnectMiddle = onMiddleClick(self, (clicked, event) => {
|
||||
runAsyncCommand(middleClick.get(), { clicked, event });
|
||||
});
|
||||
disconnectFunctions.push(
|
||||
onPrimaryClick(self, (clicked, event) => {
|
||||
openMenu(clicked, event, 'energymenu');
|
||||
}),
|
||||
);
|
||||
|
||||
const disconnectScroll = onScroll(self, throttledHandler, scrollUp.get(), scrollDown.get());
|
||||
return (): void => {
|
||||
disconnectPrimary();
|
||||
disconnectSecondary();
|
||||
disconnectMiddle();
|
||||
disconnectScroll();
|
||||
};
|
||||
});
|
||||
disconnectFunctions.push(
|
||||
onSecondaryClick(self, (clicked, event) => {
|
||||
runAsyncCommand(rightClick.get(), { clicked, event });
|
||||
}),
|
||||
);
|
||||
|
||||
disconnectFunctions.push(
|
||||
onMiddleClick(self, (clicked, event) => {
|
||||
runAsyncCommand(middleClick.get(), { clicked, event });
|
||||
}),
|
||||
);
|
||||
|
||||
disconnectFunctions.push(onScroll(self, throttledHandler, scrollUp.get(), scrollDown.get()));
|
||||
},
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user