Compare commits
10 Commits
dff0a8ca47
...
6e0427cc62
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e0427cc62 | ||
|
|
eaea90247d | ||
|
|
2f6b14432b | ||
|
|
75e97a09f6 | ||
|
|
e930791f58 | ||
|
|
1a789ba7f2 | ||
|
|
3021fba918 | ||
|
|
14e121cf90 | ||
|
|
72d2756d3d | ||
|
|
640e145e16 |
@ -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
13
.gitignore
vendored
@ -1,10 +1,3 @@
|
|||||||
idea/*
|
.idea/*
|
||||||
/main
|
*goGoFetch*
|
||||||
result*
|
*gogofetch*
|
||||||
./src
|
|
||||||
./pkg
|
|
||||||
./goGoFetch
|
|
||||||
/gogofetch-git-r14.ff1fcf9-1-x86_64.pkg.tar.zst
|
|
||||||
./gogofetch-git
|
|
||||||
/goGoFetch
|
|
||||||
/gogofetch
|
|
||||||
|
|||||||
13
PKGBUILD
13
PKGBUILD
@ -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=r72.51d32b6
|
pkgver=r134.da944b7
|
||||||
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')
|
makedepends=('git' 'go' 'git-lfs')
|
||||||
provides=("gogofetch")
|
provides=("gogofetch")
|
||||||
conflicts=("gogofetch")
|
conflicts=("gogofetch")
|
||||||
source=("git+https://codeberg.org/nekohepott/goGoFetch.git")
|
source=("goGoFetch::git+https://codeberg.org/nekohepott/goGoFetch.git#branch=master")
|
||||||
sha256sums=('SKIP')
|
sha256sums=('SKIP')
|
||||||
|
|
||||||
pkgver() {
|
pkgver() {
|
||||||
@ -18,6 +18,13 @@ 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"
|
||||||
|
|||||||
@ -37,12 +37,12 @@ yay -S gogofetch-git
|
|||||||
### Gentoo
|
### Gentoo
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
eselect repository add nekohepott git https://codeberg.org/nekohepott/neko-overlay.git
|
eselect repository add urug git https://codeberg.org/koru/urug
|
||||||
emerge --sync nekohepott
|
emerge --sync urug
|
||||||
emerge -av gogofetch
|
emerge -av gogofetch
|
||||||
```
|
```
|
||||||
|
|
||||||
Also see: <https://codeberg.org/nekohepott/neko-overlay>.
|
Also see: <https://codeberg.org/koru/urug>.
|
||||||
|
|
||||||
### NixOS
|
### NixOS
|
||||||
|
|
||||||
@ -70,6 +70,9 @@ 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
|
||||||
|
|||||||
14
src/main.go
14
src/main.go
@ -7,6 +7,7 @@ import (
|
|||||||
_ "image/png"
|
_ "image/png"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -33,7 +34,10 @@ func main() {
|
|||||||
fmt.Println("Warning: No layout specified in config, using default")
|
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
|
var defaultLogo string
|
||||||
|
|
||||||
if conf.CustomLogo != "" {
|
if conf.CustomLogo != "" {
|
||||||
@ -74,13 +78,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: providers.GetCpu},
|
"cpu": {label: "cpu", fn: func() string { v, _ := providers.GetCpu(); return v }},
|
||||||
"krnl": {label: "kernel", fn: providers.GetKernel},
|
"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},
|
"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},
|
||||||
"shell": {label: "shell", fn: providers.GetShell},
|
"sh": {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},
|
||||||
@ -129,7 +133,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"
|
||||||
|
|||||||
@ -17,7 +17,7 @@ var id, prettyName string
|
|||||||
|
|
||||||
const gpuCacheFile = "/tmp/gogofetch_gpu_cache"
|
const gpuCacheFile = "/tmp/gogofetch_gpu_cache"
|
||||||
|
|
||||||
func GetDist() (string, string) {
|
func GetDist() (string, string, error) {
|
||||||
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,10 +39,13 @@ func GetDist() (string, string) {
|
|||||||
prettyName = strings.ReplaceAll(prettyName, "'", "")
|
prettyName = strings.ReplaceAll(prettyName, "'", "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if id == "" && prettyName == "" {
|
if err := s.Err(); err != nil {
|
||||||
return "unknown", "unknown"
|
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 {
|
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)
|
return fmt.Sprintf("%d / %d MiB", *used, totalMB)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRam() string {
|
func GetRam() (string, error) {
|
||||||
f, err := os.Open("/proc/meminfo")
|
f, err := os.Open("/proc/meminfo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "error"
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
@ -77,27 +80,30 @@ func GetRam() string {
|
|||||||
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 ""
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 ""
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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
|
return ram, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetCpu() string {
|
func GetCpu() (string, error) {
|
||||||
f, err := os.Open("/proc/cpuinfo")
|
f, err := os.Open("/proc/cpuinfo")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "unknown"
|
return "unknown", err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
@ -110,12 +116,15 @@ func GetCpu() string {
|
|||||||
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
|
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) {
|
func readGpuCache() (string, bool) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user