NixOS-Config/home-manager/services/mako.nix

49 lines
1.5 KiB
Nix
Raw Normal View History

2024-08-24 22:16:51 -04:00
{pkgs, ...}: {
# Notification daemon
services.mako = let
colors = import ../style/colors.nix;
border = import ../common/border.nix;
displays = import ../common/displays.nix;
fonts = import ../common/fonts.nix;
in {
enable = true;
borderColor = "#${colors.accent}";
backgroundColor = "#${colors.dark}CC";
output = "${displays.d1}";
sort = "+time";
layer = "overlay";
padding = "8";
margin = "0";
borderSize = border.weightInt;
maxIconSize = 40;
defaultTimeout = 6000;
font = "${fonts.main} 12";
anchor = "bottom-right";
extraConfig = "on-button-right=dismiss-all\nouter-margin=10\n[mode=do-not-disturb]\ninvisible=1";
};
# Script to toggle notifications using mako
home.packages = let
makoToggle = pkgs.writeScriptBin "makotoggle" ''
# Run makoctl mode and store the output in a variable
mode_output=$(makoctl mode)
# Extract the second line after "default"
mode_line=$(echo "$mode_output" | sed -n '/default/{n;p}')
if [[ "$mode_line" == "do-not-disturb" ]]; then
# Notifications are disabled, so we enable them
makoctl mode -r do-not-disturb
notify-send --expire-time=1500 'Notifications Enabled'
else
# Notifications are enabled, so we disable them
notify-send --expire-time=1500 'Notifications Disabled'
sleep 2
makoctl mode -a do-not-disturb
fi
'';
in with pkgs; [
makoToggle
];
}