From a18ed4d3e88f2a2790503faad7f639aae0ab5b7d Mon Sep 17 00:00:00 2001 From: sfome Date: Fri, 15 Jul 2022 02:48:09 +0300 Subject: [PATCH] Update: destructured --- setup.sh | 6 +++++- src/funcs/drawing.nim | 22 +++++++++++++--------- src/funcs/getDistroId.nim | 7 +++++++ src/nitches/getPkgs.nim | 10 ++-------- 4 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 src/funcs/getDistroId.nim diff --git a/setup.sh b/setup.sh index 9405905..5964f61 100755 --- a/setup.sh +++ b/setup.sh @@ -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") @@ -16,4 +18,6 @@ case $symbolsYN in chmod +x nitchNoNerd sudo mv nitchNoNerd /usr/local/bin/nitch ;; -esac \ No newline at end of file +esac + +echo "" \ No newline at end of file diff --git a/src/funcs/drawing.nim b/src/funcs/drawing.nim index 95f567d..077caa3 100644 --- a/src/funcs/drawing.nim +++ b/src/funcs/drawing.nim @@ -1,5 +1,6 @@ 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, @@ -7,6 +8,9 @@ import ../nitches/[getUser, getHostname, # 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: " " @@ -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 diff --git a/src/funcs/getDistroId.nim b/src/funcs/getDistroId.nim new file mode 100644 index 0000000..71b72b3 --- /dev/null +++ b/src/funcs/getDistroId.nim @@ -0,0 +1,7 @@ +import std/parsecfg + +proc getDistroId*(): string = + let + osRelease: Config = loadConfig("/etc/os-release") + + result = osRelease.getSectionValue("", "ID") \ No newline at end of file diff --git a/src/nitches/getPkgs.nim b/src/nitches/getPkgs.nim index ac61756..b810139 100644 --- a/src/nitches/getPkgs.nim +++ b/src/nitches/getPkgs.nim @@ -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()