✨ feat(config): implement configurations
This commit is contained in:
+34
-29
@@ -1,10 +1,12 @@
|
||||
import { Astal, Gdk, Gtk, Widget } from "astal/gtk3";
|
||||
import { getDateTime } from "../scripts/time";
|
||||
import { exec, execAsync, Gio, GLib } from "astal";
|
||||
import { execAsync, Gio, GLib } from "astal";
|
||||
import { AskPopup } from "../widget/AskPopup";
|
||||
import { Windows } from "../windows";
|
||||
import { Notifications } from "../scripts/notifications";
|
||||
import AstalNotifd from "gi://AstalNotifd";
|
||||
import { NightLight } from "../scripts/nightlight";
|
||||
import { Config } from "../scripts/config";
|
||||
|
||||
|
||||
const { TOP, LEFT, RIGHT, BOTTOM } = Astal.WindowAnchor;
|
||||
@@ -62,7 +64,9 @@ export const LogoutMenu = (mon: number) => new Widget.Window({
|
||||
title: "Power Off",
|
||||
text: "Are you sure you want to power off? Unsaved work will be lost.",
|
||||
onAccept: () => {
|
||||
exec(`sh "${GLib.getenv("XDG_CONFIG_HOME")}/hypr/scripts/save-hyprsunset.sh"`);
|
||||
Config.getDefault().getProperty("night_light.save_on_shutdown", "boolean") &&
|
||||
NightLight.getDefault().saveData();
|
||||
|
||||
execAsync("systemctl poweroff");
|
||||
}
|
||||
})
|
||||
@@ -76,7 +80,9 @@ export const LogoutMenu = (mon: number) => new Widget.Window({
|
||||
title: "Reboot",
|
||||
text: "Are you sure you want to Reboot? Unsaved work will be lost.",
|
||||
onAccept: () => {
|
||||
exec(`sh "${GLib.getenv("XDG_CONFIG_HOME")}/hypr/scripts/save-hyprsunset.sh"`);
|
||||
Config.getDefault().getProperty("night_light.save_on_shutdown", "boolean") &&
|
||||
NightLight.getDefault().saveData();
|
||||
|
||||
execAsync("systemctl reboot");
|
||||
}
|
||||
})
|
||||
@@ -101,32 +107,31 @@ export const LogoutMenu = (mon: number) => new Widget.Window({
|
||||
title: "Log out",
|
||||
text: "Are you sure you want to log out? Your session will be ended.",
|
||||
onAccept: () => {
|
||||
execAsync(
|
||||
`sh "${GLib.getenv("XDG_CONFIG_HOME")}/hypr/scripts/save-hyprsunset.sh"`
|
||||
).finally(() =>
|
||||
execAsync(`hyprctl dispatch exit`).catch((err: Gio.IOErrorEnum) =>
|
||||
Notifications.getDefault().sendNotification({
|
||||
appName: "colorshell",
|
||||
summary: "Couldn't exit Hyprland",
|
||||
body: `An error occurred and colorshell couldn't exit Hyprland. Stderr: \n${
|
||||
err.message ? `${err.message}\n` : ""}${err.stack}`,
|
||||
urgency: AstalNotifd.Urgency.NORMAL,
|
||||
actions: [{
|
||||
text: "Report Issue on colorshell",
|
||||
onAction: () => execAsync(
|
||||
`xdg-open https://github.com/retrozinndev/colorshell/issues/new`
|
||||
).catch((err: Gio.IOErrorEnum) =>
|
||||
Notifications.getDefault().sendNotification({
|
||||
appName: "colorshell",
|
||||
summary: "Couldn't open link",
|
||||
body: `Do you have \`xdg-utils\` installed? Stderr: \n${
|
||||
err.message ? `${err.message}\n` : ""}${err.stack}`
|
||||
})
|
||||
)
|
||||
}]
|
||||
})
|
||||
)
|
||||
);
|
||||
Config.getDefault().getProperty("night_light.save_on_shutdown", "boolean") &&
|
||||
NightLight.getDefault().saveData();
|
||||
|
||||
execAsync(`hyprctl dispatch exit`).catch((err: Gio.IOErrorEnum) =>
|
||||
Notifications.getDefault().sendNotification({
|
||||
appName: "colorshell",
|
||||
summary: "Couldn't exit Hyprland",
|
||||
body: `An error occurred and colorshell couldn't exit Hyprland. Stderr: \n${
|
||||
err.message ? `${err.message}\n` : ""}${err.stack}`,
|
||||
urgency: AstalNotifd.Urgency.NORMAL,
|
||||
actions: [{
|
||||
text: "Report Issue on colorshell",
|
||||
onAction: () => execAsync(
|
||||
`xdg-open https://github.com/retrozinndev/colorshell/issues/new`
|
||||
).catch((err: Gio.IOErrorEnum) =>
|
||||
Notifications.getDefault().sendNotification({
|
||||
appName: "colorshell",
|
||||
summary: "Couldn't open link",
|
||||
body: `Do you have \`xdg-utils\` installed? Stderr: \n${
|
||||
err.message ? `${err.message}\n` : ""}${err.stack}`
|
||||
})
|
||||
)
|
||||
}]
|
||||
})
|
||||
)
|
||||
}
|
||||
})
|
||||
} as Widget.ButtonProps),
|
||||
|
||||
Reference in New Issue
Block a user