forked from Shinonome/dots-hyprland
ags: update to new syntax
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
// This file is for brightness/volume indicators
|
||||
const { GLib, Gtk } = imports.gi;
|
||||
import { App, Service, Utils, Widget } from '../../imports.js';
|
||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
|
||||
const { Box, Label, ProgressBar, Revealer } = Widget;
|
||||
import { MarginRevealer } from '../../lib/advancedwidgets.js';
|
||||
import Brightness from '../../services/brightness.js';
|
||||
import Indicator from '../../services/indicator.js';
|
||||
|
||||
const OsdValue = (name, labelConnections, progressConnections, props = {}) => Box({ // Volume
|
||||
const OsdValue = (name, labelSetup, progressSetup, props = {}) => Box({ // Volume
|
||||
...props,
|
||||
vertical: true,
|
||||
className: 'osd-bg osd-value',
|
||||
@@ -23,8 +22,7 @@ const OsdValue = (name, labelConnections, progressConnections, props = {}) => Bo
|
||||
}),
|
||||
Label({
|
||||
hexpand: false, className: 'osd-value-txt',
|
||||
label: '100',
|
||||
connections: labelConnections,
|
||||
setup: labelSetup,
|
||||
}),
|
||||
]
|
||||
}),
|
||||
@@ -32,41 +30,49 @@ const OsdValue = (name, labelConnections, progressConnections, props = {}) => Bo
|
||||
className: 'osd-progress',
|
||||
hexpand: true,
|
||||
vertical: false,
|
||||
connections: progressConnections,
|
||||
setup: progressSetup,
|
||||
})
|
||||
],
|
||||
});
|
||||
|
||||
const brightnessIndicator = OsdValue('Brightness',
|
||||
[[Brightness, self => {
|
||||
self.label = `${Math.round(Brightness.screen_value * 100)}`;
|
||||
}, 'notify::screen-value']],
|
||||
[[Brightness, (progress) => {
|
||||
const updateValue = Brightness.screen_value;
|
||||
progress.value = updateValue;
|
||||
}, 'notify::screen-value']],
|
||||
(self) => self
|
||||
.hook(Brightness, self => {
|
||||
self.label = `${Math.round(Brightness.screen_value * 100)}`;
|
||||
}, 'notify::screen-value')
|
||||
,
|
||||
(self) => self
|
||||
.hook(Brightness, (progress) => {
|
||||
const updateValue = Brightness.screen_value;
|
||||
progress.value = updateValue;
|
||||
}, 'notify::screen-value')
|
||||
,
|
||||
)
|
||||
|
||||
const volumeIndicator = OsdValue('Volume',
|
||||
[[Audio, (label) => {
|
||||
label.label = `${Math.round(Audio.speaker?.volume * 100)}`;
|
||||
}]],
|
||||
[[Audio, (progress) => {
|
||||
const updateValue = Audio.speaker?.volume;
|
||||
if (!isNaN(updateValue)) progress.value = updateValue;
|
||||
}]],
|
||||
(self) => self
|
||||
.hook(Audio, (label) => {
|
||||
label.label = `${Math.round(Audio.speaker?.volume * 100)}`;
|
||||
})
|
||||
,
|
||||
(self) => self
|
||||
.hook(Audio, (progress) => {
|
||||
const updateValue = Audio.speaker?.volume;
|
||||
if (!isNaN(updateValue)) progress.value = updateValue;
|
||||
})
|
||||
,
|
||||
);
|
||||
|
||||
export default () => MarginRevealer({
|
||||
transition: 'slide_down',
|
||||
showClass: 'osd-show',
|
||||
hideClass: 'osd-hide',
|
||||
connections: [
|
||||
[Indicator, (revealer, value) => {
|
||||
if(value > -1) revealer._show();
|
||||
else revealer._hide();
|
||||
}, 'popup'],
|
||||
],
|
||||
extraSetup: (self) => self
|
||||
.hook(Indicator, (revealer, value) => {
|
||||
if (value > -1) revealer.attribute.show();
|
||||
else revealer.attribute.hide();
|
||||
}, 'popup')
|
||||
,
|
||||
child: Box({
|
||||
hpack: 'center',
|
||||
vertical: false,
|
||||
|
||||
Reference in New Issue
Block a user