2024-01-30 11:29:07 -05:00
|
|
|
const Audio = await Service.import('audio');
|
|
|
|
|
|
|
|
const { Label } = Widget;
|
2023-11-27 22:02:28 -05:00
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
import OSD from './ctor.ts';
|
2023-11-27 22:02:28 -05:00
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
import Brightness from '../../services/brightness.ts';
|
|
|
|
import { SpeakerIcon } from '../misc/audio-icons.ts';
|
|
|
|
import { MicIcon } from '../misc/audio-icons.ts';
|
2023-11-27 22:02:28 -05:00
|
|
|
|
|
|
|
const AUDIO_MAX = 1.5;
|
|
|
|
|
2023-12-21 01:25:59 -05:00
|
|
|
|
2024-02-27 18:27:47 -05:00
|
|
|
export const SpeakerOSD = () => OSD({
|
2024-02-27 16:55:01 -05:00
|
|
|
name: 'speaker',
|
|
|
|
icon: SpeakerIcon.bind(),
|
2023-11-27 22:02:28 -05:00
|
|
|
info: {
|
2024-02-27 16:55:01 -05:00
|
|
|
mod: Audio.speaker,
|
|
|
|
signal: ['notify::volume', 'notify::is-muted'],
|
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;
|
|
|
|
|
2024-01-29 20:56:56 -05:00
|
|
|
self.sensitive = !Audio.speaker.stream?.is_muted;
|
2023-11-27 22:02:28 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-02-27 18:27:47 -05:00
|
|
|
export const ScreenBrightnessOSD = () => OSD({
|
2024-02-27 16:55:01 -05:00
|
|
|
name: 'screen',
|
|
|
|
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-02-27 18:27:47 -05:00
|
|
|
export const KbdBrightnessOSD = () => OSD({
|
2024-02-27 16:55:01 -05:00
|
|
|
name: 'kbd',
|
2023-11-27 22:02:28 -05:00
|
|
|
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-02-27 18:27:47 -05:00
|
|
|
export const MicOSD = () => OSD({
|
2024-02-27 16:55:01 -05:00
|
|
|
name: 'mic',
|
|
|
|
icon: MicIcon.bind(),
|
2023-11-27 22:02:28 -05:00
|
|
|
info: {
|
2024-02-27 16:55:01 -05:00
|
|
|
mod: Audio.microphone,
|
|
|
|
signal: ['notify::volume', 'notify::is-muted'],
|
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;
|
2024-01-29 20:56:56 -05:00
|
|
|
self.sensitive = !Audio.microphone.stream?.is_muted;
|
2023-11-27 22:02:28 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-02-27 18:27:47 -05:00
|
|
|
export const CapsLockOSD = () => OSD({
|
2024-02-27 16:55:01 -05:00
|
|
|
name: 'caps',
|
|
|
|
icon: Brightness.bind('capsIcon'),
|
2023-11-27 22:02:28 -05:00
|
|
|
info: {
|
|
|
|
mod: Brightness,
|
|
|
|
signal: 'caps',
|
|
|
|
widget: Label({
|
|
|
|
vpack: 'center',
|
|
|
|
label: 'Caps Lock',
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
});
|