chore(osd): use AstalWp.Endpoint.description instead of name

This commit is contained in:
retrozinndev
2025-06-21 14:20:27 -03:00
parent d13da4f462
commit 3f26a3528b
3 changed files with 42 additions and 61 deletions
+4 -2
View File
@@ -2,10 +2,12 @@
@use "./wal"; @use "./wal";
@use "./functions" as funs; @use "./functions" as funs;
.osd { .osd {
background: funs.toRGB(color.change($color: wal.$background, $alpha: 65%)); background: funs.toRGB(color.change($color: wal.$background, $alpha: 65%));
padding: 14px 16px; padding: 16px;
border-radius: 20px; border-radius: 24px;
min-width: 180px;
.icon { .icon {
margin-right: 10px; margin-right: 10px;
+20 -20
View File
@@ -1,26 +1,26 @@
// SCSS Variables // SCSS Variables
// Generated by 'wal' // Generated by 'wal'
$wallpaper: "/home/joaov/wallpapers/Frieren Rain.jpg"; $wallpaper: "/home/joaov/wallpapers/Gumi Forest Sunlight.jpg";
// Special // Special
$background: #25301c; $background: #2a2825;
$foreground: #c8cbc6; $foreground: #c9c9c8;
$cursor: #c8cbc6; $cursor: #c9c9c8;
// Colors // Colors
$color0: #25301c; $color0: #2a2825;
$color1: #6c8251; $color1: #6a6a3b;
$color2: #7c9357; $color2: #7b7b48;
$color3: #78846e; $color3: #908a45;
$color4: #948a88; $color4: #7e876d;
$color5: #899869; $color5: #8a9680;
$color6: #98a27b; $color6: #a5a679;
$color7: #9ba197; $color7: #a29f98;
$color8: #707c66; $color8: #7d7667;
$color9: #91AE6D; $color9: #8E8E4F;
$color10: #A6C574; $color10: #A5A560;
$color11: #A0B093; $color11: #C0B85C;
$color12: #C6B9B6; $color12: #A9B592;
$color13: #B7CB8D; $color13: #B9C8AB;
$color14: #CBD9A4; $color14: #DDDEA2;
$color15: #c8cbc6; $color15: #c9c9c8;
+13 -34
View File
@@ -1,4 +1,4 @@
import { bind, Binding, Variable } from "astal"; import { bind, Variable } from "astal";
import { Astal, Gtk, Widget } from "astal/gtk3"; import { Astal, Gtk, Widget } from "astal/gtk3";
import { Wireplumber } from "../scripts/volume"; import { Wireplumber } from "../scripts/volume";
@@ -8,7 +8,6 @@ export enum OSDModes {
} }
let osdMode: (Variable<OSDModes>|null); let osdMode: (Variable<OSDModes>|null);
let osdIcon: (Binding<string | undefined>|null);
export function setOSDMode(newMode: OSDModes): void { export function setOSDMode(newMode: OSDModes): void {
if(!osdMode) return; if(!osdMode) return;
@@ -18,31 +17,24 @@ export function setOSDMode(newMode: OSDModes): void {
export const OSD = (mon: number) => { export const OSD = (mon: number) => {
osdMode = new Variable<OSDModes>(OSDModes.SINK); osdMode = new Variable<OSDModes>(OSDModes.SINK);
osdIcon = osdMode().as((mode: OSDModes) => {
switch(mode) {
case OSDModes.SINK: return "󰕾";
case OSDModes.BRIGHTNESS: return "󰃠";
default: return "󱧣";
}
});
return new Widget.Window({ return new Widget.Window({
namespace: "osd", namespace: "osd",
className: "osd-window",
layer: Astal.Layer.OVERLAY, layer: Astal.Layer.OVERLAY,
anchor: Astal.WindowAnchor.BOTTOM, anchor: Astal.WindowAnchor.BOTTOM,
canFocus: false, canFocus: false,
marginBottom: 80,
focusOnClick: false,
clickThrough: true, clickThrough: true,
focusOnClick: false,
marginBottom: 80,
monitor: mon, monitor: mon,
onDestroy: () => { onDestroy: () => {
osdMode?.drop(); osdMode?.drop();
osdMode = null; osdMode = null;
osdIcon = null;
}, },
child: new Widget.Box({ child: new Widget.Box({
className: "osd", className: "osd",
expand: true,
children: [ children: [
new Widget.Icon({ new Widget.Icon({
className: "icon", className: "icon",
@@ -53,37 +45,24 @@ export const OSD = (mon: number) => {
className: "volume", className: "volume",
orientation: Gtk.Orientation.VERTICAL, orientation: Gtk.Orientation.VERTICAL,
valign: Gtk.Align.CENTER, valign: Gtk.Align.CENTER,
expand: true,
children: [ children: [
new Widget.Label({ new Widget.Label({
className: "device", className: "device",
label: bind(Wireplumber.getDefault().getDefaultSink(), "name").as((name: string) => label: bind(Wireplumber.getDefault().getDefaultSink(), "description").as(description =>
name || "Speaker"), description ?? "Speaker"),
halign: Gtk.Align.CENTER truncate: true,
} as Widget.LabelProps), } as Widget.LabelProps),
new Widget.Box({ new Widget.Box({
vexpand: false, expand: true,
expand: false, child: new Widget.LevelBar({
children: [
new Widget.LevelBar({
className: "levelbar", className: "levelbar",
width_request: 120,
value: bind(Wireplumber.getDefault().getDefaultSink(), "volume").as((volume: number) => value: bind(Wireplumber.getDefault().getDefaultSink(), "volume").as((volume: number) =>
Math.floor(volume * 100)), Math.floor(volume * 100)),
maxValue: bind(Wireplumber.getWireplumber(), "defaultSpeaker").as(() => maxValue: bind(Wireplumber.getWireplumber(), "defaultSpeaker").as(() =>
Wireplumber.getDefault().getMaxSinkVolume()), Wireplumber.getDefault().getMaxSinkVolume()),
vexpand: false, expand: true
expand: false, } as Widget.LevelBarProps)
halign: Gtk.Align.CENTER
} as Widget.LevelBarProps),
/*new Widget.Label({
className: "value",
label: bind(Wireplumber.getDefault().getDefaultSink(), "volume").as((volume: number) =>
`${Math.floor(volume * 100)}%`),
vexpand: false,
expand: false,
halign: Gtk.Align.CENTER
} as Widget.LabelProps)*/
]
} as Widget.BoxProps) } as Widget.BoxProps)
] ]
} as Widget.BoxProps) } as Widget.BoxProps)