diff --git a/PKGBUILD b/PKGBUILD index 2401dc3..a0e4664 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -11,7 +11,7 @@ pkgdesc="Fetch written in Go with image support" arch=('x86_64') url="git+https://codeberg.org/nekohepott/goGoFetch.git" license=('MIT') -depends=('glibc') +depends=('glibc' 'chafa') makedepends=('git' 'go') checkdepends=() optdepends=() diff --git a/README.md b/README.md index 974ade3..2a44b86 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Fetch written in Go with image support (only for foot and kitty) +# Fetch written in Go with image support ![Fetch image](assets/screenshot.png "fetch") @@ -7,6 +7,7 @@ you can get gogofetch on AUR! ```bash yay -S gogofetch-git ``` +also chafa is dependency for gogofetch # Usage basic usage: @@ -15,11 +16,11 @@ gogofetch ``` to show custom image (only png supported btw): ```bash -gogofetch -i *absolute_path* +gogofetch -l *absolute_path* ``` to show custom image and set custom width: ```bash -gogofetch -i *absolute_path* -w 250 +gogofetch -l *absolute_path* -w 250 ``` to show help message: ```bash @@ -70,6 +71,12 @@ and run: ./main ``` - +# Some screenshots + +![alacritty](assets/alacritty.png "alacritty") alacritty + +![foot](assets/foot.png "foot") foot + +![necrokall](assets/xterm.png "xterm") xterm diff --git a/assets/alacritty.png b/assets/alacritty.png new file mode 100644 index 0000000..72d196a --- /dev/null +++ b/assets/alacritty.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b280ca80646d36a60f6b3690cd010fc637b1c9eaeb21abfac3d80c593001761b +size 25667 diff --git a/assets/foot.png b/assets/foot.png new file mode 100644 index 0000000..d6d46c6 --- /dev/null +++ b/assets/foot.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f867fd5fecdef8eb2910acb55efd4c4de9b2314daa5ecacde7fdce174add1a22 +size 27977 diff --git a/assets/nixos.png b/assets/nixos.png index ab339cb..fb3e410 100644 --- a/assets/nixos.png +++ b/assets/nixos.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a1535c35f416ab1c58124d1ebbf698e478695d2dfee925f4ce1409335baec8cc -size 179310 +oid sha256:d8ad1469729821210509862c07ad91514cc3f1d171e274abf3d31563e274dcc1 +size 21411 diff --git a/assets/xterm.png b/assets/xterm.png new file mode 100644 index 0000000..ba38b9c --- /dev/null +++ b/assets/xterm.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eef23ee124d2afd1f305b185ae9728528ae628ecb837227a72f5bad14bb3651b +size 7662 diff --git a/main.go b/main.go index 0b9b197..82ecdc9 100644 --- a/main.go +++ b/main.go @@ -2,21 +2,14 @@ package main import ( "bufio" - "bytes" - "encoding/base64" "flag" "fmt" - "image" - "image/png" _ "image/png" "os" "os/exec" "regexp" "strconv" "strings" - - "github.com/mattn/go-sixel" - "github.com/nfnt/resize" ) const ( @@ -51,7 +44,7 @@ func getDist() string { return dist } } - return "unsupported distro" + return "unknown distro :(" } func getRam() string { @@ -196,30 +189,13 @@ func getPkgs() string { // return "unknown" //} -func printLogo(path string, Width uint) { - file, _ := os.Open(path) - defer func(file *os.File) { - err := file.Close() - if err != nil { - return - } - }(file) - img, _, _ := image.Decode(file) - resizedImg := resize.Resize(Width, 0, img, resize.Lanczos3) - if os.Getenv("KITTY_PID") != "" || os.Getenv("TERM") == "xterm-kitty" { - var buf bytes.Buffer - err := png.Encode(&buf, resizedImg) - if err != nil { - return - } - enc := base64.StdEncoding.EncodeToString(buf.Bytes()) - fmt.Printf("\033_Gf=100,a=T;%s\033\\\n", enc) - } else { - err := sixel.NewEncoder(os.Stdout).Encode(resizedImg) - fmt.Printf("\n") - if err != nil { - return - } +func printLogo(path string, width uint) { + cols := width / 8 + sizeArg := fmt.Sprintf("--size=%dx%d", cols, cols/2) + cmd := exec.Command("chafa", path, sizeArg, "--symbols=half") + cmd.Stdout = os.Stdout + if err := cmd.Run(); err != nil { + fmt.Println("Chafa error:", err) } } @@ -244,8 +220,8 @@ func main() { {"pkgs", getPkgs()}, } - logoPath := flag.String("i", defaultLogo, "Absolute or relative path to the logo image (only png)") - width := flag.Int("w", 200, "Logo width in lines (400 IS MAXIMUM FOR KITTY VALUES ABOVE WILL CRASH TERMINAL)") + logoPath := flag.String("l", defaultLogo, "Absolute or relative path to the logo image") + width := flag.Int("w", 200, "Logo width in lines") flag.Parse() if _, err := os.Stat(*logoPath); os.IsNotExist(err) { fmt.Printf("Image '%s' not found\n", *logoPath)