forked from Elara6331/itd
Move mpris out of pkg directory and run gofumpt
This commit is contained in:
parent
d475c6905e
commit
73a679d10b
3
calls.go
3
calls.go
@ -7,8 +7,7 @@ import (
|
|||||||
"github.com/godbus/dbus/v5"
|
"github.com/godbus/dbus/v5"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
"go.arsenm.dev/itd/internal/utils"
|
"go.arsenm.dev/itd/internal/utils"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func initCallNotifs(ctx context.Context, dev *infinitime.Device) error {
|
func initCallNotifs(ctx context.Context, dev *infinitime.Device) error {
|
||||||
|
@ -29,7 +29,7 @@ func init() {
|
|||||||
// If config dir is not readable
|
// If config dir is not readable
|
||||||
if _, err = os.ReadDir(cfgDir); err != nil {
|
if _, err = os.ReadDir(cfgDir); err != nil {
|
||||||
// Create config dir with 700 permissions
|
// Create config dir with 700 permissions
|
||||||
err = os.MkdirAll(cfgDir, 0700)
|
err = os.MkdirAll(cfgDir, 0o700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
2
maps.go
2
maps.go
@ -37,7 +37,7 @@ func initPureMaps(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define rules to listen for
|
// Define rules to listen for
|
||||||
var rules = []string{
|
rules := []string{
|
||||||
"type='signal',interface='io.github.rinigus.PureMaps.navigator'",
|
"type='signal',interface='io.github.rinigus.PureMaps.navigator'",
|
||||||
}
|
}
|
||||||
var flag uint = 0
|
var flag uint = 0
|
||||||
|
@ -109,42 +109,40 @@ func Prev() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func VolUp(percent uint) error {
|
func VolUp(percent uint) error {
|
||||||
|
|
||||||
player, err := getPlayerObj()
|
player, err := getPlayerObj()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if player != nil {
|
if player != nil {
|
||||||
currentVal, err := player.GetProperty("org.mpris.MediaPlayer2.Player.Volume")
|
currentVal, err := player.GetProperty("org.mpris.MediaPlayer2.Player.Volume")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
newVal := currentVal.Value().(float64) + (float64(percent) / 100)
|
newVal := currentVal.Value().(float64) + (float64(percent) / 100)
|
||||||
err = player.SetProperty("org.mpris.MediaPlayer2.Player.Volume", newVal)
|
err = player.SetProperty("org.mpris.MediaPlayer2.Player.Volume", newVal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func VolDown(percent uint) error {
|
func VolDown(percent uint) error {
|
||||||
|
|
||||||
player, err := getPlayerObj()
|
player, err := getPlayerObj()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if player != nil {
|
if player != nil {
|
||||||
currentVal, err := player.GetProperty("org.mpris.MediaPlayer2.Player.Volume")
|
currentVal, err := player.GetProperty("org.mpris.MediaPlayer2.Player.Volume")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
newVal := currentVal.Value().(float64) - (float64(percent) / 100)
|
newVal := currentVal.Value().(float64) - (float64(percent) / 100)
|
||||||
err = player.SetProperty("org.mpris.MediaPlayer2.Player.Volume", newVal)
|
err = player.SetProperty("org.mpris.MediaPlayer2.Player.Volume", newVal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
14
music.go
14
music.go
@ -19,30 +19,30 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
|
"go.arsenm.dev/itd/mpris"
|
||||||
"go.arsenm.dev/itd/translit"
|
"go.arsenm.dev/itd/translit"
|
||||||
"go.arsenm.dev/itd/pkg/mpris"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func initMusicCtrl(ctx context.Context, dev *infinitime.Device) error {
|
func initMusicCtrl(ctx context.Context, dev *infinitime.Device) error {
|
||||||
mpris.Init(ctx)
|
mpris.Init(ctx)
|
||||||
|
|
||||||
maps := k.Strings("notifs.translit.use")
|
maps := k.Strings("notifs.translit.use")
|
||||||
translit.Transliterators["custom"] = translit.Map(k.Strings("notifs.translit.custom"))
|
translit.Transliterators["custom"] = translit.Map(k.Strings("notifs.translit.custom"))
|
||||||
|
|
||||||
mpris.OnChange(func(ct mpris.ChangeType, val string) {
|
mpris.OnChange(func(ct mpris.ChangeType, val string) {
|
||||||
newVal := translit.Transliterate(val, maps...)
|
newVal := translit.Transliterate(val, maps...)
|
||||||
if !firmwareUpdating {
|
if !firmwareUpdating {
|
||||||
switch ct {
|
switch ct {
|
||||||
case mpris.ChangeTypeStatus:
|
case mpris.ChangeTypeStatus:
|
||||||
dev.Music.SetStatus(val == "Playing")
|
dev.Music.SetStatus(val == "Playing")
|
||||||
case mpris.ChangeTypeTitle:
|
case mpris.ChangeTypeTitle:
|
||||||
dev.Music.SetTrack(newVal)
|
dev.Music.SetTrack(newVal)
|
||||||
case mpris.ChangeTypeAlbum:
|
case mpris.ChangeTypeAlbum:
|
||||||
dev.Music.SetAlbum(newVal)
|
dev.Music.SetAlbum(newVal)
|
||||||
case mpris.ChangeTypeArtist:
|
case mpris.ChangeTypeArtist:
|
||||||
dev.Music.SetArtist(newVal)
|
dev.Music.SetArtist(newVal)
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ import (
|
|||||||
"github.com/godbus/dbus/v5"
|
"github.com/godbus/dbus/v5"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"go.arsenm.dev/infinitime"
|
"go.arsenm.dev/infinitime"
|
||||||
"go.arsenm.dev/itd/translit"
|
|
||||||
"go.arsenm.dev/itd/internal/utils"
|
"go.arsenm.dev/itd/internal/utils"
|
||||||
|
"go.arsenm.dev/itd/translit"
|
||||||
)
|
)
|
||||||
|
|
||||||
func initNotifRelay(ctx context.Context, dev *infinitime.Device) error {
|
func initNotifRelay(ctx context.Context, dev *infinitime.Device) error {
|
||||||
@ -37,7 +37,7 @@ func initNotifRelay(ctx context.Context, dev *infinitime.Device) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define rules to listen for
|
// Define rules to listen for
|
||||||
var rules = []string{
|
rules := []string{
|
||||||
"type='method_call',member='Notify',path='/org/freedesktop/Notifications',interface='org.freedesktop.Notifications'",
|
"type='method_call',member='Notify',path='/org/freedesktop/Notifications',interface='org.freedesktop.Notifications'",
|
||||||
}
|
}
|
||||||
var flag uint = 0
|
var flag uint = 0
|
||||||
|
@ -43,7 +43,7 @@ var (
|
|||||||
|
|
||||||
func startSocket(ctx context.Context, dev *infinitime.Device) error {
|
func startSocket(ctx context.Context, dev *infinitime.Device) error {
|
||||||
// Make socket directory if non-existant
|
// Make socket directory if non-existant
|
||||||
err := os.MkdirAll(filepath.Dir(k.String("socket.path")), 0755)
|
err := os.MkdirAll(filepath.Dir(k.String("socket.path")), 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user