Compare commits

..

No commits in common. "6e0427cc62d2e628a55bd9e969da237c1860c60c" and "dff0a8ca476eb42f2da46f55d5f61a4293529d3c" have entirely different histories.

6 changed files with 87 additions and 49 deletions

View File

@ -0,0 +1,54 @@
name: Build and Release
on:
push:
tags:
- "v*"
jobs:
build:
runs-on: codeberg-small
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "stable"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y chafa libglib2.0-dev jq
- name: Build binary
run: make build
- name: Test binary
run: ./gogofetch -h
- name: Package release artifact
run: |
tar -czvf gogofetch-${{ github.ref_name }}-linux-amd64.tar.gz gogofetch Makefile logos/
- name: Create Release and Upload Asset via API
run: |
TAG="${{ github.ref_name }}"
REPO="${{ github.repository }}"
TOKEN="${{ secrets.GITHUB_TOKEN }}"
ASSET="gogofetch-${TAG}-linux-amd64.tar.gz"
RELEASE_ID=$(curl -X POST "${{ github.server_url }}/api/v1/repos/${REPO}/releases" \
-H "Authorization: token ${TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"${TAG}\",\"target_commitish\":\"master\",\"name\":\"Release ${TAG}\",\"body\":\"Automated binary release for Arch Linux AUR\",\"draft\":false,\"prerelease\":false}" \
| jq '.id')
echo "Created release with ID: ${RELEASE_ID}"
curl -X POST "${{ github.server_url }}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \
-H "Authorization: token ${TOKEN}" \
-H "Accept: application/json" \
-F "attachment=@./${ASSET}"

13
.gitignore vendored
View File

@ -1,3 +1,10 @@
.idea/* idea/*
*goGoFetch* /main
*gogofetch* result*
./src
./pkg
./goGoFetch
/gogofetch-git-r14.ff1fcf9-1-x86_64.pkg.tar.zst
./gogofetch-git
/goGoFetch
/gogofetch

View File

@ -1,16 +1,16 @@
# Maintainer: Mykhailo Aleksieiev <mishanya.bigimot@gmail.com> # Maintainer: Mykhailo Aleksieiev <mishanya.bigimot@gmail.com>
pkgname=gogofetch-git pkgname=gogofetch-git
pkgver=r134.da944b7 pkgver=r72.51d32b6
pkgrel=1 pkgrel=1
pkgdesc="Fetch written in Go with image support" pkgdesc="Fetch written in Go with image support"
arch=('x86_64') arch=('x86_64')
url="https://codeberg.org/nekohepott/goGoFetch" url="https://codeberg.org/nekohepott/goGoFetch"
license=('MIT') license=('MIT')
depends=('glibc' 'chafa') depends=('glibc' 'chafa')
makedepends=('git' 'go' 'git-lfs') makedepends=('git' 'go')
provides=("gogofetch") provides=("gogofetch")
conflicts=("gogofetch") conflicts=("gogofetch")
source=("goGoFetch::git+https://codeberg.org/nekohepott/goGoFetch.git#branch=master") source=("git+https://codeberg.org/nekohepott/goGoFetch.git")
sha256sums=('SKIP') sha256sums=('SKIP')
pkgver() { pkgver() {
@ -18,13 +18,6 @@ pkgver() {
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
} }
prepare() {
cd "goGoFetch"
git remote set-url origin https://codeberg.org/nekohepott/goGoFetch.git
git lfs install --local
git lfs pull
}
build() { build() {
cd "goGoFetch" cd "goGoFetch"
export GOPATH="$srcdir/gopath" export GOPATH="$srcdir/gopath"

View File

@ -37,12 +37,12 @@ yay -S gogofetch-git
### Gentoo ### Gentoo
```bash ```bash
eselect repository add urug git https://codeberg.org/koru/urug eselect repository add nekohepott git https://codeberg.org/nekohepott/neko-overlay.git
emerge --sync urug emerge --sync nekohepott
emerge -av gogofetch emerge -av gogofetch
``` ```
Also see: <https://codeberg.org/koru/urug>. Also see: <https://codeberg.org/nekohepott/neko-overlay>.
### NixOS ### NixOS
@ -70,9 +70,6 @@ gogofetch
### Linux ### Linux
> [!WARNING]
> You need to install git-lfs before cloning repository!
```bash ```bash
git clone https://codeberg.org/nekohepott/goGoFetch && cd goGoFetch git clone https://codeberg.org/nekohepott/goGoFetch && cd goGoFetch
make build make build

View File

@ -7,7 +7,6 @@ import (
_ "image/png" _ "image/png"
"os" "os"
"strings" "strings"
"sync"
) )
func main() { func main() {
@ -34,10 +33,7 @@ func main() {
fmt.Println("Warning: No layout specified in config, using default") fmt.Println("Warning: No layout specified in config, using default")
} }
distID, prettyName, err := providers.GetDist() distID, prettyName := providers.GetDist()
if err != nil {
fmt.Println(err)
}
var defaultLogo string var defaultLogo string
if conf.CustomLogo != "" { if conf.CustomLogo != "" {
@ -78,13 +74,13 @@ func main() {
statProviders := map[string]statProvider{ statProviders := map[string]statProvider{
"host": {label: "host", fn: providers.GetHostname}, "host": {label: "host", fn: providers.GetHostname},
"dist": {label: "os", fn: func() string { return prettyName }}, "dist": {label: "os", fn: func() string { return prettyName }},
"cpu": {label: "cpu", fn: func() string { v, _ := providers.GetCpu(); return v }}, "cpu": {label: "cpu", fn: providers.GetCpu},
"krnl": {label: "kernel", fn: providers.GetKernel}, "krnl": {label: "kernel", fn: providers.GetKernel},
"ram": {label: "ram", fn: func() string { v, _ := providers.GetRam(); return v }}, "ram": {label: "ram", fn: providers.GetRam},
"gpu": {label: "gpu", fn: providers.GetGpu}, "gpu": {label: "gpu", fn: providers.GetGpu},
"de/wm": {label: "de/wm", fn: providers.GetDE}, "de/wm": {label: "de/wm", fn: providers.GetDE},
"pkgs": {label: "packages", fn: providers.GetPkgs}, "pkgs": {label: "packages", fn: providers.GetPkgs},
"sh": {label: "shell", fn: providers.GetShell}, "shell": {label: "shell", fn: providers.GetShell},
"term": {label: "terminal", fn: providers.GetTerminal}, "term": {label: "terminal", fn: providers.GetTerminal},
"uptime": {label: "uptime", fn: providers.GetUptime}, "uptime": {label: "uptime", fn: providers.GetUptime},
"age": {label: "age", fn: providers.GetAge}, "age": {label: "age", fn: providers.GetAge},
@ -133,7 +129,7 @@ func main() {
} }
fallbackToAscii := func(path *string) []string { fallbackToAscii := func(path *string) []string {
fmt.Println("chafa binary not found, chafa is the dependency of gogofetch, please install it.") fmt.Println("chafa binary not found, chafa is the dependency of gogofetch, please install it")
parts := strings.Split(*path, ".") parts := strings.Split(*path, ".")
if len(parts) > 1 { if len(parts) > 1 {
parts[len(parts)-1] = "txt" parts[len(parts)-1] = "txt"

View File

@ -17,7 +17,7 @@ var id, prettyName string
const gpuCacheFile = "/tmp/gogofetch_gpu_cache" const gpuCacheFile = "/tmp/gogofetch_gpu_cache"
func GetDist() (string, string, error) { func GetDist() (string, string) {
f, _ := os.Open("/etc/os-release") f, _ := os.Open("/etc/os-release")
defer func(f *os.File) { defer func(f *os.File) {
err := f.Close() err := f.Close()
@ -39,13 +39,10 @@ func GetDist() (string, string, error) {
prettyName = strings.ReplaceAll(prettyName, "'", "") prettyName = strings.ReplaceAll(prettyName, "'", "")
} }
} }
if err := s.Err(); err != nil {
return "", "", fmt.Errorf("reading input: %w", err)
}
if id == "" && prettyName == "" { if id == "" && prettyName == "" {
return "unknown", "unknown", nil return "unknown", "unknown"
} }
return id, prettyName, nil return id, prettyName
} }
func getSizeRam(total, avaible, used *int) string { func getSizeRam(total, avaible, used *int) string {
@ -65,10 +62,10 @@ func getSizeRam(total, avaible, used *int) string {
return fmt.Sprintf("%d / %d MiB", *used, totalMB) return fmt.Sprintf("%d / %d MiB", *used, totalMB)
} }
func GetRam() (string, error) { func GetRam() string {
f, err := os.Open("/proc/meminfo") f, err := os.Open("/proc/meminfo")
if err != nil { if err != nil {
return "", err return "error"
} }
defer f.Close() defer f.Close()
@ -80,30 +77,27 @@ func GetRam() (string, error) {
if strings.HasPrefix(line, "MemTotal:") { if strings.HasPrefix(line, "MemTotal:") {
_, err2 := fmt.Sscanf(line, "MemTotal: %d kB", &total) _, err2 := fmt.Sscanf(line, "MemTotal: %d kB", &total)
if err2 != nil { if err2 != nil {
return "", err return ""
} }
} }
if strings.HasPrefix(line, "MemAvailable:") { if strings.HasPrefix(line, "MemAvailable:") {
_, err := fmt.Sscanf(line, "MemAvailable: %d kB", &available) _, err := fmt.Sscanf(line, "MemAvailable: %d kB", &available)
if err != nil { if err != nil {
return "", err return ""
} }
} }
} }
if err := s.Err(); err != nil {
return "", fmt.Errorf("reading input: %w", err)
}
ram := getSizeRam(&total, &available, &used) ram := getSizeRam(&total, &available, &used)
ram = strings.TrimSpace(ram) ram = strings.TrimSpace(ram)
return ram, nil return ram
} }
func GetCpu() (string, error) { func GetCpu() string {
f, err := os.Open("/proc/cpuinfo") f, err := os.Open("/proc/cpuinfo")
if err != nil { if err != nil {
return "unknown", err return "unknown"
} }
defer f.Close() defer f.Close()
@ -116,15 +110,12 @@ func GetCpu() (string, error) {
parts := strings.SplitN(line, ":", 2) parts := strings.SplitN(line, ":", 2)
if len(parts) > 1 { if len(parts) > 1 {
cpu := strings.TrimSpace(parts[1]) cpu := strings.TrimSpace(parts[1])
return cpu, nil return cpu
} }
} }
} }
if err := s.Err(); err != nil {
return "", fmt.Errorf("reading input: %w", err)
}
return strings.TrimSpace(cpu), nil return strings.TrimSpace(cpu)
} }
func readGpuCache() (string, bool) { func readGpuCache() (string, bool) {