Notification handler and better powermenu

This commit is contained in:
Filippo Berto 2023-01-04 12:18:31 +01:00
parent 22cc32b064
commit 2d76b1228b
No known key found for this signature in database
GPG key ID: FE98AE5EC52B1056

View file

@ -9,6 +9,20 @@ let
pgrep = "${pkgs.procps}/bin/pgrep";
pkill = "${pkgs.procps}/bin/pkill";
playerCtl = "${pkgs.playerctl}/bin/playerctl";
dunstctl = "${pkgs.dunst}/bin/dunstctl";
notificationStatus = pkgs.writeShellScript "notificationStatus" ''
PATH=$PATH:"${lib.makeBinPath [ pkgs.dbus ]}"
if [[ `${dunstctl} is-paused` == "true" ]]; then echo ; else echo ; fi
'';
notificationToggle = pkgs.writeShellScript "notificationToggle" ''
PATH=$PATH:"${lib.makeBinPath [ pkgs.dbus ]}"
${dunstctl} set-paused toggle
'';
notificationHistory = pkgs.writeShellScript "notificationToggle" ''
PATH=$PATH:"${lib.makeBinPath [ pkgs.dbus ]}"
${dunstctl} set-paused false
for i in {1..10}; do ${dunstctl} history-pop; done
'';
playerStatus =
"${playerCtl} -f '{{emoji(status)}} {{title}} - {{artist}}' metadata | ${head} -c 60";
confirm_command = { cmd, title ? null, text ? null, image ? null }:
@ -92,6 +106,7 @@ let
"Noto Sans CJK CN:size=${toString pkgs.rice.font.monospace.size};0"
"Noto Sans CJK HK:size=${toString pkgs.rice.font.monospace.size};0"
];
enable-ipc = true;
wm-restack = "bspwm";
};
@ -125,8 +140,7 @@ in
"bar/primary" = recursiveUpdate commonBar {
modules-left = "bspwm";
# modules-center =
modules-right = "player pulseaudio temperature cpu memory battery date powermenu";
enable-ipc = true;
modules-right = "player pulseaudio temperature cpu memory battery notifications powermenu date";
tray = {
position = "right";
padding = 1;
@ -136,9 +150,7 @@ in
"bar/secondary" = recursiveUpdate commonBar {
modules-left = "bspwm";
# modules-center =
modules-right =
"player pulseaudio temperature cpu memory battery date powermenu";
enable-ipc = true;
modules-right = "player pulseaudio temperature cpu memory battery notifications powermenu date";
};
"module/battery" = {
@ -286,14 +298,10 @@ in
"module/powermenu" = {
type = "custom/menu";
expand.right = true;
format = {
spacing = 1;
suffix = " ";
};
format.spacing = 1;
label = {
open = recursiveUpdate colors.normal { text = ""; };
close = recursiveUpdate colors.normal { text = ""; };
# separator = { text = "|"; };
};
menu = [
[
@ -333,6 +341,16 @@ in
];
};
"module/notifications" = {
type = "custom/script";
format = recursiveUpdate colors.normal { padding = 0; };
exec = "${notificationStatus}";
click.left = "${notificationToggle}";
click.right = "${notificationHistory}";
interval = 0.5;
# tail = 1;
};
"module/player" = {
type = "custom/script";
format = recursiveUpdate colors.normal { padding = 0; };