chore: lots of improvements, exec apps with uwsm if in usage

also, started using `AstalWp.Endpoint.description` instead of the `name` property when showing device names, thanks to @NotMephisto in #9
This commit is contained in:
retrozinndev
2025-06-15 20:29:16 -03:00
parent 1e0a158b39
commit a669e1acc3
21 changed files with 119 additions and 100 deletions
@@ -7,19 +7,16 @@ import { TilesPages } from "../Tiles";
import { isInstalled } from "../../../scripts/utils";
import { Widget } from "astal/gtk3";
export const TileNightLight = () => isInstalled("hyprsunset") ?
Tile({
export const TileNightLight = () => isInstalled("hyprsunset") ? Tile({
title: tr("control_center.tiles.night_light.title"),
icon: "weather-clear-night-symbolic",
description: Variable.derive([
bind(NightLight.getDefault(), "temperature"),
bind(NightLight.getDefault(), "gamma")
], (temp, gamma) =>
(temp === 6000 ? tr("control_center.tiles.night_light.default_desc")
: `${temp}K`) + (gamma < NightLight.getDefault().maxGamma ?
` (${gamma}%)` : "")
], (temp, gamma) => `${temp === NightLight.getDefault().identityTemperature ?
tr("control_center.tiles.night_light.default_desc") : `${temp}K`} ${
gamma < NightLight.getDefault().maxGamma ? `(${gamma}%)` : ""}`
)(),
iconSize: 16,
onToggledOff: () => NightLight.getDefault().identity = true,
onToggledOn: () => NightLight.getDefault().identity = false,
enableOnClickMore: true,
+10 -8
View File
@@ -18,13 +18,15 @@ export type TileProps = {
}
export function Tile(props: TileProps): (() => Gtk.Widget) {
const toggled = new Variable<boolean>(props.toggleState instanceof Binding ?
(props.toggleState.get() || false) : (props.toggleState || false));
let subscription: () => void;
const subs: Array<() => void> = [];
const toggled = new Variable<boolean>(((props.toggleState instanceof Binding) ?
props.toggleState.get()
: props.toggleState) ?? false);
if(props?.toggleState instanceof Binding)
subscription = props.toggleState.subscribe(val => toggled.set(val || false));
subs.push(props.toggleState.subscribe((state) =>
toggled.set(state ?? false)
));
return () => new Widget.Box({
className: (props.className instanceof Binding) ?
@@ -37,15 +39,15 @@ export function Tile(props: TileProps): (() => Gtk.Widget) {
}`
)()
: toggled().as((state: boolean) =>
`tile ${state ? "toggled" : ""} ${
props.onClickMore ? "has-more" : ""
`tile${state ? " toggled" : ""}${
props.onClickMore ? " has-more" : ""
}`
),
expand: true,
visible: props.visible,
onDestroy: () => {
subs.map(sub => sub?.());
props.onDestroy?.();
subscription?.();
},
children: [
new Widget.Button({