Compare commits

...

10 Commits

Author SHA1 Message Date
nekohepott
6e0427cc62
fix: change ram to cpu in GetCpu output 2026-06-29 18:30:21 +03:00
nekohepott
eaea90247d
fix: add "sync" import 2026-06-25 19:00:28 +03:00
nekohepott
2f6b14432b
docs: change gentoo overlay url 2026-06-25 19:00:28 +03:00
nekohepott
75e97a09f6
fix: handle error in Scanner
костыль тот ещё
2026-06-25 19:00:28 +03:00
nekohepott
e930791f58
chore: update .gitignore 2026-06-25 19:00:28 +03:00
koru
1a789ba7f2
fix: typos 2026-06-25 19:00:28 +03:00
nekohepott
3021fba918
fix: update PKGBUILD 2026-06-25 19:00:28 +03:00
nekohepott
14e121cf90
docs: add warning about git-lfs 2026-06-25 19:00:28 +03:00
nekohepott
72d2756d3d
refactor: remove .forgejo due to removing aur binary 2026-06-25 19:00:27 +03:00
nekohepott
640e145e16
style: change release message 2026-06-25 19:00:27 +03:00
6 changed files with 50 additions and 88 deletions

View File

@ -1,54 +0,0 @@
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,10 +1,3 @@
idea/*
/main
result*
./src
./pkg
./goGoFetch
/gogofetch-git-r14.ff1fcf9-1-x86_64.pkg.tar.zst
./gogofetch-git
/goGoFetch
/gogofetch
.idea/*
*goGoFetch*
*gogofetch*

View File

@ -1,16 +1,16 @@
# Maintainer: Mykhailo Aleksieiev <mishanya.bigimot@gmail.com>
pkgname=gogofetch-git
pkgver=r72.51d32b6
pkgver=r134.da944b7
pkgrel=1
pkgdesc="Fetch written in Go with image support"
arch=('x86_64')
url="https://codeberg.org/nekohepott/goGoFetch"
license=('MIT')
depends=('glibc' 'chafa')
makedepends=('git' 'go')
makedepends=('git' 'go' 'git-lfs')
provides=("gogofetch")
conflicts=("gogofetch")
source=("git+https://codeberg.org/nekohepott/goGoFetch.git")
source=("goGoFetch::git+https://codeberg.org/nekohepott/goGoFetch.git#branch=master")
sha256sums=('SKIP')
pkgver() {
@ -18,6 +18,13 @@ pkgver() {
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() {
cd "goGoFetch"
export GOPATH="$srcdir/gopath"

View File

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

View File

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

View File

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