2023-11-27 22:02:28 -05:00
|
|
|
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
|
2023-12-15 09:17:03 -05:00
|
|
|
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
|
2023-11-27 22:02:28 -05:00
|
|
|
|
|
|
|
import { Label } from 'resource:///com/github/Aylur/ags/widget.js';
|
|
|
|
import OSD from './ctor.js';
|
|
|
|
|
|
|
|
import Brightness from '../../services/brightness.js';
|
|
|
|
import { SpeakerIcon } from '../misc/audio-icons.js';
|
|
|
|
import { MicIcon } from '../misc/audio-icons.js';
|
|
|
|
|
|
|
|
const AUDIO_MAX = 1.5;
|
|
|
|
|
2023-12-15 09:17:03 -05:00
|
|
|
const ShowSpeaker = Variable(true);
|
|
|
|
|
|
|
|
globalThis.showSpeaker = () => {
|
|
|
|
ShowSpeaker.value = !ShowSpeaker.value;
|
|
|
|
};
|
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
// Types
|
|
|
|
import AgsStack from 'types/widgets/stack.js';
|
2023-12-21 01:25:59 -05:00
|
|
|
|
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
export const SpeakerOSD = (stack: AgsStack) => OSD({
|
2023-11-27 22:02:28 -05:00
|
|
|
stack,
|
2023-12-21 01:25:59 -05:00
|
|
|
icon: { icon: SpeakerIcon.bind() },
|
2023-11-27 22:02:28 -05:00
|
|
|
info: {
|
2023-12-15 09:17:03 -05:00
|
|
|
mod: ShowSpeaker,
|
2023-12-21 01:25:59 -05:00
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
logic: (self) => {
|
|
|
|
if (!Audio.speaker) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.value = Audio.speaker ?
|
|
|
|
Audio.speaker.volume / AUDIO_MAX :
|
|
|
|
0;
|
|
|
|
|
2023-12-21 01:25:59 -05:00
|
|
|
self.sensitive = !Audio.speaker?.stream.is_muted;
|
2023-11-27 22:02:28 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
export const ScreenBrightnessOSD = (stack: AgsStack) => OSD({
|
2023-11-27 22:02:28 -05:00
|
|
|
stack,
|
2023-12-21 01:25:59 -05:00
|
|
|
icon: { icon: Brightness.bind('screenIcon') },
|
2023-11-27 22:02:28 -05:00
|
|
|
info: {
|
|
|
|
mod: Brightness,
|
|
|
|
signal: 'screen',
|
2023-12-21 01:25:59 -05:00
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
logic: (self) => {
|
|
|
|
self.value = Brightness.screen;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
export const KbdBrightnessOSD = (stack: AgsStack) => OSD({
|
2023-11-27 22:02:28 -05:00
|
|
|
stack,
|
|
|
|
icon: 'keyboard-brightness-symbolic',
|
|
|
|
info: {
|
|
|
|
mod: Brightness,
|
|
|
|
signal: 'kbd',
|
2023-12-21 01:25:59 -05:00
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
logic: (self) => {
|
|
|
|
if (!self.value) {
|
|
|
|
self.value = Brightness.kbd / 2;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
self.value = Brightness.kbd / 2;
|
|
|
|
self.sensitive = Brightness.kbd !== 0;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
export const MicOSD = (stack: AgsStack) => OSD({
|
2023-11-27 22:02:28 -05:00
|
|
|
stack,
|
2023-12-21 01:25:59 -05:00
|
|
|
icon: { icon: MicIcon.bind() },
|
2023-11-27 22:02:28 -05:00
|
|
|
info: {
|
|
|
|
mod: Audio,
|
|
|
|
signal: 'microphone-changed',
|
2023-12-21 01:25:59 -05:00
|
|
|
|
2023-11-27 22:02:28 -05:00
|
|
|
logic: (self) => {
|
|
|
|
if (!Audio.microphone) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
self.value = Audio.microphone ? Audio.microphone.volume : 0;
|
2023-12-21 01:25:59 -05:00
|
|
|
self.sensitive = !Audio.microphone?.stream.is_muted;
|
2023-11-27 22:02:28 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-01-13 11:15:08 -05:00
|
|
|
export const CapsLockOSD = (stack: AgsStack) => OSD({
|
2023-11-27 22:02:28 -05:00
|
|
|
stack,
|
2023-12-21 01:25:59 -05:00
|
|
|
icon: { icon: Brightness.bind('capsIcon') },
|
2023-11-27 22:02:28 -05:00
|
|
|
info: {
|
|
|
|
mod: Brightness,
|
|
|
|
signal: 'caps',
|
|
|
|
widget: Label({
|
|
|
|
vpack: 'center',
|
|
|
|
label: 'Caps Lock',
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
});
|