File tree Expand file tree Collapse file tree 2 files changed +31
-12
lines changed Expand file tree Collapse file tree 2 files changed +31
-12
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ package internal
3
3
import (
4
4
"fmt"
5
5
"os"
6
+ "regexp"
7
+ "strings"
6
8
"time"
7
9
8
10
"github.com/godbus/dbus/v5"
@@ -63,17 +65,18 @@ const DBUS_XML = `<node name="` + FDN_PATH + `">
63
65
</node>`
64
66
65
67
var (
66
- conn * dbus.Conn
67
- hyprsock HyprConn
68
- ongoing_notifications map [uint32 ]chan uint32 = make (map [uint32 ]chan uint32 )
69
- current_id uint32 = 0
70
- sound bool
68
+ conn * dbus.Conn
69
+ hyprsock HyprConn
70
+ ongoing_notifications map [uint32 ]chan uint32 = make (map [uint32 ]chan uint32 )
71
+ current_id uint32 = 0
72
+ sound bool
73
+ notification_padding_regexp * regexp.Regexp = regexp .MustCompile ("^\\ s*|(\n )\\ s*(.)" )
71
74
)
72
75
73
76
type DBusNotify string
74
77
75
78
func (n DBusNotify ) GetCapabilities () ([]string , * dbus.Error ) {
76
- var cap []string
79
+ cap := []string { "body" }
77
80
return cap , nil
78
81
}
79
82
@@ -98,9 +101,29 @@ func (n DBusNotify) Notify(
98
101
99
102
// Send Notification
100
103
nf := NewNotification ()
101
- nf . message = summary
104
+
102
105
parse_hints (& nf , hints )
103
106
107
+ // Setting min-width, left alignment
108
+ summary = fmt .Sprintf ("%-60s" , summary )
109
+ if nf .icon .value == nf .icon .NOICON {
110
+ summary += " "
111
+ }
112
+ summary += "\u205F "
113
+
114
+ if body != "" {
115
+ nf .message = fmt .Sprintf ("%s\n %s" , summary , body )
116
+ } else {
117
+ nf .message = summary
118
+ }
119
+
120
+ // Using RegExp to add padding for all lines
121
+ nf .message = notification_padding_regexp .
122
+ ReplaceAllString (
123
+ strings .TrimLeft (nf .message , "\n " ),
124
+ "$1\u205F $2" ,
125
+ )
126
+
104
127
if expire_timeout != - 1 {
105
128
nf .time_ms = expire_timeout
106
129
}
Original file line number Diff line number Diff line change @@ -80,27 +80,23 @@ func newIconStruct() icon {
80
80
81
81
func (nf * Notification ) set_urgency (urgency uint8 ) {
82
82
icon := nf .icon .NOICON
83
- padding := ""
84
83
color := nf .color .DEFAULT
85
84
var time_ms int32 = 5 * 1000
86
85
87
86
if urgency == 0 {
88
87
icon = nf .icon .OK
89
- padding = " "
90
88
color = nf .color .GREEN
91
89
} else if urgency == 1 {
92
90
icon = nf .icon .NOICON
93
- padding = " "
94
91
color = nf .color .LIGHTBLUE
95
92
} else if urgency == 2 {
96
93
icon = nf .icon .WARNING
97
- padding = " "
98
94
color = nf .color .RED
99
95
time_ms = 60 * 1000
100
96
}
101
97
102
98
nf .icon .value = icon
103
- nf .icon .padding = padding
99
+ nf .icon .padding = ""
104
100
nf .color .value = color
105
101
nf .time_ms = time_ms
106
102
}
You can’t perform that action at this time.
0 commit comments