From bd25cc4efc412a730257bd76e7f93df8b3effe09 Mon Sep 17 00:00:00 2001 From: Jonathan Bourdon Date: Mon, 4 May 2026 19:41:29 -0400 Subject: [PATCH] feat(mako): notifications now on bottom and colorful --- apply.sh | 2 +- bootstrap.sh | 4 +- mako/.config/mako/config | 30 +++++ waybar/.config/waybar/config.jsonc | 19 ++- .../waybar/scripts/mako-notifications.sh | 114 ++++++++++++++++++ waybar/.config/waybar/style.css | 59 +++++---- 6 files changed, 197 insertions(+), 31 deletions(-) create mode 100644 mako/.config/mako/config create mode 100755 waybar/.config/waybar/scripts/mako-notifications.sh diff --git a/apply.sh b/apply.sh index 44e5c2d..e20067a 100755 --- a/apply.sh +++ b/apply.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")" -stow -t ~ bash zsh tmux nvim hypr waybar alacritty rider-palette walker +stow -t ~ bash zsh tmux nvim hypr waybar mako alacritty rider-palette walker diff --git a/bootstrap.sh b/bootstrap.sh index 176e64d..197c724 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -4,7 +4,7 @@ set -euo pipefail # ====== CONFIG ====== DOTFILES_DIR="${DOTFILES_DIR:-$HOME/repos/dotfiles}" DOTFILES_GIT_URL="${DOTFILES_GIT_URL:-}" # ex: git@github.com:TON_USER/dotfiles.git -STOW_PACKAGES_DEFAULT=("zsh" "tmux" "nvim" "hypr" "hypridle" "waybar" "alacritty") +STOW_PACKAGES_DEFAULT=("zsh" "tmux" "nvim" "hypr" "waybar" "mako" "alacritty") INSTALL_FONTS="${INSTALL_FONTS:-1}" # 1 = install nerd font, 0 = skip SET_DEFAULT_SHELL="${SET_DEFAULT_SHELL:-1}" # 1 = chsh to zsh, 0 = skip @@ -61,7 +61,7 @@ sudo_run apt install -y build-essential || true # Hypr ecosystem (availability depends on distro/repo) # We try, but do not fail if packages aren't found. log "Trying to install Hyprland ecosystem packages (best effort)" -sudo_run apt install -y hyprland hypridle waybar alacritty 2>/dev/null || true +sudo_run apt install -y hyprland hyprpaper hypridle waybar mako-notifier alacritty 2>/dev/null || true # ====== DOTFILES CLONE (OPTIONAL) ====== if [ ! -d "$DOTFILES_DIR/.git" ]; then diff --git a/mako/.config/mako/config b/mako/.config/mako/config new file mode 100644 index 0000000..d7ca1f0 --- /dev/null +++ b/mako/.config/mako/config @@ -0,0 +1,30 @@ +font=JetBrainsMono Nerd Font 14 +background-color=#191A1C +text-color=#BDBDBD +border-color=#39CC9B +progress-color=over #39CC9B +width=420 +height=160 +outer-margin=16 +margin=12 +padding=14 +border-size=1 +border-radius=7 +icons=1 +max-icon-size=48 +markup=1 +actions=1 +max-visible=5 +max-history=50 +default-timeout=8000 +ignore-timeout=0 +anchor=bottom-right +layer=overlay +sort=-time + +[urgency=high] +border-color=#FF5647 +default-timeout=0 + +[mode=do-not-disturb] +invisible=1 diff --git a/waybar/.config/waybar/config.jsonc b/waybar/.config/waybar/config.jsonc index edc14de..d0c9ff8 100644 --- a/waybar/.config/waybar/config.jsonc +++ b/waybar/.config/waybar/config.jsonc @@ -1,6 +1,6 @@ { - "layer": "top", - "position": "top", + "layer": "bottom", + "position": "bottom", "mod": "dock", "margin-left": 0, "margin-right": 0, @@ -23,6 +23,7 @@ "bluetooth", "pulseaudio", "battery", + "custom/mako", "custom/power" ], "battery": { @@ -47,8 +48,8 @@ "tooltip": true }, "tray": { - "icon-size": 18, - "spacing": 12, + "icon-size": 22, + "spacing": 14, "rotate": 0 }, "custom/power": { @@ -73,6 +74,16 @@ "tooltip": true, "on-click": "$HOME/.config/waybar/scripts/print-queue-view.sh" }, + "custom/mako": { + "exec": "$HOME/.config/waybar/scripts/mako-notifications.sh status", + "return-type": "json", + "interval": 5, + "signal": 8, + "format": "{}", + "tooltip": true, + "on-click": "$HOME/.config/waybar/scripts/mako-notifications.sh toggle", + "on-click-right": "$HOME/.config/waybar/scripts/mako-notifications.sh list" + }, "hyprland/workspaces": { "all-outputs": false, "sort-by-number": true diff --git a/waybar/.config/waybar/scripts/mako-notifications.sh b/waybar/.config/waybar/scripts/mako-notifications.sh new file mode 100755 index 0000000..1792724 --- /dev/null +++ b/waybar/.config/waybar/scripts/mako-notifications.sh @@ -0,0 +1,114 @@ +#!/usr/bin/env sh + +set -eu + +dnd_mode="do-not-disturb" + +json_escape() { + printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g; s/\t/\\t/g' +} + +refresh_waybar() { + pkill -RTMIN+8 waybar >/dev/null 2>&1 || true +} + +notification_count() { + if ! command -v jq >/dev/null 2>&1; then + printf '0' + return + fi + + makoctl list -j 2>/dev/null \ + | jq '[.. | objects | select(has("id"))] | length' 2>/dev/null \ + || printf '0' +} + +is_dnd() { + makoctl mode 2>/dev/null | grep -qx "$dnd_mode" +} + +status() { + if ! modes="$(makoctl mode 2>/dev/null)"; then + tooltip="$(json_escape "Mako is unavailable")" + printf '{"text":" n/a","class":"disabled","tooltip":"%s"}\n' "$tooltip" + return + fi + + count="$(notification_count)" + count="${count:-0}" + + if printf '%s\n' "$modes" | grep -qx "$dnd_mode"; then + state="dnd" + icon="" + label="Do Not Disturb is on" + elif [ "$count" -gt 0 ] 2>/dev/null; then + state="active" + icon="" + label="Do Not Disturb is off" + else + state="normal" + icon="" + label="Do Not Disturb is off" + fi + + tooltip="$(json_escape "$label +$count pending notifications +Left click toggles DND +Right click opens the notification list")" + + printf '{"text":"%s %s","class":"%s","tooltip":"%s"}\n' "$icon" "$count" "$state" "$tooltip" +} + +toggle() { + makoctl mode -t "$dnd_mode" >/dev/null 2>&1 || true + refresh_waybar +} + +list_notifications() { + title="Notifications" + + if command -v jq >/dev/null 2>&1; then + list="$( + makoctl list -j 2>/dev/null \ + | jq -r ' + [.. | objects | select(has("id"))] + | if length == 0 then + "No pending notifications" + else + .[] + | [ + (."app-name" // .app_name // "app"), + (.summary // ""), + (.body // "") + ] + | map(select(. != "")) + | join(" - ") + end + ' 2>/dev/null + )" + else + list="$(makoctl list 2>/dev/null || printf 'No pending notifications')" + fi + + if [ -z "$list" ]; then + list="No pending notifications" + fi + + if command -v wofi >/dev/null 2>&1; then + printf '%s\n' "$list" | wofi --dmenu --prompt "$title" >/dev/null 2>&1 || true + elif command -v alacritty >/dev/null 2>&1; then + tmp="${TMPDIR:-/tmp}/mako-notifications.$$" + printf '%s\n' "$list" > "$tmp" + alacritty -e sh -c 'printf "%s\n\n" "$1"; cat "$2"; printf "\nPress Enter to close."; read -r _' sh "$title" "$tmp" + rm -f "$tmp" + else + printf '%s\n' "$list" + fi +} + +case "${1:-status}" in + status) status ;; + toggle) toggle ;; + list) list_notifications ;; + *) status ;; +esac diff --git a/waybar/.config/waybar/style.css b/waybar/.config/waybar/style.css index 6344f5e..d47a929 100644 --- a/waybar/.config/waybar/style.css +++ b/waybar/.config/waybar/style.css @@ -15,24 +15,25 @@ * { color: @foreground; font-family: 'JetBrainsMono Nerd Font'; - font-size: 14px; + font-size: 17px; } window#waybar { background: @background; + border-top: 1px solid alpha(@foreground, 0.28); border-radius: 0px; box-shadow: none; color: @foreground; } window#waybar>box { - padding: 3px 2px; + padding: 4px 2px; } tooltip { background: @background; border: 1px solid @accent-alt; - border-radius: 12px; + border-radius: 14px; } .modules-left, @@ -50,6 +51,7 @@ tooltip { #bluetooth, #pulseaudio, #battery, +#custom-mako, #tray, #custom-power { background: transparent; @@ -58,7 +60,7 @@ tooltip { border-radius: 0; box-shadow: none; margin: 0; - padding: 0 10px; + padding: 0 12px; } #custom-launcher, @@ -75,31 +77,31 @@ tooltip { } #custom-print-queue { - padding: 0 10px; + padding: 0 12px; } #network { - padding: 0 6px 0 10px; + padding: 0 7px 0 12px; } #bluetooth { - padding: 0 6px; + padding: 0 7px; } #pulseaudio { - padding: 0 10px 0 6px; + padding: 0 12px 0 7px; } #workspaces { - padding: 0 5px; + padding: 0 6px; } #workspaces button { all: initial; - min-width: 24px; - padding: 0 4px; + min-width: 29px; + padding: 0 5px; margin: 2px 2px; - border-radius: 6px; + border-radius: 7px; opacity: 0.9; } @@ -139,21 +141,29 @@ tooltip { #window { color: @foreground-muted; - padding: 0 14px; + padding: 0 17px; } #clock { - padding: 0 15px; + padding: 0 18px; box-shadow: none; border: none; } #tray { - padding: 0 12px; + padding: 0 14px; } #custom-power { - padding: 0px 16px 0px 12px; + padding: 0px 19px 0px 14px; +} + +#custom-mako.dnd { + color: @warning; +} + +#custom-mako.active { + color: @accent; } #custom-launcher:hover, @@ -163,6 +173,7 @@ tooltip { #bluetooth:hover, #pulseaudio:hover, #battery:hover, +#custom-mako:hover, #tray:hover, #custom-power:hover, #clock:hover { @@ -182,14 +193,14 @@ tooltip { menu#menu { background: @background; border: 1px solid alpha(@accent-alt, 0.24); - border-radius: 14px; - padding: 8px; + border-radius: 17px; + padding: 10px; } menu#menu menuitem { - border-radius: 10px; - margin: 10px; - padding: 8px 12px; + border-radius: 12px; + margin: 12px; + padding: 10px 14px; } menu#menu menuitem:hover { @@ -198,9 +209,9 @@ menu#menu menuitem:hover { menu#menu menuitem.section-header { color: @foreground-muted; - font-size: 14px; + font-size: 17px; margin-top: 4px; - padding: 4px 12px; + padding: 5px 14px; } menu#menu menuitem#lock { @@ -227,5 +238,5 @@ menu#menu menuitem#shutdown { menu#menu separator { background: alpha(@accent-alt, 0.24); - margin: 6px 10px; + margin: 7px 12px; }