nixos-configs/devices/wim/config/ags/js/powermenu.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
import { CenterBox, Label } from 'resource:///com/github/Aylur/ags/widget.js';
2023-11-06 18:37:23 -05:00
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
import PopupWindow from './misc/popup.js';
import CursorBox from './misc/cursorbox.js';
2023-08-27 10:31:41 -04:00
const PowermenuWidget = () => CenterBox({
class_name: 'powermenu',
// @ts-expect-error
vertical: false,
2023-08-27 10:31:41 -04:00
2023-12-23 01:14:21 -05:00
start_widget: CursorBox({
class_name: 'shutdown button',
on_primary_click_release: () => execAsync(['systemctl', 'poweroff'])
.catch(print),
2023-08-27 10:31:41 -04:00
child: Label({
label: '襤',
}),
2023-08-27 10:31:41 -04:00
}),
2023-12-23 01:14:21 -05:00
center_widget: CursorBox({
class_name: 'reboot button',
on_primary_click_release: () => execAsync(['systemctl', 'reboot'])
.catch(print),
2023-08-27 10:31:41 -04:00
child: Label({
label: '勒',
}),
2023-08-27 10:31:41 -04:00
}),
2023-12-23 01:14:21 -05:00
end_widget: CursorBox({
class_name: 'logout button',
on_primary_click_release: () => Hyprland.sendMessage('dispatch exit')
.catch(print),
2023-08-27 10:31:41 -04:00
child: Label({
label: '',
}),
2023-08-27 10:31:41 -04:00
}),
});
export default () => PopupWindow({
name: 'powermenu',
transition: 'crossfade',
child: PowermenuWidget(),
});