build: PKGBUILD added
[zvuchno.git] / volume_notification.go
1 // This file is a part of git.thekondor.net/zvuchno.git (mirror: github.com/thekondor/zvuchno)
2
3 package main
4
5 import (
6         "github.com/godbus/dbus"
7 )
8
9 type VolumeNotification struct {
10         conn                      dbus.BusObject
11         notificationReplacementID uint32
12 }
13
14 func NewVolumeNotification(bus *dbus.Conn) VolumeNotification {
15         obj := bus.Object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
16         return VolumeNotification{conn: obj}
17 }
18
19 func (vn *VolumeNotification) Show(title, message string, timeout uint32) {
20         hints := map[string]interface{}{}
21         out := vn.conn.Call(
22                 "org.freedesktop.Notifications.Notify", 0, "Volume",
23                 vn.notificationReplacementID, "volume", title, message, []string{}, hints, int(timeout))
24         out.Store(&vn.notificationReplacementID)
25 }