From d5f625fe275835274e2e52b6e8f5bc142d833ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lelzin=20=CE=BB?= Date: Wed, 25 Sep 2024 20:09:04 -0300 Subject: [PATCH] feat: add flag `--font-size` to set a fixed font size --- cmd/hyprnotify/main.go | 1 + internal/dbus.go | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/hyprnotify/main.go b/cmd/hyprnotify/main.go index cd3b0f6..ffa2fc3 100644 --- a/cmd/hyprnotify/main.go +++ b/cmd/hyprnotify/main.go @@ -19,6 +19,7 @@ func main() { CmdFlags := Cmd.Flags() CmdFlags.BoolVarP(&disableSound, "no-sound", "s", false, "disable sound, silent mode") + CmdFlags.Uint8VarP(&internal.DefaultFontSize, "font-size", "f", 0, "set a fixed font size (1-255)") Cmd.Execute() } diff --git a/internal/dbus.go b/internal/dbus.go index 8110a18..b34853e 100644 --- a/internal/dbus.go +++ b/internal/dbus.go @@ -71,6 +71,8 @@ var ( current_id uint32 = 0 notification_padding_regexp *regexp.Regexp = regexp.MustCompile("^\\s*|(\n)\\s*(.)") sound bool + + DefaultFontSize uint8 ) type DBusNotify string @@ -104,6 +106,10 @@ func (n DBusNotify) Notify( parse_hints(&nf, hints) + if DefaultFontSize > 0 { + nf.font_size = fontSize{value: DefaultFontSize} + } + // Setting min-width, left alignment summary = fmt.Sprintf("%-60s", summary) if nf.icon.value == nf.icon.NOICON { @@ -189,12 +195,12 @@ func parse_hints(nf *Notification, hints map[string]dbus.Variant) { if ok { nf.font_size.value = uint8(font_size) } - + hint_icon, ok := hints["x-hyprnotify-icon"].Value().(int32) if ok { nf.icon.value = hint_icon nf.icon.padding = "" - nf.color.value = nf.color.DEFAULT + nf.color.value = nf.color.DEFAULT } hint_color, ok := hints["x-hyprnotify-color"].Value().(string)