Better power menu handle
This commit is contained in:
parent
ea23ad8fbf
commit
8c940dec07
3 changed files with 31 additions and 70 deletions
|
|
@ -44,20 +44,9 @@ let
|
|||
-u true ${playerStatusSrc} &
|
||||
wait
|
||||
'';
|
||||
confirm_command = { cmd, title ? null, text ? null, image ? null }:
|
||||
lib.concatStringsSep " " [
|
||||
"${pkgs.yad}/bin/yad --question --center --on-top --sticky --timeout=30 --timeout-indicator=bottom"
|
||||
(if title == null then "" else ''--title "${title}"'')
|
||||
(if image == null then "" else ''--image "${image}"'')
|
||||
(if text == null then "" else ''--text "${text}"'')
|
||||
"&& ${cmd}"
|
||||
];
|
||||
systemctl = "${pkgs.systemd}/bin/systemctl";
|
||||
loginctl = "${pkgs.systemd}/bin/loginctl";
|
||||
shutdown = "${pkgs.systemd}/bin/shutdown";
|
||||
logout = pkgs.writeShellScript "logout" ''
|
||||
session=`${loginctl} session-status | ${pkgs.coreutils}/bin/head -n 1 | ${pkgs.gawk}/bin/awk '{print $1}'`
|
||||
${loginctl} terminate-session $session
|
||||
powermenu = pkgs.writeShellScript "powermenu" ''
|
||||
PATH=$PATH:"${lib.makeBinPath [ pkgs.rofi pkgs.rofi-power-menu pkgs.zsh ]}"
|
||||
zsh -c 'rofi -show menu -modi "menu:rofi-power-menu --choices=shutdown/reboot/hibernate/logout"'
|
||||
'';
|
||||
colors = with pkgs.lib.nix-rice;
|
||||
let alpha = 255 * opacity;
|
||||
|
|
@ -295,37 +284,12 @@ in
|
|||
type = "internal/temperature";
|
||||
warn.temperature = "90";
|
||||
};
|
||||
|
||||
"module/powermenu" = {
|
||||
type = "custom/menu";
|
||||
expand.right = true;
|
||||
format.spacing = 1;
|
||||
label = {
|
||||
open = recursiveUpdate colors.normal { text = "●"; };
|
||||
close = recursiveUpdate colors.normal { text = ""; };
|
||||
};
|
||||
menu = [
|
||||
[
|
||||
{
|
||||
text = "";
|
||||
exec = confirm_command { cmd = logout; title = "Logout"; text = "Do you want to logout?"; };
|
||||
}
|
||||
{
|
||||
text = "";
|
||||
exec = confirm_command { cmd = "${systemctl} reboot"; title = "Reboot"; text = "Do you want to reboot?"; };
|
||||
}
|
||||
{
|
||||
text = "";
|
||||
exec = confirm_command { cmd = "${systemctl} hibernate"; title = "Hibernate"; text = "Do you want to hibernate?"; };
|
||||
}
|
||||
{
|
||||
text = "";
|
||||
exec = confirm_command { cmd = "${shutdown} now"; title = "Shutdown"; text = "Do you want to shutdown?"; };
|
||||
}
|
||||
]
|
||||
];
|
||||
type = "custom/script";
|
||||
format = recursiveUpdate colors.normal { padding = 0; };
|
||||
exec = "echo ";
|
||||
click.left = "${powermenu}";
|
||||
};
|
||||
|
||||
"module/notifications" = {
|
||||
type = "custom/script";
|
||||
format = recursiveUpdate colors.normal { padding = 0; };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue