Now the Image is resized according to font Size
Image is now resized according to the font size and also a new globals.go files is added which contains all the globals. the Image width can also be changed according to use by adding or substracting pixels to it by changing the globals IMAGE_WIDTH_EXTRA_X, IMAGE_WIDTH_EXTRA_Y Also, now there is no need to specify where the music directory is the mpd.conf file in `~/.config/mpd/` is automatically parsed for music directory
This commit is contained in:
parent
190564abd1
commit
bae972f697
9
globals.go
Normal file
9
globals.go
Normal file
@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
var ADDITIONAL_PADDING_X int = 12
|
||||
var ADDITIONAL_PADDING_Y int = 16
|
||||
|
||||
var IMAGE_WIDTH_EXTRA_X float32 = -1.5
|
||||
var IMAGE_WIDTH_EXTRA_Y float32 = -3.75
|
||||
|
||||
var DBDIR string = getMusicDirectory() + "/"
|
@ -25,13 +25,13 @@ func getAlbumArt(uri string) string {
|
||||
}
|
||||
albumCover := m.Picture()
|
||||
if albumCover != nil {
|
||||
b, err := os.Create("hello.jpg")
|
||||
b, err := os.Create("thumb.jpg")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer b.Close()
|
||||
b.Write(albumCover.Data)
|
||||
path = "hello.jpg"
|
||||
path = "thumb.jpg"
|
||||
b.Close()
|
||||
}
|
||||
f.Close()
|
||||
@ -51,8 +51,9 @@ func getImg(uri string) (image.Image, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
img = resize.Thumbnail(
|
||||
uint(IMG_W*22), uint(IMG_H*15),
|
||||
fw, fh := getFontWidth()
|
||||
img = resize.Resize(
|
||||
uint(float32(IMG_W)*(fw+IMAGE_WIDTH_EXTRA_X)), uint(float32(IMG_H)*(fh+IMAGE_WIDTH_EXTRA_Y)),
|
||||
img,
|
||||
resize.Bilinear,
|
||||
)
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
)
|
||||
|
||||
var CurrentSong string
|
||||
var DBDIR string = "PATH TO YOUR MPD DATABASE"
|
||||
|
||||
// The progressBar is just a string which is separated by the color formatting String
|
||||
// for e.g
|
||||
|
@ -13,9 +13,6 @@ type Renderer struct {
|
||||
c chan string
|
||||
}
|
||||
|
||||
var ADDITIONAL_PADDING_X int = 16
|
||||
var ADDITIONAL_PADDING_Y int = 24
|
||||
|
||||
/*
|
||||
Returns a new Renderer with a string channel
|
||||
*/
|
||||
|
27
utils.go
27
utils.go
@ -1,6 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
@ -80,3 +83,27 @@ func formatString(a interface{}) string {
|
||||
return "Paused"
|
||||
}
|
||||
}
|
||||
|
||||
func getMusicDirectory() string {
|
||||
a, _ := os.UserHomeDir()
|
||||
content, err := ioutil.ReadFile(a + "/.config/mpd/mpd.conf")
|
||||
if err != nil {
|
||||
fmt.Println("No Config File for mpd Found")
|
||||
panic(err)
|
||||
}
|
||||
ab := string(content)
|
||||
maps := strings.Split(ab, "\n")
|
||||
for _, j := range maps {
|
||||
if strings.Contains(j, "music_directory") {
|
||||
s := strings.SplitAfter(strings.ReplaceAll(j, " ", ""), "y")[1]
|
||||
d := ""
|
||||
for z, m := range s {
|
||||
if (z != 0) && (z != (len(s) - 1)) {
|
||||
d += string(m)
|
||||
}
|
||||
}
|
||||
return d
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user