Skip to content

Commit

Permalink
Update: destructured
Browse files Browse the repository at this point in the history
  • Loading branch information
ssleert committed Jul 14, 2022
1 parent f3fd20a commit a18ed4d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
6 changes: 5 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ linkNoNerd="https://github.com/unxsh/nitch/releases/download/0.1.3/nitchNoNerd"

sudo rm -fv /usr/local/bin/nitch

echo ""

read -p "Use nerd font sumbols? (y/n):" symbolsYN
case $symbolsYN in
"y")
Expand All @@ -16,4 +18,6 @@ case $symbolsYN in
chmod +x nitchNoNerd
sudo mv nitchNoNerd /usr/local/bin/nitch
;;
esac
esac

echo ""
22 changes: 13 additions & 9 deletions src/funcs/drawing.nim
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import std/terminal # import standard terminal lib
import ../assets/logos # import logos from nitch/src/assets/logos
import getDistroId
import ../nitches/[getUser, getHostname,
getDistro, getKernel,
getUptime, getShell,
getPkgs, getRam] # import nitches to get info about user system

# the main function for drawing fetch
proc drawInfo*() =
let # distro id (arch, manjaro, debian)
distroId: string = getDistroId()

const # icons before cotegores
userIcon: string = "" # recomended: " "
hnameIcon: string = "" # recomended: " "
Expand All @@ -30,15 +34,15 @@ proc drawInfo*() =
ramCat: string = " memory │ " # recomended: " memory │ "

let # all info about system
defaultLogo: string = nitchLogo # default nitch logo from nitch/src/assets/logos
userInfo: string = getUser() # get user through $USER env variable
hostnameInfo: string = getHostname() # get Hostname hostname through /etc/hostname
distroInfo: string = getDistro() # get distro through /etc/os-release
kernelInfo: string = getKernel() # get kernel through /proc/version
uptimeInfo: string = getUptime() # get Uptime through /proc/uptime file
shellInfo: string = getShell() # get shell through $SHELL env variable
pkgsInfo: string = getPkgs() # get amount of packages in distro
ramInfo: string = getRam() # get ram through /proc/meminfo
defaultLogo: string = nitchLogo # default nitch logo from nitch/src/assets/logos
userInfo: string = getUser() # get user through $USER env variable
hostnameInfo: string = getHostname() # get Hostname hostname through /etc/hostname
distroInfo: string = getDistro() # get distro through /etc/os-release
kernelInfo: string = getKernel() # get kernel through /proc/version
uptimeInfo: string = getUptime() # get Uptime through /proc/uptime file
shellInfo: string = getShell() # get shell through $SHELL env variable
pkgsInfo: string = getPkgs(distroId) # get amount of packages in distro
ramInfo: string = getRam() # get ram through /proc/meminfo


# colored out
Expand Down
7 changes: 7 additions & 0 deletions src/funcs/getDistroId.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import std/parsecfg

proc getDistroId*(): string =
let
osRelease: Config = loadConfig("/etc/os-release")

result = osRelease.getSectionValue("", "ID")
10 changes: 2 additions & 8 deletions src/nitches/getPkgs.nim
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import std/parsecfg
import ../funcs/packages/getPacmanPkgs

proc getPkgs*(): string =
let
osRelease: Config = loadConfig("/etc/os-release")

sysId: string = osRelease.getSectionValue("", "ID")

case sysId:
proc getPkgs*(distroId: string): string =
case distroId:
of "arch":
result = getPacmanPkgs()

Expand Down

0 comments on commit a18ed4d

Please sign in to comment.