hyprpanel
This commit is contained in:
1 parent
10080a83ee
commit
5151ac24da
322 files changed
+38276
No files matched your search
@@ -0,0 +1,61 @@
|
||||
import { Action } from 'lib/types/power';
|
||||
import options from 'options';
|
||||
const { sleep, reboot, logout, shutdown } = options.menus.dashboard.powermenu;
|
||||
|
||||
class PowerMenu extends Service {
|
||||
static {
|
||||
Service.register(
|
||||
this,
|
||||
{},
|
||||
{
|
||||
title: ['string'],
|
||||
cmd: ['string'],
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
#title = '';
|
||||
#cmd = '';
|
||||
|
||||
get title(): string {
|
||||
return this.#title;
|
||||
}
|
||||
|
||||
action(action: Action): void {
|
||||
[this.#cmd, this.#title] = {
|
||||
sleep: [sleep.value, 'Sleep'],
|
||||
reboot: [reboot.value, 'Reboot'],
|
||||
logout: [logout.value, 'Log Out'],
|
||||
shutdown: [shutdown.value, 'Shutdown'],
|
||||
}[action];
|
||||
|
||||
this.notify('cmd');
|
||||
this.notify('title');
|
||||
this.emit('changed');
|
||||
App.closeWindow('powermenu');
|
||||
App.openWindow('verification');
|
||||
}
|
||||
|
||||
customAction(action: Action, cmnd: string): void {
|
||||
[this.#cmd, this.#title] = [cmnd, action];
|
||||
|
||||
this.notify('cmd');
|
||||
this.notify('title');
|
||||
this.emit('changed');
|
||||
App.closeWindow('powermenu');
|
||||
App.openWindow('verification');
|
||||
}
|
||||
|
||||
shutdown = (): void => {
|
||||
this.action('shutdown');
|
||||
};
|
||||
|
||||
exec = (): void => {
|
||||
App.closeWindow('verification');
|
||||
Utils.execAsync(this.#cmd);
|
||||
};
|
||||
}
|
||||
|
||||
const powermenu = new PowerMenu();
|
||||
Object.assign(globalThis, { powermenu });
|
||||
export default powermenu;
|
||||
@@ -0,0 +1,41 @@
|
||||
import { Action } from 'lib/types/power.js';
|
||||
import PopupWindow from '../shared/popup/index.js';
|
||||
import powermenu from './helpers/actions.js';
|
||||
import icons from '../../icons/index.js';
|
||||
import Window from 'types/widgets/window.js';
|
||||
import { Attribute, Child, GButton } from 'lib/types/widget.js';
|
||||
import options from 'options.js';
|
||||
|
||||
const SysButton = (action: Action, label: string): GButton =>
|
||||
Widget.Button({
|
||||
class_name: `widget-button powermenu-button-${action}`,
|
||||
on_clicked: () => powermenu.action(action),
|
||||
child: Widget.Box({
|
||||
vertical: true,
|
||||
class_name: 'system-button widget-box',
|
||||
children: [
|
||||
Widget.Icon({
|
||||
class_name: `system-button_icon ${action}`,
|
||||
icon: icons.powermenu[action],
|
||||
}),
|
||||
Widget.Label({
|
||||
class_name: `system-button_label ${action}`,
|
||||
label,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
});
|
||||
export default (): Window<Child, Attribute> =>
|
||||
PopupWindow({
|
||||
name: 'powermenu',
|
||||
transition: options.menus.transition.bind('value'),
|
||||
child: Widget.Box({
|
||||
class_name: 'powermenu horizontal',
|
||||
children: [
|
||||
SysButton('shutdown', 'SHUTDOWN'),
|
||||
SysButton('logout', 'LOG OUT'),
|
||||
SysButton('reboot', 'REBOOT'),
|
||||
SysButton('sleep', 'SLEEP'),
|
||||
],
|
||||
}),
|
||||
});
|
||||
@@ -0,0 +1,54 @@
|
||||
import Window from 'types/widgets/window.js';
|
||||
import PopupWindow from '../shared/popup/index.js';
|
||||
import powermenu from './helpers/actions.js';
|
||||
import { Attribute, Child } from 'lib/types/widget.js';
|
||||
|
||||
export default (): Window<Child, Attribute> =>
|
||||
PopupWindow({
|
||||
name: 'verification',
|
||||
transition: 'crossfade',
|
||||
child: Widget.Box({
|
||||
class_name: 'verification',
|
||||
child: Widget.Box({
|
||||
class_name: 'verification-content',
|
||||
expand: true,
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Box({
|
||||
class_name: 'text-box',
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Label({
|
||||
class_name: 'title',
|
||||
label: powermenu.bind('title').as((t) => t.toUpperCase()),
|
||||
}),
|
||||
Widget.Label({
|
||||
class_name: 'desc',
|
||||
label: powermenu
|
||||
.bind('title')
|
||||
.as((p) => `Are you sure you want to ${p.toLowerCase()}?`),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
Widget.Box({
|
||||
class_name: 'buttons horizontal',
|
||||
vexpand: true,
|
||||
vpack: 'end',
|
||||
homogeneous: true,
|
||||
children: [
|
||||
Widget.Button({
|
||||
class_name: 'verification-button bar-verification_yes',
|
||||
child: Widget.Label('Yes'),
|
||||
on_clicked: powermenu.exec,
|
||||
}),
|
||||
Widget.Button({
|
||||
class_name: 'verification-button bar-verification_no',
|
||||
child: Widget.Label('No'),
|
||||
on_clicked: () => App.toggleWindow('verification'),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
});
|
||||
Reference in new issue
Block a user