Skip to content

Commit 177b8ac

Browse files
committed
deps updates, remove notification daemon, make the icon recognition smarter
1 parent e962d7b commit 177b8ac

File tree

5 files changed

+63
-62
lines changed

5 files changed

+63
-62
lines changed

bar.go

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ package main
2222
import (
2323
_ "embed"
2424
"fmt"
25-
"strconv"
2625
"time"
2726

2827
"github.com/MiracleOS-Team/desktoplib/batteryHandler"
2928
"github.com/MiracleOS-Team/desktoplib/foreignToplevel"
3029
"github.com/MiracleOS-Team/desktoplib/networkManagerHandler"
3130
"github.com/MiracleOS-Team/desktoplib/volumeHandler"
32-
"github.com/MiracleOS-Team/libxdg-go/notificationDaemon"
31+
"github.com/MiracleOS-Team/libxdg-go/desktopFiles"
3332
"github.com/dlasky/gotk3-layershell/layershell"
3433
"github.com/gotk3/gotk3/gdk"
3534
"github.com/gotk3/gotk3/glib"
@@ -56,7 +55,7 @@ func getDateInfo() (string, string) {
5655
return curDayCal, curTimeInString
5756
}
5857

59-
func createSidestuff(nDaemon *notificationDaemon.Daemon) *gtk.Box {
58+
func createSidestuff() *gtk.Box {
6059
sideBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 0)
6160
sideBox.SetHAlign(gtk.ALIGN_END)
6261
sc, _ := sideBox.GetStyleContext()
@@ -165,48 +164,48 @@ func createSidestuff(nDaemon *notificationDaemon.Daemon) *gtk.Box {
165164
sc, _ = notificationBox.GetStyleContext()
166165
sc.AddClass("notification-bell-wrapper")
167166

168-
notificationBar := createNotificationBar(nDaemon)
169-
notificationButton.Connect("clicked", func() {
170-
if notificationBar.IsVisible() {
171-
notificationBar.Hide()
172-
} else {
173-
if len(nDaemon.Notifications) != 0 {
174-
notificationBar.ShowAll()
175-
}
167+
// notificationBar := createNotificationBar(nDaemon)
168+
// notificationButton.Connect("clicked", func() {
169+
// if notificationBar.IsVisible() {
170+
// notificationBar.Hide()
171+
// } else {
172+
// if len(nDaemon.Notifications) != 0 {
173+
// notificationBar.ShowAll()
174+
// }
176175

177-
}
178-
})
176+
// }
177+
// })
179178

180179
ntStack, _ := gtk.StackNew()
181180

182181
notificationImage, _ := gtk.ImageNewFromIconName("preferences-system-notifications-symbolic", gtk.ICON_SIZE_BUTTON)
183182
sc, _ = notificationImage.GetStyleContext()
184183
sc.AddClass("notification-bell")
185184

186-
notificationText, _ := gtk.LabelNew(strconv.Itoa(len(nDaemon.Notifications)))
187-
sc, _ = notificationText.GetStyleContext()
188-
sc.AddClass("h2")
185+
// notificationText, _ := gtk.LabelNew(strconv.Itoa(len(nDaemon.Notifications)))
186+
// sc, _ = notificationText.GetStyleContext()
187+
// sc.AddClass("h2")
189188

190189
ntStack.Add(notificationImage)
191-
ntStack.Add(notificationText)
190+
// ntStack.Add(notificationText)
192191

193192
notificationBox.PackStart(ntStack, false, false, 0)
194193
notificationButton.Add(notificationBox)
195194

196-
glib.TimeoutAdd(uint(100), func() bool {
197-
// Get new date/time info.
198-
notificationText.SetText(strconv.Itoa(len(nDaemon.Notifications)))
199-
if len(nDaemon.Notifications) == 0 {
200-
ntStack.SetVisibleChild(notificationImage)
201-
ntStack.SetTransitionType(gtk.STACK_TRANSITION_TYPE_SLIDE_LEFT)
202-
} else {
203-
ntStack.SetVisibleChild(notificationText)
204-
ntStack.SetTransitionType(gtk.STACK_TRANSITION_TYPE_SLIDE_RIGHT)
205-
}
206-
207-
// Return true to keep the timeout active.
208-
return true
209-
})
195+
// glib.TimeoutAdd(uint(100), func() bool {
196+
// // Get new date/time info.
197+
// notificationText.SetText(strconv.Itoa(len(nDaemon.Notifications)))
198+
// if len(nDaemon.Notifications) == 0 {
199+
// ntStack.SetVisibleChild(notificationImage)
200+
// ntStack.SetTransitionType(gtk.STACK_TRANSITION_TYPE_SLIDE_LEFT)
201+
// } else {
202+
// ntStack.SetVisibleChild(notificationText)
203+
// ntStack.SetTransitionType(gtk.STACK_TRANSITION_TYPE_SLIDE_RIGHT)
204+
// }
205+
206+
// // Return true to keep the timeout active.
207+
// return true
208+
// })
210209

211210
sideBox.PackStart(otherIcons, false, false, 0)
212211
sideBox.PackStart(statusBox, false, false, 0)
@@ -217,7 +216,7 @@ func createSidestuff(nDaemon *notificationDaemon.Daemon) *gtk.Box {
217216
return sideBox
218217
}
219218

220-
func createWorkspaces() *gtk.Box {
219+
func createWorkspaces(apps []desktopFiles.DesktopFile) *gtk.Box {
221220
box, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 10)
222221
box.SetHAlign(gtk.ALIGN_START)
223222
sc, _ := box.GetStyleContext()
@@ -234,7 +233,7 @@ func createWorkspaces() *gtk.Box {
234233
sc, _ := imgButton.GetStyleContext()
235234
sc.AddClass("app")
236235

237-
pathn, err := foreignToplevel.GetIconFromToplevel(k, 16, 1)
236+
pathn, err := foreignToplevel.GetIconFromToplevel(k, 16, 1, apps)
238237
if err == nil {
239238

240239
pixb, _ := gdk.PixbufNewFromFile(pathn)
@@ -254,7 +253,7 @@ func createWorkspaces() *gtk.Box {
254253
return box
255254
}
256255

257-
func createMainIcons() *gtk.Box {
256+
func createMainIcons(apps []desktopFiles.DesktopFile) *gtk.Box {
258257
box, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 10)
259258
box.SetHAlign(gtk.ALIGN_CENTER)
260259

@@ -267,7 +266,7 @@ func createMainIcons() *gtk.Box {
267266
customButton, _ := gtk.ButtonNew()
268267
customButton.Add(customIcon)
269268

270-
mm := createMainMenu()
269+
mm := createMainMenu(apps)
271270

272271
customButton.Connect("clicked", func() {
273272
if mm.IsVisible() {
@@ -285,7 +284,7 @@ func createMainIcons() *gtk.Box {
285284
return box
286285
}
287286

288-
func createBar(nDaemon *notificationDaemon.Daemon) *gtk.Window {
287+
func createBar(apps []desktopFiles.DesktopFile) *gtk.Window {
289288
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
290289
win.SetTitle("Main Bar")
291290
win.SetDecorated(false)
@@ -325,15 +324,15 @@ func createBar(nDaemon *notificationDaemon.Daemon) *gtk.Window {
325324
box, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 10)
326325
sc, _ := box.GetStyleContext()
327326
sc.AddClass("bar")
328-
box.PackStart(createWorkspaces(), false, false, 0)
329-
box.SetCenterWidget(createMainIcons())
330-
box.PackEnd(createSidestuff(nDaemon), false, false, 0)
327+
box.PackStart(createWorkspaces(apps), false, false, 0)
328+
box.SetCenterWidget(createMainIcons(apps))
329+
box.PackEnd(createSidestuff(), false, false, 0)
331330

332331
glib.TimeoutAdd(uint(500), func() bool {
333332
chil := box.GetChildren()
334333
chil.NthData(uint(0)).(*gtk.Widget).Destroy()
335334

336-
wspaces := createWorkspaces()
335+
wspaces := createWorkspaces(apps)
337336
box.PackStart(wspaces, false, false, 0)
338337

339338
box.ShowAll()

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ module github.com/MiracleOS-Team/desktop
33
go 1.24.0
44

55
require (
6-
github.com/MiracleOS-Team/desktoplib v0.0.0-20250825133335-a752d18a2ba1
7-
github.com/MiracleOS-Team/libxdg-go v0.0.0-20250612171904-bbe9fb77c7a2
6+
github.com/MiracleOS-Team/desktoplib v0.0.0-20251012162900-77396125eb94
7+
github.com/MiracleOS-Team/libxdg-go v0.0.0-20251012163055-74d1f12a1177
88
github.com/dlasky/gotk3-layershell v0.0.0-20240515133811-5c5115f0d774
99
github.com/gotk3/gotk3 v0.6.5-0.20240618185848-ff349ae13f56
10-
golang.org/x/text v0.28.0
10+
golang.org/x/text v0.30.0
1111
)
1212

1313
require (
@@ -17,8 +17,8 @@ require (
1717
github.com/itchyny/volume-go v0.2.2 // indirect
1818
github.com/jfreymuth/pulse v0.1.1 // indirect
1919
github.com/moutend/go-wca v0.3.0 // indirect
20-
github.com/stretchr/testify v1.10.0 // indirect
21-
golang.org/x/sys v0.35.0 // indirect
20+
github.com/stretchr/testify v1.11.1 // indirect
21+
golang.org/x/sys v0.37.0 // indirect
2222
gopkg.in/ini.v1 v1.67.0 // indirect
2323
howett.net/plist v1.0.1 // indirect
2424
)

go.sum

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
github.com/MiracleOS-Team/desktoplib v0.0.0-20250825133335-a752d18a2ba1 h1:T92xxnAzXnyFdpNFaWtdYaYPIfd+dtjQJ+xuH1fprYk=
22
github.com/MiracleOS-Team/desktoplib v0.0.0-20250825133335-a752d18a2ba1/go.mod h1:MvUfFjwbQ/rtGzHCgA9B+gs7IwQceVa39P4puUB/jxk=
3+
github.com/MiracleOS-Team/desktoplib v0.0.0-20251012162900-77396125eb94 h1:E1Z6/UiucPwgCo13Zj+D0O+CrYc9ll2K/EPgYT//WpM=
4+
github.com/MiracleOS-Team/desktoplib v0.0.0-20251012162900-77396125eb94/go.mod h1:cvL31l5z1msP/V/NvTmYDen+bRewt9sEzxdwpkTwQvo=
35
github.com/MiracleOS-Team/libxdg-go v0.0.0-20250612171904-bbe9fb77c7a2 h1:Wz03uVCmKuYANnZYZLbZ7jOF7Lx3ePiUyVM5o9lwOVA=
46
github.com/MiracleOS-Team/libxdg-go v0.0.0-20250612171904-bbe9fb77c7a2/go.mod h1:GA/p+ukjyXCsrcpGvs0/gFp1NeHAMtJG/sYT0JcImfE=
7+
github.com/MiracleOS-Team/libxdg-go v0.0.0-20251012163055-74d1f12a1177 h1:uiCwXSxEPJ8HhFSa03KG3ghAzjxrH3C3hv1XkhDKod0=
8+
github.com/MiracleOS-Team/libxdg-go v0.0.0-20251012163055-74d1f12a1177/go.mod h1://cELzVs4L53pOZ66czbEYfKhjT0MK6QHyIu/awBR8M=
59
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
610
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
711
github.com/distatus/battery v0.11.0 h1:KJk89gz90Iq/wJtbjjM9yUzBXV+ASV/EG2WOOL7N8lc=
@@ -27,12 +31,13 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
2731
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2832
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
2933
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
34+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
3035
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
3136
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
32-
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
33-
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
34-
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
35-
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
37+
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
38+
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
39+
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
40+
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
3641
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
3742
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
3843
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=

main.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"log"
2525
"os"
2626

27+
"github.com/MiracleOS-Team/libxdg-go/desktopFiles"
2728
"github.com/gotk3/gotk3/gdk"
2829
"github.com/gotk3/gotk3/gtk"
2930
)
@@ -38,11 +39,10 @@ func loadCSS() {
3839

3940
err := provider.LoadFromData(cssData)
4041
if err != nil {
41-
err = provider.LoadFromPath("/opt/miracleos-software/desktop/desktop.css")
42-
if err != nil {
43-
log.Println("Failed to load CSS into GTK:", err)
44-
return
45-
}
42+
43+
log.Println("Failed to load CSS into GTK:", err)
44+
return
45+
4646
}
4747

4848
display, err := gdk.DisplayGetDefault()
@@ -96,10 +96,9 @@ func main() {
9696
gtk.Init(&os.Args)
9797
loadCSS()
9898

99-
daemon := listenNotifications()
100-
defer daemon.Stop()
99+
apps1, _ := desktopFiles.ListAllApplications()
101100

102-
bar := createBar(daemon)
101+
bar := createBar(apps1)
103102
bar.ShowAll()
104103

105104
gtk.Main()

mainMenu.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ func createAppGroup(apps []desktopFiles.DesktopFile) *gtk.Box {
6767
return group
6868
}
6969

70-
func createAppList() *gtk.ScrolledWindow {
70+
func createAppList(apps1 []desktopFiles.DesktopFile) *gtk.ScrolledWindow {
7171
scroll, _ := gtk.ScrolledWindowNew(nil, nil)
7272
scroll.SetPolicy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
7373
vbox, _ := gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 5)
7474

75-
apps1, _ := desktopFiles.ListAllApplications()
76-
7775
apps := []desktopFiles.DesktopFile{}
7876

7977
for _, app := range apps1 {
@@ -185,7 +183,7 @@ func createPowerButtons() *gtk.Box {
185183
return powerBox
186184
}
187185

188-
func createMainMenu() *gtk.Window {
186+
func createMainMenu(apps []desktopFiles.DesktopFile) *gtk.Window {
189187
win, _ := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)
190188
win.SetTitle("Main Menu")
191189

@@ -225,7 +223,7 @@ func createMainMenu() *gtk.Window {
225223

226224
contentBox, _ := gtk.BoxNew(gtk.ORIENTATION_HORIZONTAL, 10)
227225

228-
appList := createAppList()
226+
appList := createAppList(apps)
229227
sc, _ = appList.GetStyleContext()
230228
sc.AddClass("mm_tab")
231229

0 commit comments

Comments
 (0)