utils

package
v0.0.0-...-58516bd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2025 License: LGPL-2.1 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// BaseColorList is color names list and their default values
	BaseColorList = map[string]string{
		"text":               "ffffff",
		"subtext":            "b3b3b3",
		"main":               "121212",
		"main-elevated":      "242424",
		"highlight":          "1a1a1a",
		"highlight-elevated": "2a2a2a",
		"sidebar":            "000000",
		"player":             "181818",
		"card":               "282828",
		"shadow":             "000000",
		"selected-row":       "ffffff",
		"button":             "1db954",
		"button-active":      "1ed760",
		"button-disabled":    "535353",
		"tab-active":         "333333",
		"notification":       "4687d6",
		"notification-error": "e22134",
		"misc":               "7f7f7f",
	}

	// BaseColorOrder is color name list in an order
	BaseColorOrder = []string{
		"text",
		"subtext",
		"main",
		"main-elevated",
		"highlight",
		"highlight-elevated",
		"sidebar",
		"player",
		"card",
		"shadow",
		"selected-row",
		"button",
		"button-active",
		"button-disabled",
		"tab-active",
		"notification",
		"notification-error",
		"misc",
	}
)
View Source
var (
	// INTERVAL .
	INTERVAL = 200 * time.Millisecond
)

Functions

func Blue

func Blue(text string) string

Blue .

func Bold

func Bold(text string) string

Bold .

func CheckExistAndCreate

func CheckExistAndCreate(dir string)

CheckExistAndCreate checks folder existence and makes that folder, recursively, if it does not exist

func CheckExistAndDelete

func CheckExistAndDelete(dir string)

CheckExistAndDelete checks folder existence and deletes that folder if it does exist

func CmdScanner

func CmdScanner(cmd *exec.Cmd)

CmdScanner is a helper function to scan output from exec.Cmd

func Copy

func Copy(src, dest string, recursive bool, filters []string) error

Copy .

func CopyFile

func CopyFile(srcPath, dest string) error

CopyFile .

func CreateJunction

func CreateJunction(location, destination string) error

CreateJunction creates a junction in Windows or a symlink in Linux/Mac.

func Fatal

func Fatal(err error)

Fatal prints fatal message and exits process

func FetchLatestTag

func FetchLatestTag() (string, error)

func FindAppPath

func FindAppPath() string

FindAppPath finds Spotify location in various possible places of each platform and returns it. Returns blank string if none of default locations exists.

func FindFirstMatch

func FindFirstMatch(input string, regexpTerm string) []string

func FindLastMatch

func FindLastMatch(input string, regexpTerm string) []string

func FindMatch

func FindMatch(input string, regexpTerm string) [][]string

func FindPrefFilePath

func FindPrefFilePath() string

FindPrefFilePath finds Spotify "prefs" file location in various possible places of each platform and returns it. Returns blank string if none of default locations exists.

func FindSymbol

func FindSymbol(debugInfo, content string, clues []string) []string

FindSymbol uses regexp from one or multiple clues to find variable or function symbol in obfuscated code.

func GetCustomAppPath

func GetCustomAppPath(name string) (string, error)

func GetCustomAppSubfolderPath

func GetCustomAppSubfolderPath(folderPath string) string

func GetDebuggerPath

func GetDebuggerPath() string

GetDebuggerPath fetches opening debugger list from localhost and returns the Spotify one.

func GetExecutableDir

func GetExecutableDir() string

GetExecutableDir returns directory of current process

func GetExtensionPath

func GetExtensionPath(name string) (string, error)

func GetJsHelperDir

func GetJsHelperDir() string

GetJsHelperDir returns jsHelper directory in executable directory

func GetSpotifyVersion

func GetSpotifyVersion(prefsPath string) string

GetSpotifyVersion .

func GetStateFolder

func GetStateFolder(name string) string

func GetSubFolder

func GetSubFolder(folder string, name string) string

GetSubFolder checks if folder `name` is available in specified folder, else creates then returns the path.

func GetWhymeFolder

func GetWhymeFolder() string

func Green

func Green(text string) string

Green .

func MigrateConfigFolder

func MigrateConfigFolder()

func MigrateFolders

func MigrateFolders()

func ModifyFile

func ModifyFile(path string, repl func(string) string)

ModifyFile opens file, changes file content by executing `repl` callback function and writes new content.

func PrependTime

func PrependTime(text string) string

PrependTime prepends current time string to text and returns new string

func PrintBold

func PrintBold(text string)

PrintBold prints a bold message

func PrintError

func PrintError(text string)

PrintError prints an error message

func PrintGreen

func PrintGreen(text string)

PrintGreen prints a message in green color

func PrintInfo

func PrintInfo(text string)

PrintInfo prints an info message

func PrintNote

func PrintNote(text string)

PrintNote prints a warning message

func PrintRed

func PrintRed(text string)

PrintRed prints a message in red color

func PrintSuccess

func PrintSuccess(text string)

PrintSuccess prints a success message

func PrintWarning

func PrintWarning(text string)

PrintWarning prints a warning message

func Red

func Red(text string) string

Red .

func Replace

func Replace(str *string, pattern string, repl func(submatches ...string) string)

Replace uses Regexp to find any matched from `input` with `regexpTerm` and replaces them with `replaceTerm` then returns new string.

func ReplaceEnvVarsInString

func ReplaceEnvVarsInString(input string) string

func ReplaceOnce

func ReplaceOnce(str *string, pattern string, repl func(submatches ...string) string)

func SeekToCloseParen

func SeekToCloseParen(content string, regexpTerm string, leftChar, rightChar byte) string

func SendReload

func SendReload(debuggerURL *string) error

SendReload sends reload command to debugger Websocket server

func ShowDirectory

func ShowDirectory(dir string) error

ShowDirectory shows directory in user's default file manager application

func Unzip

func Unzip(src, dest string) error

Unzip unzips zip

func Watch

func Watch(fileList []string, callbackEach func(fileName string, err error), callbackAfter func())

Watch .

func WatchRecursive

func WatchRecursive(root string, callbackEach func(fileName string, err error), callbackAfter func())

WatchRecursive .

func WinXApp

func WinXApp() string

func WinXPrefs

func WinXPrefs() string

func Yellow

func Yellow(text string) string

Yellow .

Types

type AppManifest

type AppManifest struct {
	Files          []string `json:"subfiles"`
	ExtensionFiles []string `json:"subfiles_extension"`
	Assets         []string `json:"assets"`
}

func GetAppManifest

func GetAppManifest(app string) (AppManifest, string, error)

type Color

type Color interface {
	Hex() string
	RGB() string
	TerminalRGB() string
}

Color stores hex and rgb value of color

func ParseColor

func ParseColor(raw string) Color

ParseColor parses a string in both hex or rgb or from XResources or env variable and converts to both rgb and hex value

type Config

type Config interface {
	Write()
	GetSection(string) *ini.Section
	GetPath() string
}

Config .

func ParseConfig

func ParseConfig(configPath string) Config

ParseConfig read config file content, return default config if file doesn't exist.

type GithubRelease

type GithubRelease struct {
	TagName string `json:"tag_name"`
	Message string `json:"message"`
}

type TernaryBool

type TernaryBool int

TernaryBool is three-way boolean: default, true, false

func (TernaryBool) IsDefault

func (b TernaryBool) IsDefault() bool

IsDefault .

func (TernaryBool) ToForceOperator

func (b TernaryBool) ToForceOperator() string

ToForceOperator .

func (TernaryBool) ToString

func (b TernaryBool) ToString() string

ToString .

type Tracker

type Tracker struct {
	// contains filtered or unexported fields
}

Tracker is used to hold, update and print progress info to console.

func NewTracker

func NewTracker(total int) *Tracker

NewTracker creates new tracker instance

func (*Tracker) Finish

func (t *Tracker) Finish()

Finish prints success message

func (*Tracker) Reset

func (t *Tracker) Reset()

Reset .

func (*Tracker) Update

func (t *Tracker) Update(name string)

Update increases progress count and prints current progress.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL