✨ 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:
@@ -3,17 +3,15 @@ import { Gtk, Widget } from "astal/gtk3";
|
||||
import AstalMpris from "gi://AstalMpris";
|
||||
import { Separator, SeparatorProps } from "../Separator";
|
||||
import { Windows } from "../../windows";
|
||||
import { Clipboard } from "../../scripts/clipboard";
|
||||
|
||||
|
||||
const playerIcons = {
|
||||
spotify: "spotify-symbolic",
|
||||
mpv: "mpv-symbolic",
|
||||
Clapper: "com.github.rafostar.Clapper-symbolic"
|
||||
}
|
||||
};
|
||||
|
||||
export function Media(): Gtk.Widget {
|
||||
|
||||
const connections: Array<number> = [];
|
||||
|
||||
const mediaControlsRevealer: Widget.Revealer = new Widget.Revealer({
|
||||
@@ -32,11 +30,9 @@ export function Media(): Gtk.Widget {
|
||||
icon: "edit-paste-symbolic"
|
||||
} as Widget.IconProps),
|
||||
tooltipText: "Copy link to Clipboard",
|
||||
visible: bind(players[0], "metadata").as((meta) =>
|
||||
Boolean(meta["xesam:url"]?.get_string()[0])),
|
||||
onClick: () => Clipboard.getDefault().copyAsync(
|
||||
players[0].metadata["xesam:url"].get_string()[0]
|
||||
)
|
||||
visible: bind(players[0], "metadata").as((metadata) =>
|
||||
metadata["xesam:url"]?.get_string()[0] != null),
|
||||
onClick: () => console.log(players[0].metadata["xesam:url"]?.get_string()[0]!)
|
||||
} as Widget.ButtonProps),
|
||||
new Widget.Button({
|
||||
className: "previous",
|
||||
|
||||
@@ -73,7 +73,6 @@ class Pages extends Widget.Box {
|
||||
this.#page = undefined;
|
||||
|
||||
timeout(this.#transDuration, () => {
|
||||
pageRevealer.ref();
|
||||
this.remove(pageRevealer);
|
||||
pageRevealer.destroy();
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { exec, execAsync, GLib, Variable } from "astal";
|
||||
import { exec, GLib, Variable } from "astal";
|
||||
import { Gtk, Widget } from "astal/gtk3";
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { Windows } from "../../windows";
|
||||
import { Wallpaper } from "../../scripts/wallpaper";
|
||||
import { execApp } from "../../scripts/apps";
|
||||
|
||||
|
||||
function LockButton(): Widget.Button {
|
||||
@@ -12,7 +12,7 @@ function LockButton(): Widget.Button {
|
||||
} as Widget.IconProps),
|
||||
onClick: () => {
|
||||
Windows.close("control-center");
|
||||
AstalHyprland.get_default().dispatch("exec", "hyprlock");
|
||||
execApp("hyprlock");
|
||||
}
|
||||
} as Widget.ButtonProps)
|
||||
}
|
||||
@@ -22,10 +22,10 @@ function ColorPickerButton(): Widget.Button {
|
||||
image: new Widget.Icon({
|
||||
icon: "color-select-symbolic"
|
||||
} as Widget.IconProps),
|
||||
onClick: () => AstalHyprland.get_default().dispatch(
|
||||
"exec",
|
||||
"sh $HOME/.config/hypr/scripts/color-picker.sh"
|
||||
)
|
||||
onClick: () => {
|
||||
Windows.close("control-center");
|
||||
execApp("sh $HOME/.config/hypr/scripts/color-picker.sh");
|
||||
}
|
||||
} as Widget.ButtonProps)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ function ScreenshotButton(): Widget.Button {
|
||||
} as Widget.IconProps),
|
||||
onClick: () => {
|
||||
Windows.close("control-center");
|
||||
execAsync(`sh ${GLib.get_user_config_dir()}/hypr/scripts/screenshot.sh`);
|
||||
execApp(`sh ${GLib.get_user_config_dir()}/hypr/scripts/screenshot.sh`);
|
||||
}
|
||||
} as Widget.ButtonProps);
|
||||
}
|
||||
@@ -58,7 +58,10 @@ function LogoutButton(): Widget.Button {
|
||||
image: new Widget.Icon({
|
||||
icon: "system-shutdown-symbolic"
|
||||
} as Widget.IconProps),
|
||||
onClick: () => Windows.open("logout-menu")
|
||||
onClick: () => {
|
||||
Windows.close("control-center");
|
||||
Windows.open("logout-menu");
|
||||
}
|
||||
} as Widget.ButtonProps);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ import { Gtk, Widget } from "astal/gtk3";
|
||||
import AstalBluetooth from "gi://AstalBluetooth";
|
||||
import { Page, PageButton } from "./Page";
|
||||
import { tr } from "../../../i18n/intl";
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { Windows } from "../../../windows";
|
||||
import { Notifications } from "../../../scripts/notifications";
|
||||
import AstalNotifd from "gi://AstalNotifd";
|
||||
import { execApp } from "../../../scripts/apps";
|
||||
|
||||
export const BluetoothPage: (() => Page) = () => new Page({
|
||||
id: "bluetooth",
|
||||
@@ -42,7 +42,7 @@ export const BluetoothPage: (() => Page) = () => new Page({
|
||||
title: tr("control_center.pages.more_settings"),
|
||||
onClick: () => {
|
||||
Windows.close("control-center");
|
||||
AstalHyprland.get_default().dispatch("exec", "[float; animation slide right] overskride");
|
||||
execApp("overskride", "[float; animation slide right]");
|
||||
}
|
||||
}],
|
||||
spacing: 2,
|
||||
|
||||
@@ -21,7 +21,7 @@ export function PageMicrophone(): Page {
|
||||
className: bind(microphone, "isDefault").as(isDefault => isDefault ? "default" : ""),
|
||||
icon: bind(microphone, "icon").as(icon =>
|
||||
Astal.Icon.lookup_icon(icon) ? icon : "audio-input-microphone-symbolic"),
|
||||
title: bind(microphone, "name").as(name => name ?? "Microphone"),
|
||||
title: bind(microphone, "description").as(desc => desc ?? "Microphone"),
|
||||
onClick: () => microphone.set_is_default(true),
|
||||
endWidget: new Widget.Icon({
|
||||
icon: "object-select-symbolic",
|
||||
|
||||
@@ -4,8 +4,8 @@ import AstalNetwork from "gi://AstalNetwork";
|
||||
import { bind } from "astal";
|
||||
import NM from "gi://NM";
|
||||
import { Windows } from "../../../windows";
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { tr } from "../../../i18n/intl";
|
||||
import { execApp } from "../../../scripts/apps";
|
||||
|
||||
export const PageNetwork: (() => Page) = () => new Page({
|
||||
id: "network",
|
||||
@@ -27,7 +27,7 @@ export const PageNetwork: (() => Page) = () => new Page({
|
||||
title: tr("control_center.pages.more_settings"),
|
||||
onClick: () => {
|
||||
Windows.close("control-center");
|
||||
AstalHyprland.get_default().dispatch("exec", "[animationstyle gnomed] nm-connection-editor");
|
||||
execApp("nm-connection-editor", "[animationstyle gnomed]");
|
||||
}
|
||||
}],
|
||||
children: [
|
||||
@@ -60,10 +60,10 @@ export const PageNetwork: (() => Page) = () => new Page({
|
||||
} as Widget.IconProps),
|
||||
onClick: () => {
|
||||
Windows.close("control-center");
|
||||
AstalHyprland.get_default().dispatch("exec",
|
||||
`[animationstyle gnomed; float] nm-connection-editor --edit ${
|
||||
dev.activeConnection?.connection.get_uuid()
|
||||
}`);
|
||||
execApp(
|
||||
`nm-connection-editor --edit ${dev.activeConnection?.connection.get_uuid()}`,
|
||||
"[animationstyle gnomed; float]"
|
||||
);
|
||||
}
|
||||
} as Widget.ButtonProps)
|
||||
]
|
||||
|
||||
@@ -25,7 +25,7 @@ export const PageNightLight: (() => Page) = () => new Page({
|
||||
value: bind(NightLight.getDefault(), "temperature"),
|
||||
tooltipText: bind(NightLight.getDefault(), "temperature").as((temp) => `${temp}K`),
|
||||
min: 1000,
|
||||
max: bind(NightLight.getDefault(), "maxTemperature"),
|
||||
max: NightLight.getDefault().maxTemperature,
|
||||
onDragged: (slider) =>
|
||||
NightLight.getDefault().temperature = (Math.floor(slider.value)),
|
||||
} as Widget.SliderProps),
|
||||
@@ -42,7 +42,7 @@ export const PageNightLight: (() => Page) = () => new Page({
|
||||
addSliderMarksFromMinMax(slider, 5, "{}%");
|
||||
},
|
||||
value: bind(NightLight.getDefault(), "gamma"),
|
||||
max: bind(NightLight.getDefault(), "maxGamma"),
|
||||
max: NightLight.getDefault().maxGamma,
|
||||
tooltipText: bind(NightLight.getDefault(), "gamma").as((gamma) => `${gamma}%`),
|
||||
onDragged: (slider) =>
|
||||
NightLight.getDefault().gamma = (Math.floor(slider.value)),
|
||||
|
||||
@@ -172,7 +172,7 @@ class Page extends Widget.Box {
|
||||
}
|
||||
}
|
||||
|
||||
export function PageButton(props: {
|
||||
export function PageButton({ onDestroy, ...props }: {
|
||||
className?: string | Binding<string>;
|
||||
icon?: string | Binding<string>;
|
||||
title: string | Binding<string>;
|
||||
@@ -185,7 +185,7 @@ export function PageButton(props: {
|
||||
tooltipMarkup?: string | Binding<string>;
|
||||
}): Gtk.Widget {
|
||||
return new Widget.Box({
|
||||
onDestroy: props.onDestroy,
|
||||
onDestroy,
|
||||
children: [
|
||||
new Widget.Button({
|
||||
onClick: props.onClick,
|
||||
@@ -202,17 +202,26 @@ export function PageButton(props: {
|
||||
className: "icon",
|
||||
icon: props.icon,
|
||||
visible: props.icon,
|
||||
hexpand: false,
|
||||
css: "font-size: 20px; margin-right: 6px;"
|
||||
} as Widget.IconProps),
|
||||
new Widget.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
expand: true,
|
||||
hexpand: true,
|
||||
vexpand: false,
|
||||
children: [
|
||||
new Widget.Label({
|
||||
className: "title",
|
||||
xalign: 0,
|
||||
// truncating is not working, so I had to do this
|
||||
label: (props.title instanceof Binding) ?
|
||||
props.title.as((title) =>
|
||||
`${title.substring(0, 35)}${
|
||||
title.length > 35 ? '…' : ""}`)
|
||||
: `${props.title.substring(0, 35)}${
|
||||
props.title.length > 35 ? '…' : ""}`,
|
||||
tooltipText: props.title,
|
||||
truncate: true,
|
||||
label: props.title
|
||||
} as Widget.LabelProps),
|
||||
new Widget.Label({
|
||||
className: "description",
|
||||
@@ -230,6 +239,7 @@ export function PageButton(props: {
|
||||
visible: (props.endWidget instanceof Binding) ?
|
||||
props.endWidget.as(Boolean)
|
||||
: props.endWidget,
|
||||
halign: Gtk.Align.END,
|
||||
child: props.endWidget
|
||||
} as Widget.BoxProps)
|
||||
]
|
||||
|
||||
@@ -27,7 +27,7 @@ export function PageSound(): Page {
|
||||
className: bind(speaker, "isDefault").as(isDefault => isDefault ? "default" : ""),
|
||||
icon: bind(speaker, "icon").as(icon =>
|
||||
Astal.Icon.lookup_icon(icon)? icon : "audio-card-symbolic"),
|
||||
title: speaker.name ?? "Speaker",
|
||||
title: bind(speaker, "description").as(desc => desc ?? "Speaker"),
|
||||
onClick: () => speaker.set_is_default(true),
|
||||
endWidget: new Widget.Icon({
|
||||
icon: "object-select-symbolic",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user