✨ chore(logout-menu): use hyprctl to exit Hyprland, add background color for better visibility
also improved error handling if command fails
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
@use "./colors";
|
||||
|
||||
.logout-menu {
|
||||
background: rgba($color: colors.$bg-translucent-primary, $alpha: .4);
|
||||
|
||||
.top {
|
||||
.time {
|
||||
font-size: 128px;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { Astal, Gdk, Gtk, Widget } from "astal/gtk3";
|
||||
import { getDateTime } from "../scripts/time";
|
||||
import { exec, execAsync, GLib } from "astal";
|
||||
import { exec, execAsync, Gio, GLib } from "astal";
|
||||
import { AskPopup } from "../widget/AskPopup";
|
||||
import { Windows } from "../windows";
|
||||
import { Notifications } from "../scripts/notifications";
|
||||
import AstalNotifd from "gi://AstalNotifd?version=0.1";
|
||||
|
||||
|
||||
const { TOP, LEFT, RIGHT, BOTTOM } = Astal.WindowAnchor;
|
||||
@@ -99,8 +101,32 @@ 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: () => {
|
||||
exec(`sh "${GLib.getenv("XDG_CONFIG_HOME")}/hypr/scripts/save-hyprsunset.sh"`);
|
||||
execAsync(`sh -c "loginctl terminate-user ${GLib.getenv("USER") || "$USER"}"`);
|
||||
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}`
|
||||
})
|
||||
)
|
||||
}]
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
})
|
||||
} as Widget.ButtonProps),
|
||||
|
||||
Reference in New Issue
Block a user