Skip to content

Commit f13a3d8

Browse files
authored
Merge pull request #11 from d3cryptofc/main
feat: add `--font-size` & `--fixed-font-size` flags
2 parents 91de923 + a601e0b commit f13a3d8

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

cmd/hyprnotify/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ func main() {
1919
CmdFlags := Cmd.Flags()
2020

2121
CmdFlags.BoolVarP(&disableSound, "no-sound", "s", false, "disable sound, silent mode")
22+
CmdFlags.Uint8VarP(&internal.DefaultFontSize, "font-size", "f", 13, "set default font size (range 1-255)")
23+
CmdFlags.BoolVar(&internal.FixedFontSize, "fixed-font-size", false, "makes font size fixed, ignoring new sizes")
2224

2325
Cmd.Execute()
2426
}

internal/dbus.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ var (
6969
hyprsock HyprConn
7070
ongoing_notifications map[uint32]chan uint32 = make(map[uint32]chan uint32)
7171
current_id uint32 = 0
72-
sound bool
7372
notification_padding_regexp *regexp.Regexp = regexp.MustCompile("^\\s*|(\n)\\s*(.)")
73+
sound bool
74+
FixedFontSize bool
7475
)
7576

7677
type DBusNotify string
@@ -185,16 +186,18 @@ func parse_hints(nf *Notification, hints map[string]dbus.Variant) {
185186
nf.set_urgency(urgency)
186187
}
187188

188-
font_size, ok := hints["x-hyprnotify-font-size"].Value().(int32)
189-
if ok {
190-
nf.font_size.value = font_size
189+
if !FixedFontSize {
190+
font_size, ok := hints["x-hyprnotify-font-size"].Value().(int32)
191+
if ok {
192+
nf.font_size.value = uint8(font_size)
193+
}
191194
}
192-
195+
193196
hint_icon, ok := hints["x-hyprnotify-icon"].Value().(int32)
194197
if ok {
195198
nf.icon.value = hint_icon
196199
nf.icon.padding = ""
197-
nf.color.value = nf.color.DEFAULT
200+
nf.color.value = nf.color.DEFAULT
198201
}
199202

200203
hint_color, ok := hints["x-hyprnotify-color"].Value().(string)
@@ -206,8 +209,6 @@ func parse_hints(nf *Notification, hints map[string]dbus.Variant) {
206209
nf.color.value = nf.color.HEX(hint_color)
207210
}
208211
}
209-
210-
211212
}
212213

213214
func InitDBus(enable_sound bool) {

internal/hypripc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (hypr HyprConn) HyprCtl(args ...string) {
6060
func (hypr HyprConn) SendNotification(nf *Notification) {
6161
icon := i32ToString(nf.icon.value)
6262
timeout := i32ToString(nf.time_ms)
63-
font_size := i32ToString(nf.font_size.value)
63+
font_size := fmt.Sprintf("%d", nf.font_size.value)
6464
msg := "fontsize:" + font_size + " " + nf.icon.padding + nf.message
6565

6666
hypr.HyprCtl("notify", icon, timeout, nf.color.value, msg)

internal/notify.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package internal
22

3+
var DefaultFontSize uint8
4+
35
type Notification struct {
46
message string
57

@@ -44,8 +46,7 @@ type icon struct {
4446
}
4547

4648
type fontSize struct {
47-
value int32
48-
DEFAULT int32
49+
value uint8
4950
}
5051

5152
func newColorStruct() color {
@@ -106,7 +107,8 @@ func NewNotification() Notification {
106107

107108
n.icon = newIconStruct()
108109
n.color = newColorStruct()
109-
n.font_size = fontSize{value: 13, DEFAULT: 13}
110+
111+
n.font_size = fontSize{value: DefaultFontSize}
110112

111113
n.set_urgency(1) // default
112114
return n

0 commit comments

Comments
 (0)