mirror of
https://github.com/aditya-K2/gspt.git
synced 2026-01-08 21:37:58 -05:00
Alias config.Config to cfg
This commit is contained in:
@@ -36,6 +36,7 @@ var (
|
||||
Main *interactiveView
|
||||
root *Root
|
||||
Flex *tview.Flex
|
||||
cfg = config.Config
|
||||
)
|
||||
|
||||
func onConfigChange() {
|
||||
@@ -80,7 +81,7 @@ func rectWatcher() {
|
||||
ImgH = _ImgH
|
||||
coverArt.RefreshState()
|
||||
}
|
||||
time.Sleep(time.Millisecond * time.Duration(config.Config.RedrawInterval))
|
||||
time.Sleep(time.Millisecond * time.Duration(cfg.RedrawInterval))
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -370,7 +371,7 @@ func NewApplication() *tview.Application {
|
||||
AddItem(navMenu, 6, 3, false).
|
||||
AddItem(playlistNav, 0, 6, false)
|
||||
|
||||
if !config.Config.HideImage {
|
||||
if !cfg.HideImage {
|
||||
navFlex.AddItem(coverArt, 9, 3, false)
|
||||
}
|
||||
|
||||
@@ -393,7 +394,7 @@ func NewApplication() *tview.Application {
|
||||
|
||||
// Start Routines
|
||||
InitNotifier()
|
||||
if !config.Config.HideImage {
|
||||
if !cfg.HideImage {
|
||||
go rectWatcher()
|
||||
} else {
|
||||
// Start Progress Routine directly
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"image"
|
||||
"os"
|
||||
|
||||
"github.com/aditya-K2/gspt/config"
|
||||
"github.com/aditya-K2/tview"
|
||||
"github.com/aditya-K2/utils"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
@@ -41,8 +40,8 @@ func getImg(uri string) (image.Image, error) {
|
||||
return nil, err
|
||||
}
|
||||
img = resize.Resize(
|
||||
uint((ImgW*fw)+config.Config.ImageWidthExtraX),
|
||||
uint((ImgH*fh)+config.Config.ImageWidthExtraY),
|
||||
uint((ImgW*fw)+cfg.ImageWidthExtraX),
|
||||
uint((ImgH*fh)+cfg.ImageWidthExtraY),
|
||||
img,
|
||||
resize.Bilinear,
|
||||
)
|
||||
@@ -93,8 +92,8 @@ func (c *CoverArt) RefreshState() {
|
||||
return
|
||||
}
|
||||
im, err := ueberzug.NewImage(uimg,
|
||||
int(ImgX*fw)+config.Config.AdditionalPaddingX,
|
||||
int(ImgY*fh)+config.Config.AdditionalPaddingY)
|
||||
int(ImgX*fw)+cfg.AdditionalPaddingX,
|
||||
int(ImgY*fh)+cfg.AdditionalPaddingY)
|
||||
if err != nil {
|
||||
SendNotification("Error Rendering Image: %s", err.Error())
|
||||
return
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/gdamore/tcell/v2"
|
||||
"github.com/zmb3/spotify/v2"
|
||||
|
||||
"github.com/aditya-K2/gspt/config"
|
||||
"github.com/aditya-K2/gspt/spt"
|
||||
"github.com/aditya-K2/tview"
|
||||
"github.com/aditya-K2/utils"
|
||||
@@ -101,7 +100,7 @@ func RefreshProgress(force bool) {
|
||||
if state.Item != nil {
|
||||
ctrackId = state.Item.ID
|
||||
}
|
||||
if !config.Config.HideImage {
|
||||
if !cfg.HideImage {
|
||||
coverArt.RefreshState()
|
||||
}
|
||||
}
|
||||
@@ -156,8 +155,8 @@ func progressFunc() (string, string, string, float64) {
|
||||
barTopTitle = fmt.Sprintf("[%s Device: %s Shuffle: %t Repeat: %s]", playing, state.Device.Name, state.ShuffleState, state.RepeatState)
|
||||
if state.Item != nil {
|
||||
barTitle = fmt.Sprintf("%s%s[-:-:-] - %s%s",
|
||||
config.Config.Colors.PBarTrack.String(), state.Item.Name,
|
||||
config.Config.Colors.PBarArtist.String(), state.Item.Artists[0].Name)
|
||||
cfg.Colors.PBarTrack.String(), state.Item.Name,
|
||||
cfg.Colors.PBarArtist.String(), state.Item.Artists[0].Name)
|
||||
barText = utils.StrTime(float64(state.Progress/1000)) + "/" + utils.StrTime(float64(state.Item.Duration/1000))
|
||||
percentage = (float64(state.Progress) / float64(state.Item.Duration)) * 100
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package ui
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/aditya-K2/gspt/config"
|
||||
"github.com/aditya-K2/tview"
|
||||
"github.com/gdamore/tcell/v2"
|
||||
)
|
||||
@@ -75,7 +74,7 @@ func (m *Root) AddCenteredWidget(t CenteredWidget) {
|
||||
t.ContentHandler()
|
||||
|
||||
resizeHandler := func() {
|
||||
dur := config.Config.RedrawInterval
|
||||
dur := cfg.RedrawInterval
|
||||
tck := time.NewTicker(time.Duration(dur) * time.Millisecond)
|
||||
go func() {
|
||||
for {
|
||||
|
||||
47
ui/styles.go
47
ui/styles.go
@@ -1,7 +1,6 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"github.com/aditya-K2/gspt/config"
|
||||
"github.com/aditya-K2/tview"
|
||||
)
|
||||
|
||||
@@ -39,30 +38,30 @@ var (
|
||||
)
|
||||
|
||||
func setBorderRunes() {
|
||||
tview.Borders.TopLeft = borders[config.Config.RoundedCorners]["TopLeft"]
|
||||
tview.Borders.TopRight = borders[config.Config.RoundedCorners]["TopRight"]
|
||||
tview.Borders.BottomRight = borders[config.Config.RoundedCorners]["BottomRight"]
|
||||
tview.Borders.BottomLeft = borders[config.Config.RoundedCorners]["BottomLeft"]
|
||||
tview.Borders.Vertical = borders[config.Config.RoundedCorners]["Vertical"]
|
||||
tview.Borders.Horizontal = borders[config.Config.RoundedCorners]["Horizontal"]
|
||||
tview.Borders.TopLeftFocus = borders[config.Config.RoundedCorners]["TopLeftFocus"]
|
||||
tview.Borders.TopRightFocus = borders[config.Config.RoundedCorners]["TopRightFocus"]
|
||||
tview.Borders.BottomRightFocus = borders[config.Config.RoundedCorners]["BottomRightFocus"]
|
||||
tview.Borders.BottomLeftFocus = borders[config.Config.RoundedCorners]["BottomLeftFocus"]
|
||||
tview.Borders.VerticalFocus = borders[config.Config.RoundedCorners]["VerticalFocus"]
|
||||
tview.Borders.HorizontalFocus = borders[config.Config.RoundedCorners]["HorizontalFocus"]
|
||||
tview.Borders.TopLeft = borders[cfg.RoundedCorners]["TopLeft"]
|
||||
tview.Borders.TopRight = borders[cfg.RoundedCorners]["TopRight"]
|
||||
tview.Borders.BottomRight = borders[cfg.RoundedCorners]["BottomRight"]
|
||||
tview.Borders.BottomLeft = borders[cfg.RoundedCorners]["BottomLeft"]
|
||||
tview.Borders.Vertical = borders[cfg.RoundedCorners]["Vertical"]
|
||||
tview.Borders.Horizontal = borders[cfg.RoundedCorners]["Horizontal"]
|
||||
tview.Borders.TopLeftFocus = borders[cfg.RoundedCorners]["TopLeftFocus"]
|
||||
tview.Borders.TopRightFocus = borders[cfg.RoundedCorners]["TopRightFocus"]
|
||||
tview.Borders.BottomRightFocus = borders[cfg.RoundedCorners]["BottomRightFocus"]
|
||||
tview.Borders.BottomLeftFocus = borders[cfg.RoundedCorners]["BottomLeftFocus"]
|
||||
tview.Borders.VerticalFocus = borders[cfg.RoundedCorners]["VerticalFocus"]
|
||||
tview.Borders.HorizontalFocus = borders[cfg.RoundedCorners]["HorizontalFocus"]
|
||||
}
|
||||
|
||||
func setStyles() {
|
||||
TrackStyle = config.Config.Colors.Track.Style()
|
||||
AlbumStyle = config.Config.Colors.Album.Style()
|
||||
ArtistStyle = config.Config.Colors.Artist.Style()
|
||||
TimeStyle = config.Config.Colors.Timestamp.Style()
|
||||
GenreStyle = config.Config.Colors.Genre.Style()
|
||||
PlaylistNavStyle = config.Config.Colors.PlaylistNav.Style()
|
||||
NavStyle = config.Config.Colors.Nav.Style()
|
||||
ContextMenuStyle = config.Config.Colors.ContextMenu.Style()
|
||||
NotSelectableStyle = config.Config.Colors.Null.Style()
|
||||
tview.Styles.BorderColorFocus = config.Config.Colors.BorderFocus.Foreground()
|
||||
tview.Styles.BorderColor = config.Config.Colors.Border.Foreground()
|
||||
TrackStyle = cfg.Colors.Track.Style()
|
||||
AlbumStyle = cfg.Colors.Album.Style()
|
||||
ArtistStyle = cfg.Colors.Artist.Style()
|
||||
TimeStyle = cfg.Colors.Timestamp.Style()
|
||||
GenreStyle = cfg.Colors.Genre.Style()
|
||||
PlaylistNavStyle = cfg.Colors.PlaylistNav.Style()
|
||||
NavStyle = cfg.Colors.Nav.Style()
|
||||
ContextMenuStyle = cfg.Colors.ContextMenu.Style()
|
||||
NotSelectableStyle = cfg.Colors.Null.Style()
|
||||
tview.Styles.BorderColorFocus = cfg.Colors.BorderFocus.Foreground()
|
||||
tview.Styles.BorderColor = cfg.Colors.Border.Foreground()
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/aditya-K2/gspt/config"
|
||||
"github.com/aditya-K2/gspt/spt"
|
||||
"github.com/zmb3/spotify/v2"
|
||||
"gitlab.com/diamondburned/ueberzug-go"
|
||||
@@ -73,7 +72,7 @@ func addToPlaylist(tracks []spotify.ID) {
|
||||
}
|
||||
|
||||
func fileName(a spotify.SimpleAlbum) string {
|
||||
return fmt.Sprintf(filepath.Join(config.Config.CacheDir, "%s.jpg"), a.ID)
|
||||
return fmt.Sprintf(filepath.Join(cfg.CacheDir, "%s.jpg"), a.ID)
|
||||
}
|
||||
|
||||
func getFontWidth() (int, int, error) {
|
||||
|
||||
Reference in New Issue
Block a user