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"; pgrep = "${pkgs.procps}/bin/pgrep";
pkill = "${pkgs.procps}/bin/pkill"; pkill = "${pkgs.procps}/bin/pkill";
playerCtl = "${pkgs.playerctl}/bin/playerctl"; 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 = playerStatus =
"${playerCtl} -f '{{emoji(status)}} {{title}} - {{artist}}' metadata | ${head} -c 60"; "${playerCtl} -f '{{emoji(status)}} {{title}} - {{artist}}' metadata | ${head} -c 60";
confirm_command = { cmd, title ? null, text ? null, image ? null }: 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 CN:size=${toString pkgs.rice.font.monospace.size};0"
"Noto Sans CJK HK: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"; wm-restack = "bspwm";
}; };
@ -125,8 +140,7 @@ in
"bar/primary" = recursiveUpdate commonBar { "bar/primary" = recursiveUpdate commonBar {
modules-left = "bspwm"; modules-left = "bspwm";
# modules-center = # modules-center =
modules-right = "player pulseaudio temperature cpu memory battery date powermenu"; modules-right = "player pulseaudio temperature cpu memory battery notifications powermenu date";
enable-ipc = true;
tray = { tray = {
position = "right"; position = "right";
padding = 1; padding = 1;
@ -136,9 +150,7 @@ in
"bar/secondary" = recursiveUpdate commonBar { "bar/secondary" = recursiveUpdate commonBar {
modules-left = "bspwm"; modules-left = "bspwm";
# modules-center = # modules-center =
modules-right = modules-right = "player pulseaudio temperature cpu memory battery notifications powermenu date";
"player pulseaudio temperature cpu memory battery date powermenu";
enable-ipc = true;
}; };
"module/battery" = { "module/battery" = {
@ -286,14 +298,10 @@ in
"module/powermenu" = { "module/powermenu" = {
type = "custom/menu"; type = "custom/menu";
expand.right = true; expand.right = true;
format = { format.spacing = 1;
spacing = 1;
suffix = " ";
};
label = { label = {
open = recursiveUpdate colors.normal { text = ""; }; open = recursiveUpdate colors.normal { text = ""; };
close = recursiveUpdate colors.normal { text = ""; }; close = recursiveUpdate colors.normal { text = ""; };
# separator = { text = "|"; };
}; };
menu = [ 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" = { "module/player" = {
type = "custom/script"; type = "custom/script";
format = recursiveUpdate colors.normal { padding = 0; }; format = recursiveUpdate colors.normal { padding = 0; };