✨ ags(control-center/quickactions): better code and stuff
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
import { execAsync, Process, Variable } from "astal";
|
||||
import { exec, execAsync, GLib, Variable } from "astal";
|
||||
import { Gtk, Widget } from "astal/gtk3";
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { Windows } from "../../windows";
|
||||
|
||||
const hostname: string = Process.exec("cat /etc/hostname") || "GNU/Linux";
|
||||
const uptime = new Variable<string>("Just turned on")
|
||||
.poll(1000, () => {
|
||||
return Process.exec("uptime -p").replace(/^up /, "")
|
||||
})();
|
||||
const uptime = new Variable<string>("Just turned on").poll(1000,
|
||||
() => exec("uptime -p").replace(/^up /, "")
|
||||
);
|
||||
|
||||
function LockButton(): Widget.Button {
|
||||
return new Widget.Button({
|
||||
className: "nf",
|
||||
label: "",
|
||||
onClick: () => AstalHyprland.get_default().dispatch("exec", "hyprlock")
|
||||
onClick: () => {
|
||||
Windows.close("control-center");
|
||||
AstalHyprland.get_default().dispatch("exec", "hyprlock");
|
||||
}
|
||||
} as Widget.ButtonProps)
|
||||
}
|
||||
|
||||
@@ -22,7 +24,7 @@ function ColorPickerButton(): Widget.Button {
|
||||
label: "",
|
||||
onClick: () => AstalHyprland.get_default().dispatch(
|
||||
"exec",
|
||||
"sh $HOME/.config/eww/scripts/color-picker.sh"
|
||||
"sh $HOME/.config/hypr/scripts/color-picker.sh"
|
||||
)
|
||||
} as Widget.ButtonProps)
|
||||
}
|
||||
@@ -31,10 +33,11 @@ function ScreenshotButton(): Widget.Button {
|
||||
return new Widget.Button({
|
||||
className: "nf",
|
||||
label: "",
|
||||
onClick: () => Process.exec_async(
|
||||
"bash -c 'hyprshot -m region -o $HOME/Screenshots'",
|
||||
() => {}
|
||||
)
|
||||
onClick: () => execAsync(
|
||||
`hyprshot -m region -o ${GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES) ?
|
||||
`${GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES)}/Screenshots`
|
||||
: `${GLib.get_home_dir()}/Screenshots`
|
||||
}`)
|
||||
} as Widget.ButtonProps);
|
||||
}
|
||||
|
||||
@@ -42,9 +45,9 @@ function SelectWallpaperButton(): Widget.Button {
|
||||
return new Widget.Button({
|
||||
className: "nf",
|
||||
label: "",
|
||||
onClick: () => Process.exec_async(
|
||||
"bash -c 'sh $HOME/.config/hypr/scripts/change-wallpaper.sh'",
|
||||
() => {}
|
||||
onClick: () => execAsync(
|
||||
`sh ${GLib.get_user_config_dir() || `${GLib.get_home_dir()}/.config`
|
||||
}/hypr/scripts/change-wallpaper.sh`
|
||||
)
|
||||
} as Widget.ButtonProps);
|
||||
}
|
||||
@@ -53,7 +56,7 @@ function LogoutButton(): Widget.Button {
|
||||
return new Widget.Button({
|
||||
className: "nf",
|
||||
label: "",
|
||||
onClick: () => execAsync("astal open logout-menu")
|
||||
onClick: () => Windows.open("logout-menu")
|
||||
} as Widget.ButtonProps);
|
||||
}
|
||||
|
||||
@@ -69,12 +72,12 @@ export const QuickActions = () => new Widget.Box({
|
||||
new Widget.Label({
|
||||
className: "hostname",
|
||||
xalign: 0,
|
||||
label: hostname.toString()
|
||||
label: GLib.get_host_name()
|
||||
} as Widget.LabelProps),
|
||||
new Widget.Label({
|
||||
className: "uptime",
|
||||
xalign: 0,
|
||||
label: uptime.as((uptime: string) => ` ${uptime}`)
|
||||
label: uptime().as((uptime: string) => ` ${uptime}`)
|
||||
} as Widget.LabelProps)
|
||||
]
|
||||
} as Widget.BoxProps),
|
||||
|
||||
Reference in New Issue
Block a user