diff --git a/hm_modules/polybar.nix b/hm_modules/polybar.nix index eaa6c76..41bab7c 100644 --- a/hm_modules/polybar.nix +++ b/hm_modules/polybar.nix @@ -11,6 +11,15 @@ let playerCtl = "${pkgs.playerctl}/bin/playerctl"; playerStatus = "${playerCtl} -f '{{emoji(status)}} {{title}} - {{artist}}' metadata | ${head} -c 60"; + 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 isNull title then "" else ''--title "${title}"'') + (if isNull image then "" else ''--image "${image}"'') + (if isNull text then "" else ''--text "${text}"'') + "&& ${cmd}" + ]; systemctl = "${pkgs.systemd}/bin/systemctl"; loginctl = "${pkgs.systemd}/bin/loginctl"; shutdown = "${pkgs.systemd}/bin/shutdown"; @@ -82,7 +91,7 @@ let # "Font Awesome 6 Free:size=14;0" # "Noto Color Emoji:size=2;2" "Noto Sans Symbols2:size=${toString pkgs.rice.font.monospace.size};2" - # "Material Design Icons:size=${toString pkgs.rice.font.monospace.size};2" + "Material Design Icons:size=${toString pkgs.rice.font.monospace.size};2" # "EmojiOne Color:size=${toString pkgs.rice.font.monospace.size};0" "Noto Sans CJK JP:size=${toString pkgs.rice.font.monospace.size};0" "Noto Sans CJK KR:size=${toString pkgs.rice.font.monospace.size};0" @@ -100,7 +109,7 @@ in # emojione # noto-fonts-emoji noto-fonts - # material-design-icons + material-design-icons # font-awesome noto-fonts-cjk-sans ]; @@ -291,51 +300,43 @@ in suffix = " "; }; label = { - open = recursiveUpdate colors.normal { text = " ⏻ "; }; - close = recursiveUpdate colors.normal { text = "Cancel"; }; - separator = { text = "|"; }; + open = recursiveUpdate colors.normal { text = ""; }; + close = recursiveUpdate colors.normal { text = ""; }; + # separator = { text = "|"; }; }; menu = [ [ ({ - text = "Logout"; - exec = "#powermenu.open.1"; + text = ""; + exec = confirm_command { + cmd = logout; + title = "Logout"; + text = "Do you want to logout?"; + }; }) ({ - text = "Reboot"; - exec = "#powermenu.open.2"; + text = ""; + exec = confirm_command { + cmd = "${systemctl} reboot"; + title = "Reboot"; + text = "Do you want to reboot?"; + }; }) ({ - text = "Hibernate"; - exec = "#powermenu.open.3"; + text = ""; + exec = confirm_command { + cmd = "${systemctl} hibernate"; + title = "Hibernate"; + text = "Do you want to hibernate?"; + }; }) ({ - text = "Power off"; - exec = "#powermenu.open.4"; - }) - ] - [ - ({ - text = "Logout"; - exec = logout; - }) - ] - [ - ({ - text = "Reboot"; - exec = "${systemctl} reboot"; - }) - ] - [ - ({ - text = "Hibernate"; - exec = "${systemctl} hibernate"; - }) - ] - [ - ({ - text = "Power off"; - exec = "${shutdown} now"; + text = ""; + exec = confirm_command { + cmd = "${shutdown} now"; + title = "Shutdown"; + text = "Do you want to shutdown?"; + }; }) ] ];