├── .gitignore ├── LICENSE ├── README.md ├── nitch.nimble ├── setup.sh ├── src ├── assets │ ├── assets.nim │ └── logos.nim ├── flags │ └── argParser.nim ├── funcs │ ├── drawing.nim │ ├── getDistroId.nim │ ├── packages │ │ ├── getDpkgPkgs.nim │ │ ├── getPacmanPkgs.nim │ │ ├── getPortagePkgs.nim │ │ ├── getRpmPkgs.nim │ │ └── getXbpsPkgs.nim │ └── perform.nim ├── nitch.nim ├── nitch.nim.cfg └── nitches │ ├── getDistro.nim │ ├── getHostname.nim │ ├── getKernel.nim │ ├── getLogo.nim │ ├── getPkgs.nim │ ├── getRam.nim │ ├── getShell.nim │ ├── getUptime.nim │ └── getUser.nim └── templates ├── bfetch ├── cfgParser.nim ├── colorTest.nim ├── data.dat ├── echo.sh ├── listFiles.nim ├── readLine.nim ├── refTest.nim ├── rxfetch ├── shellCheck.nim ├── slice.nim ├── test.cfg ├── testCounter.nim ├── testFile ├── testProc.nim └── tupleTest.nim /.gitignore: -------------------------------------------------------------------------------- 1 | nitch* 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 ssleert 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | # `NiTch` 6 | 7 |

8 | incredibly fast system fetch written in nim👑 9 |

10 |
11 | 12 | ![Maintenance](https://shields.io/maintenance/yes/2022?style=for-the-badge) 13 | ![License](https://shields.io/github/license/unxsh/nitch?style=for-the-badge) 14 | ![Commits](https://shields.io/github/commit-activity/m/unxsh/nitch?style=for-the-badge) 15 | 16 | ![GitHub Repo stars](https://img.shields.io/github/stars/unxsh/nitch?style=for-the-badge) 17 | ![GitHub issues](https://img.shields.io/github/issues/unxsh/nitch?style=for-the-badge) 18 | ![GitHub pull requests](https://img.shields.io/github/issues-pr/unxsh/nitch?style=for-the-badge) 19 | 20 | ![GitHub release (latest by date)](https://img.shields.io/github/v/release/unxsh/nitch?style=for-the-badge) 21 | 22 |
23 | 24 | # Description 📖 25 | 26 | 27 | 28 | `nitch` is a small and incredibly fast system fetch written fully in `nim👑` without any dependencies, on my pc 29 | it executes in around 1.70 miliseconds. 30 | 31 | The source code of `nitch` is highly documented and I hope it will act as a learning resource for nim 32 | and linux systems architecture 33 | 34 | If anything in the source code is unclear or is lacking in its explanation, open an issue. Sometimes you get too close to something and you fail to see the "bigger picture"! 35 | 36 | 37 | btw written in `nim👑` 38 | 39 | why `nim👑`? because it's fast and simple 40 | 41 |
42 | 43 | # Installation ☁️ 44 | ```fish 45 | wget https://raw.githubusercontent.com/unxsh/nitch/main/setup.sh && sh setup.sh 46 | ``` 47 | 48 | # Usage 🪨 49 | ``` 50 | nitch 51 | ``` 52 | 53 | flags: 54 | ``` 55 | -f --fetch | return fetch about system 56 | -h --help | return help message 57 | -v --version | return version of program 58 | ``` 59 | 60 |
61 | 62 | # Configuration ⚙️ 63 | ### `nitch` is configured by changing the source code 64 | ### `src/funcs/drawing.nim` - config file 65 | ```nim 66 | import std/terminal # import standard terminal lib 67 | import getDistroId # import to get distro id through /etc/os-release 68 | #import ../assets/logos # uncomment if you use your own logo 69 | import ../nitches/[getUser, getHostname, 70 | getDistro, getKernel, 71 | getUptime, getShell, 72 | getPkgs, getRam, 73 | getLogo, getLogoColor] # import nitches to get info about user system 74 | 75 | # the main function for drawing fetch 76 | proc drawInfo*() = 77 | let # distro id (arch, manjaro, debian) 78 | distroId: string = getDistroId() 79 | 80 | let # logo and it color 81 | logoColor: ForegroundColor = getLogoColor(distroId) # color for logo 82 | defaultLogo: string = getLogo(distroId) # default logo from nitch/src/assets/logos 83 | 84 | const # icons before cotegores 85 | userIcon: string = " " # recomended: " " or "|>" 86 | hnameIcon: string = " " # recomended: " " or "|>" 87 | distroIcon: string = "󰻀 " # recomended: "󰻀 " or "|>" 88 | kernelIcon: string = "󰌢 " # recomended: "󰌢 " or "|>" 89 | uptimeIcon: string = " " # recomended: " " or "|>" 90 | shellIcon: string = " " # recomended: " " or "|>" 91 | pkgsIcon: string = "󰏖 " # recomended: "󰏖 " or "|>" 92 | ramIcon: string = "󰍛 " # recomended: "󰍛 " or "|>" 93 | colorsIcon: string = "󰏘 " # recomended: "󰏘 " or "->" 94 | # please insert any char after the icon 95 | # to avoid the bug with cropping the edge of the icon 96 | 97 | dotIcon: string = "" # recomended: "" or "■" 98 | # icon for demonstrate colors 99 | 100 | const # categories 101 | userCat: string = " user │ " # recomended: " user │ " 102 | hnameCat: string = " hname │ " # recomended: " hname │ " 103 | distroCat: string = " distro │ " # recomended: " distro │ " 104 | kernelCat: string = " kernel │ " # recomended: " kernel │ "- 105 | uptimeCat: string = " uptime │ " # recomended: " uptime │ " 106 | shellCat: string = " shell │ " # recomended: " shell │ " 107 | pkgsCat: string = " pkgs │ " # recomended: " pkgs │ " 108 | ramCat: string = " memory │ " # recomended: " memory │ " 109 | colorsCat: string = " colors │ " # recomended: " colors │ " 110 | 111 | let # all info about system 112 | userInfo: string = getUser() # get user through $USER env variable 113 | hostnameInfo: string = getHostname() # get Hostname hostname through /etc/hostname 114 | distroInfo: string = getDistro() # get distro through /etc/os-release 115 | kernelInfo: string = getKernel() # get kernel through /proc/version 116 | uptimeInfo: string = getUptime() # get Uptime through /proc/uptime file 117 | shellInfo: string = getShell() # get shell through $SHELL env variable 118 | pkgsInfo: string = getPkgs(distroId) # get amount of packages in distro 119 | ramInfo: string = getRam() # get ram through /proc/meminfo 120 | 121 | const # aliases for colors 122 | color1: ForegroundColor = fgRed 123 | color2: ForegroundColor = fgYellow 124 | color3: ForegroundColor = fgGreen 125 | color4: ForegroundColor = fgCyan 126 | color5: ForegroundColor = fgBlue 127 | color6: ForegroundColor = fgMagenta 128 | color7: ForegroundColor = fgWhite 129 | color8: ForegroundColor = fgBlack 130 | color0: ForegroundColor = fgDefault 131 | 132 | # colored out 133 | stdout.styledWrite(styleBright, logoColor, defaultLogo) 134 | stdout.styledWrite(styleBright, " ╭───────────╮\n") 135 | stdout.styledWrite(styleBright, " │ ", color1, userIcon, color0, userCat, color1, userInfo, "\n") 136 | stdout.styledWrite(styleBright, " │ ", color2, hnameIcon, color0, hnameCat, color2, hostnameInfo, "\n") 137 | stdout.styledWrite(styleBright, " │ ", color3, distroIcon, color0, distroCat, color3, distroInfo, "\n") 138 | stdout.styledWrite(styleBright, " │ ", color4, kernelIcon, color0, kernelCat, color4, kernelInfo, "\n") 139 | stdout.styledWrite(styleBright, " │ ", color5, uptimeIcon, color0, uptimeCat, color5, uptimeInfo, "\n") 140 | stdout.styledWrite(styleBright, " │ ", color6, shellIcon, color0, shellCat, color6, shellInfo, "\n") 141 | stdout.styledWrite(styleBright, " │ ", color1, pkgsIcon, color0, pkgsCat, color1, pkgsInfo, "\n") 142 | stdout.styledWrite(styleBright, " │ ", color2, ramIcon, color0, ramCat, fgYellow, ramInfo, "\n") 143 | stdout.styledWrite(styleBright, " ├───────────┤\n") 144 | stdout.styledWrite(styleBright, " │ ", color7, colorsIcon, color0, colorsCat, color7, dotIcon, " ", color1, dotIcon, " ", color2, dotIcon, " ", color3, dotIcon, " ", color4, dotIcon, " ", color5, dotIcon, " ", color6, dotIcon, " ", color8, dotIcon, "\n") 145 | stdout.styledWrite(styleBright, " ╰───────────╯\n\n") 146 | ``` 147 | 148 | # Building 📦 149 | ### 0) install [nim](https://nim-lang.org/) 150 | 151 | ### 1) clone repo 152 | ```fish 153 | git clone https://github.com/unxsh/nitch.git 154 | ``` 155 | ### 2) change dir to `nitch` 156 | ```fish 157 | cd nitch/ 158 | ``` 159 | 160 | ### 3) build program with `nimble` 161 | ```fish 162 | nimble build 163 | ``` 164 | After that you will get a ready-made binary file in the root directory of the project. 165 | 166 |
167 | 168 | # File architecture 📁 169 | ```fish 170 | nitch 171 | ├── LICENSE 172 | ├── nitch 173 | ├── nitch.nimble 174 | ├── README.md 175 | ├── src 176 | │ ├── assets 177 | │ │ ├── assets.nim 178 | │ │ └── logos.nim 179 | │ ├── flags 180 | │ │ └── argParser.nim 181 | │ ├── funcs 182 | │ │ ├── drawing.nim 183 | │ │ ├── packages 184 | │ │ │ └── getPacmanPkgs.nim 185 | │ │ └── perform.nim 186 | │ ├── nitches 187 | │ │ ├── getDistro.nim 188 | │ │ ├── getHostname.nim 189 | │ │ ├── getKernel.nim 190 | │ │ ├── getPkgs.nim 191 | │ │ ├── getRam.nim 192 | │ │ ├── getShell.nim 193 | │ │ ├── getUptime.nim 194 | │ │ └── getUser.nim 195 | │ ├── nitch.nim 196 | │ └── nitch.nim.cfg 197 | └── templates 198 | ├── cfgParser 199 | ├── cfgParser.nim 200 | ├── data.dat 201 | ├── listFiles.nim 202 | ├── readLine.nim 203 | ├── refTest.nim 204 | ├── shellCheck.nim 205 | ├── test.cfg 206 | ├── testFile 207 | └── testProc.nim 208 | 209 | 7 directories, 30 files 210 | ``` 211 | 212 | # Thanks for ideas & examples 💬 213 | - [pfetch](https://github.com/dylanaraps/pfetch/) 214 | - [neofetch](https://github.com/dylanaraps/neofetch) 215 | - [paleofetch](https://github.com/ss7m/paleofetch) 216 | - [rxfetch](https://github.com/Mangeshrex/rxfetch) 217 | - [nerdfetch](https://github.com/ThatOneCalculator/NerdFetch) 218 | -------------------------------------------------------------------------------- /nitch.nimble: -------------------------------------------------------------------------------- 1 | # Package 2 | 3 | version = "0.2.2" 4 | author = "sfome" 5 | description = "System fetch in nim lang" 6 | license = "MIT" 7 | 8 | srcDir = "src" 9 | bin = @["nitch"] 10 | 11 | 12 | # Dependencies 13 | 14 | requires "nim >= 1.6.6" 15 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | linkNerd="https://github.com/unxsh/nitch/releases/download/0.1.6/nitchNerd" 4 | linkNoNerd="https://github.com/unxsh/nitch/releases/download/0.1.6/nitchNoNerd" 5 | 6 | sudo rm -fv /usr/local/bin/nitch 7 | 8 | echo "" 9 | 10 | read -p "Use nerd font symbols? (y/n): " symbolsYN 11 | echo "Installation..." 12 | 13 | case $symbolsYN in 14 | "y") 15 | wget $linkNerd 16 | chmod +x nitchNerd 17 | sudo mv nitchNerd /usr/local/bin/nitch 18 | ;; 19 | 20 | "n") 21 | wget $linkNoNerd 22 | chmod +x nitchNoNerd 23 | sudo mv nitchNoNerd /usr/local/bin/nitch 24 | ;; 25 | esac 26 | 27 | echo "" 28 | -------------------------------------------------------------------------------- /src/assets/assets.nim: -------------------------------------------------------------------------------- 1 | const 2 | programVersion* = "nitch - 0.2.2\n" 3 | helpMsg* = r""" 4 | 5 | nitch - incredibly fast system fetch written in nim 6 | 7 | -f --fetch | return fetch about system 8 | -a --no-ascii | return fetch without ascii art 9 | -h --help | return help message 10 | -v --version | return version of program 11 | 12 | """ 13 | -------------------------------------------------------------------------------- /src/assets/logos.nim: -------------------------------------------------------------------------------- 1 | const 2 | nitchLogo* = r""" 3 | 4 | _ ___ ______ __ 5 | / |/ (_)_ __/___/ / 6 | / / / / / / __/ _ \ 7 | /_/|_/_/ /_/ \__/_//_/ 8 | """ 9 | ubuntuLogo* = r""" 10 | 11 | __ ____ __ 12 | / / / / / __ _____ / /___ __ 13 | / /_/ / _ \/ // / _ \/ __/ // / 14 | \____/_.__/\_,_/_//_/\__/\_,_/ 15 | """ 16 | archLogo* = r""" 17 | 18 | ___ __ 19 | / _ | ________/ / 20 | / __ |/ __/ __/ _ \ 21 | /_/ |_/_/ \__/_//_/ 22 | """ 23 | debianLogo* = r""" 24 | 25 | ___ __ _ 26 | / _ \___ / / (_)__ ____ 27 | / // / -_) _ \/ / _ `/ _ \ 28 | /____/\__/_.__/_/\_,_/_//_/ 29 | """ 30 | fedoraLogo* = r""" 31 | 32 | ____ __ 33 | / __/__ ___/ /__ _______ _ 34 | / _// -_) _ / _ \/ __/ _ `/ 35 | /_/ \__/\_,_/\___/_/ \_,_/ 36 | """ 37 | mintLogo* = r""" 38 | 39 | __ ____ __ 40 | / |/ (_)__ / /_ 41 | / /|_/ / / _ \/ __/ 42 | /_/ /_/_/_//_/\__/ 43 | """ 44 | zorinLogo* = r""" 45 | 46 | ____ _ 47 | /_ /___ ____(_)__ 48 | / // _ \/ __/ / _ \ 49 | /___|___/_/ /_/_//_/ 50 | """ 51 | poposLogo* = r""" 52 | 53 | ___ ____ ____ 54 | / _ \___ ___ / __ \/ __/ 55 | / ___/ _ \/ _ \/ /_/ /\ \ 56 | /_/ \___/ .__/\____/___/ 57 | /_/ 58 | """ 59 | manjaroLogo* = r""" 60 | 61 | __ ___ _ 62 | / |/ /__ ____ (_)__ ________ 63 | / /|_/ / _ `/ _ \ / / _ `/ __/ _ \ 64 | /_/ /_/\_,_/_//_/_/ /\_,_/_/ \___/ 65 | |___/ 66 | """ 67 | opensuseLogo* = r""" 68 | 69 | ______ __________ 70 | ___ ___ ___ ___ / __/ / / / __/ __/ 71 | / _ \/ _ \/ -_) _ \_\ \/ /_/ /\ \/ _/ 72 | \___/ .__/\__/_//_/___/\____/___/___/ 73 | /_/ 74 | """ 75 | slackwareLogo* = r""" 76 | 77 | ______ __ 78 | / __/ /__ _____/ /___ _____ ________ 79 | _\ \/ / _ `/ __/ '_/ |/|/ / _ `/ __/ -_) 80 | /___/_/\_,_/\__/_/\_\|__,__/\_,_/_/ \__/ 81 | """ 82 | centosLogo* = r""" 83 | 84 | _____ __ ____ ____ 85 | / ___/__ ___ / /_/ __ \/ __/ 86 | / /__/ -_) _ \/ __/ /_/ /\ \ 87 | \___/\__/_//_/\__/\____/___/ 88 | """ 89 | redhatLogo* = r""" 90 | 91 | ___ ____ __ __ 92 | / _ \___ ___/ / // /__ _/ /_ 93 | / , _/ -_) _ / _ / _ `/ __/ 94 | /_/|_|\__/\_,_/_//_/\_,_/\__/ 95 | """ 96 | gentooLogo* = r""" 97 | 98 | _____ __ 99 | / ___/__ ___ / /____ ___ 100 | / (_ / -_) _ \/ __/ _ \/ _ \ 101 | \___/\__/_//_/\__/\___/\___/ 102 | """ 103 | endeavourosLogo* = r""" 104 | 105 | ____ __ ____ ____ 106 | / __/__ ___/ /__ ___ __ _____ __ ______/ __ \/ __/ 107 | / _// _ \/ _ / -_) _ `/ |/ / _ \/ // / __/ /_/ /\ \ 108 | /___/_//_/\_,_/\__/\_,_/|___/\___/\_,_/_/ \____/___/ 109 | """ 110 | artixLogo* = r""" 111 | 112 | ___ __ _ __ __ 113 | / _ | ____ / /_(_)\ \/ / 114 | / __ |/ __// __/ / > < 115 | /_/ |_/_/ \__/_/ /_/\_\ 116 | """ -------------------------------------------------------------------------------- /src/flags/argParser.nim: -------------------------------------------------------------------------------- 1 | func argParser*(args: seq[string], argCount: int): uint8 = 2 | 3 | # list of constant args 4 | const 5 | argsList: array[6, string] = [ 6 | "-a", "--no-ascii", 7 | "-h", "--help", 8 | "-v", "--version" 9 | ] 10 | 11 | # if no flags 12 | if argCount == 0: 13 | result = 0 # return 0 14 | 15 | else: 16 | # case first argument 17 | case args[0]: 18 | 19 | # if -a --no-ascii flags 20 | of argsList[0..1]: 21 | result = 1 # return 1 22 | 23 | # if -h --help flags 24 | of argsList[2..3]: 25 | result = 2 # return 2 26 | 27 | # if -v --version flags 28 | of argsList[4..5]: 29 | result = 3 # return 2 30 | -------------------------------------------------------------------------------- /src/funcs/drawing.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/terminal, # import standard terminal lib 3 | std/strutils, 4 | getDistroId, # import to get distro id through /etc/os-release 5 | ../assets/logos, # uncomment if you use your own logo 6 | ../nitches/[getUser, getHostname, 7 | getDistro, getKernel, 8 | getUptime, getShell, 9 | getPkgs, getRam, getLogo] # import nitches to get info about user system 10 | 11 | # the main function for drawing fetch 12 | proc drawInfo*(asciiArt: bool) = 13 | let # distro id (arch, manjaro, debian) 14 | distroId = getDistroId() 15 | 16 | let # logo and it color 17 | coloredLogo = getLogo(distroId) # color + logo tuple 18 | # (fgRed, nitchLogo) 19 | 20 | const # icons before cotegores 21 | userIcon = " " # recomended: " " or "|>" 22 | hnameIcon = " " # recomended: " " or "|>" 23 | distroIcon = "󰻀 " # recomended: "󰻀 " or "|>" 24 | kernelIcon = "󰌢 " # recomended: "󰌢 " or "|>" 25 | uptimeIcon = " " # recomended: " " or "|>" 26 | shellIcon = " " # recomended: " " or "|>" 27 | pkgsIcon = "󰏖 " # recomended: "󰏖 " or "|>" 28 | ramIcon = "󰍛 " # recomended: "󰍛 " or "|>" 29 | colorsIcon = "󰏘 " # recomended: "󰏘 " or "->" 30 | # please insert any char after the icon 31 | # to avoid the bug with cropping the edge of the icon 32 | 33 | dotIcon = "" # recomended: "" or "■" 34 | # icon for demonstrate colors 35 | 36 | const # categories 37 | userCat = " user │ " # recomended: " user │ " 38 | hnameCat = " hname │ " # recomended: " hname │ " 39 | distroCat = " distro │ " # recomended: " distro │ " 40 | kernelCat = " kernel │ " # recomended: " kernel │ "- 41 | uptimeCat = " uptime │ " # recomended: " uptime │ " 42 | shellCat = " shell │ " # recomended: " shell │ " 43 | pkgsCat = " pkgs │ " # recomended: " pkgs │ " 44 | ramCat = " memory │ " # recomended: " memory │ " 45 | colorsCat = " colors │ " # recomended: " colors │ " 46 | 47 | let # all info about system 48 | userInfo = getUser() # get user through $USER env variable 49 | hostnameInfo = getHostname() # get Hostname hostname through /etc/hostname 50 | distroInfo = getDistro() # get distro through /etc/os-release 51 | kernelInfo = getKernel() # get kernel through /proc/version 52 | uptimeInfo = getUptime() # get Uptime through /proc/uptime file 53 | shellInfo = getShell() # get shell through $SHELL env variable 54 | pkgsInfo = getPkgs(distroId) # get amount of packages in distro 55 | ramInfo = getRam() # get ram through /proc/meminfo 56 | 57 | const # aliases for colors 58 | color1 = fgRed 59 | color2 = fgYellow 60 | color3 = fgGreen 61 | color4 = fgCyan 62 | color5 = fgBlue 63 | color6 = fgMagenta 64 | color7 = fgWhite 65 | color8 = fgBlack 66 | color0 = fgDefault 67 | 68 | # ascii art 69 | if not asciiArt: 70 | discard 71 | else: 72 | stdout.styledWrite(styleBright, coloredLogo[0], coloredLogo[1], color0) 73 | 74 | # colored out 75 | stdout.styledWrite("\n", styleBright, " ╭───────────╮\n") 76 | stdout.styledWrite(" │ ", color2, userIcon, color0, userCat, color1, userInfo, color0, "\n",) 77 | if not isEmptyOrWhitespace(hostnameInfo): 78 | stdout.styledWrite(" │ ", color2, hnameIcon, color0, hnameCat, color2, hostnameInfo, color0, "\n") 79 | stdout.styledWrite(" │ ", color3, distroIcon, color0, distroCat, color3, distroInfo, color0, "\n") 80 | stdout.styledWrite(" │ ", color4, kernelIcon, color0, kernelCat, color4, kernelInfo, color0, "\n") 81 | stdout.styledWrite(" │ ", color5, uptimeIcon, color0, uptimeCat, color5, uptimeInfo, color0, "\n") 82 | stdout.styledWrite(" │ ", color6, shellIcon, color0, shellCat, color6, shellInfo, color0, "\n") 83 | stdout.styledWrite(" │ ", color1, pkgsIcon, color0, pkgsCat, color1, pkgsInfo, color0, "\n") 84 | stdout.styledWrite(" │ ", color2, ramIcon, color0, ramCat, fgYellow, ramInfo, color0, "\n") 85 | stdout.styledWrite(" ├───────────┤\n") 86 | stdout.styledWrite(" │ ", color7, colorsIcon, color0, colorsCat, color7, dotIcon, " ", color1, dotIcon, " ", color2, dotIcon, " ", color3, dotIcon, " ", color4, dotIcon, " ", color5, dotIcon, " ", color6, dotIcon, " ", color8, dotIcon, color0, "\n") 87 | stdout.styledWrite(" ╰───────────╯\n\n") 88 | -------------------------------------------------------------------------------- /src/funcs/getDistroId.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/parsecfg 3 | 4 | proc getDistroId*(): string = 5 | let 6 | osRelease = "/etc/os-release".loadConfig 7 | 8 | result = osRelease.getSectionValue("", "ID") 9 | -------------------------------------------------------------------------------- /src/funcs/packages/getDpkgPkgs.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/[strutils, osproc] 3 | 4 | proc getDpkgPkgs*(): string = 5 | let 6 | count = osproc.execCmdEx("dpkg -l")[0] 7 | 8 | result = $(count.split("\n").len - 1) 9 | -------------------------------------------------------------------------------- /src/funcs/packages/getPacmanPkgs.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/[os, sequtils] 3 | 4 | proc getPacmanPkgs*(): string = 5 | let 6 | filesInPath: seq[tuple] = "/var/lib/pacman/local".walkDir(relative = true).toSeq 7 | 8 | result = $(filesInPath.len - 1) 9 | -------------------------------------------------------------------------------- /src/funcs/packages/getPortagePkgs.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/[strutils, osproc] 3 | 4 | proc getPortagePkgs*(): string = 5 | let 6 | count = osproc.execCmdEx("ls -d /var/db/pkg/*/*| cut -f5- -d/")[0] 7 | 8 | result = $(count.split("\n").len - 1) 9 | -------------------------------------------------------------------------------- /src/funcs/packages/getRpmPkgs.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/[strutils, osproc] 3 | 4 | proc getRpmPkgs*(): string = 5 | result = osproc.execCmdEx("rpm -qa | wc --lines")[0] 6 | -------------------------------------------------------------------------------- /src/funcs/packages/getXbpsPkgs.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/[strutils, osproc] 3 | 4 | proc getXbpsPkgs*(): string = 5 | let 6 | count = osproc.execCmdEx("xbps-query -l")[0] 7 | 8 | result = $(count.split("\n").len - 1) 9 | -------------------------------------------------------------------------------- /src/funcs/perform.nim: -------------------------------------------------------------------------------- 1 | import 2 | ./drawing, 3 | ../assets/assets 4 | 5 | # if if no flag 6 | proc arg0*() = 7 | drawInfo(true) 8 | 9 | # if -a --no-ascii flags 10 | proc arg1*() = 11 | drawInfo(false) 12 | 13 | # if -h --help flags 14 | proc arg2*() = 15 | stdout.write(helpMsg) # write to stdout helpMsg from nitch/assets/assets file 16 | 17 | # if -v --version flags 18 | proc arg3*() = 19 | stdout.write(programVersion) # write to stdout programVersion from nitch/assets/assets file 20 | -------------------------------------------------------------------------------- /src/nitch.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/os, # import os module from stdlib 3 | flags/argParser, # import arg parser from nitch/flags/argParser 4 | funcs/perform # perform funcs for flags 5 | 6 | let 7 | arg = argParser(commandLineParams(), paramCount()) # called argParser with args seq and amount of args 8 | 9 | # case return of argParser 10 | case arg: 11 | 12 | # if no flags 13 | of 0: 14 | arg0() # cal arg0 func from perform 15 | 16 | # if -a --no-ascii flags 17 | of 1: 18 | arg1() # cal arg1 func from perform 19 | 20 | # if -h --help flags 21 | of 2: 22 | arg2() # cal arg1 func from perform 23 | 24 | # if -v --version flags 25 | of 3: 26 | arg3() # cal arg2 func from perform 27 | 28 | # nim xdd 29 | else: 30 | arg0() 31 | -------------------------------------------------------------------------------- /src/nitch.nim.cfg: -------------------------------------------------------------------------------- 1 | --cc:gcc 2 | --parallelBuild:0 3 | --incremental:off 4 | --verbosity:1 5 | --styleCheck:error 6 | --mm:none 7 | --app:console 8 | --objChecks:off 9 | --fieldChecks:off 10 | --rangeChecks:off 11 | --boundChecks:off 12 | --overflowChecks:off 13 | --floatChecks:off 14 | --nanChecks:off 15 | --infChecks:off 16 | --debuginfo:off 17 | --opt:speed 18 | --hotCodeReloading:off 19 | --tlsEmulation:off 20 | --trmacros:off 21 | --assertions:off 22 | --checks:off 23 | --implicitStatic:off 24 | --multimethods:off 25 | --stackTrace:off 26 | --lineTrace:off 27 | --threads:off 28 | --passC:"-Ofast -flto=auto -funroll-loops -pipe -static" 29 | -------------------------------------------------------------------------------- /src/nitches/getDistro.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/parsecfg 3 | 4 | proc getDistro*(): string = 5 | result = "/etc/os-release".loadConfig.getSectionValue("", "PRETTY_NAME") 6 | -------------------------------------------------------------------------------- /src/nitches/getHostname.nim: -------------------------------------------------------------------------------- 1 | import std/os 2 | import std/parsecfg 3 | 4 | proc getHostname*(): string = 5 | let hostname = "/etc/hostname" 6 | let hostnameOpenrc = "/etc/conf.d/hostname" 7 | if hostname.fileExists(): 8 | result = hostname.open.readLine 9 | elif hostnameOpenrc.fileExists(): 10 | result = hostnameOpenrc.loadConfig.getSectionValue("", "hostname") 11 | else: 12 | result = "" 13 | -------------------------------------------------------------------------------- /src/nitches/getKernel.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/strutils 3 | 4 | proc getKernel*(): string = 5 | result = "/proc/version".open.readLine.split(" ")[2] 6 | -------------------------------------------------------------------------------- /src/nitches/getLogo.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/terminal, 3 | ../assets/logos 4 | 5 | func getLogo*(distroId: string): tuple = 6 | const 7 | coloredLogos: array[16, tuple] = [ 8 | (fgRed, nitchLogo), 9 | (fgBlue, archLogo), 10 | (fgRed, ubuntuLogo), 11 | (fgRed, debianLogo), 12 | (fgBlue, fedoraLogo), 13 | (fgGreen, mintLogo), 14 | (fgBlue, zorinLogo), 15 | (fgCyan, poposLogo), 16 | (fgGreen, manjaroLogo), 17 | (fgGreen, opensuseLogo), 18 | (fgBlue, slackwareLogo), 19 | (fgYellow, centosLogo), 20 | (fgRed, redhatLogo), 21 | (fgMagenta, gentooLogo), 22 | (fgMagenta, endeavourosLogo), 23 | (fgBlue, artixLogo) 24 | ] 25 | 26 | case distroId: 27 | of "arch": 28 | result = coloredLogos[1] 29 | 30 | of "ubuntu": 31 | result = coloredLogos[2] 32 | 33 | of "debian": 34 | result = coloredLogos[3] 35 | 36 | of "fedora": 37 | result = coloredLogos[4] 38 | 39 | of "linuxmint": 40 | result = coloredLogos[5] 41 | 42 | of "Zorin OS": 43 | result = coloredLogos[6] 44 | 45 | of "pop": 46 | result = coloredLogos[7] 47 | 48 | of "manjaro": 49 | result = coloredLogos[8] 50 | 51 | of "opensuse": 52 | result = coloredLogos[9] 53 | 54 | of "slackware": 55 | result = coloredLogos[10] 56 | 57 | of "centos": 58 | result = coloredLogos[11] 59 | 60 | of "redhat": 61 | result = coloredLogos[12] 62 | 63 | of "gentoo": 64 | result = coloredLogos[13] 65 | 66 | of "endeavouros": 67 | result = coloredLogos[14] 68 | 69 | of "artix": 70 | result = coloredLogos[15] 71 | 72 | else: 73 | result = coloredLogos[0] 74 | -------------------------------------------------------------------------------- /src/nitches/getPkgs.nim: -------------------------------------------------------------------------------- 1 | import 2 | ../funcs/packages/[getPacmanPkgs, getRpmPkgs, 3 | getPortagePkgs, getXbpsPkgs, 4 | getDpkgPkgs] 5 | 6 | proc getPkgs*(distroId: string): string = 7 | case distroId: 8 | of "arch": 9 | result = getPacmanPkgs() 10 | 11 | of "artix": 12 | result = getPacmanPkgs() 13 | 14 | of "archcraft": 15 | result = getPacmanPkgs() 16 | 17 | of "manjaro": 18 | result = getPacmanPkgs() 19 | 20 | of "endeavouros": 21 | result = getPacmanPkgs() 22 | 23 | of "garuda": 24 | result = getPacmanPkgs() 25 | 26 | of "fedora": 27 | result = getRpmPkgs() 28 | 29 | of "gentoo": 30 | result = getPortagePkgs() 31 | 32 | of "void": 33 | result = getXbpsPkgs() 34 | 35 | of "ubuntu": 36 | result = getDpkgPkgs() 37 | 38 | of "debian": 39 | result = getDpkgPkgs() 40 | 41 | of "pop": 42 | result = getDpkgPkgs() 43 | 44 | else: 45 | result = ">3" 46 | -------------------------------------------------------------------------------- /src/nitches/getRam.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/strutils 3 | 4 | proc getRam*(): string = 5 | let 6 | fileSeq: seq[string] = "/proc/meminfo".readLines(3) 7 | 8 | let 9 | memTotalString = fileSeq[0].split(" ")[^2] 10 | memAvailableString = fileSeq[2].split(" ")[^2] 11 | 12 | memTotalInt = memTotalString.parseUInt div 1024 13 | memAvailableInt = memAvailableString.parseUInt div 1024 14 | 15 | memUsedInt = memTotalInt - memAvailableInt 16 | 17 | result = $(memUsedInt) & " | " & $(memTotalInt) & " MiB" 18 | 19 | 20 | proc getRam_MB*(): string = 21 | let 22 | fileSeq: seq[string] = "/proc/meminfo".readLines(3) 23 | 24 | let 25 | memTotalString = fileSeq[0].split(" ")[^2] 26 | memAvailableString = fileSeq[2].split(" ")[^2] 27 | 28 | memTotalInt = memTotalString.parseUInt div 1000 29 | memAvailableInt = memAvailableString.parseUInt div 1000 30 | 31 | memUsedInt = memTotalInt - memAvailableInt 32 | 33 | result = $(memUsedInt) & " | " & $(memTotalInt) & " MB" 34 | -------------------------------------------------------------------------------- /src/nitches/getShell.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/[strutils, os] 3 | 4 | func getShell*(): string = 5 | result = getEnv("SHELL").split("/")[^1] 6 | -------------------------------------------------------------------------------- /src/nitches/getUptime.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/strutils 3 | 4 | proc getUptime*(): string = 5 | let 6 | uptimeString = "/proc/uptime".open.readLine.split(".")[0] 7 | uptimeUint = uptimeString.parseUInt 8 | 9 | uptimeHours = uptimeUint div 3600 mod 24 10 | uptimeMinutes = uptimeUint mod 3600 div 60 11 | uptimeDays = uptimeUint div 3600 div 24 12 | 13 | if uptimeDays == 0: 14 | result = $(uptimeHours) & "h " & $(uptimeMinutes) & "m" 15 | 16 | elif uptimeHours == 0 and uptimeDays == 0: 17 | result = $(uptimeMinutes) & "m" 18 | 19 | else: 20 | result = $(uptimeDays) & "d " & $(uptimeHours) & "h " & $(uptimeMinutes) & "m" 21 | -------------------------------------------------------------------------------- /src/nitches/getUser.nim: -------------------------------------------------------------------------------- 1 | import 2 | std/os 3 | 4 | func getUser*(): string = 5 | result = getEnv("USER") 6 | -------------------------------------------------------------------------------- /templates/bfetch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | RESTORE=$(echo -en '\033[0m') 4 | RED=$(echo -en '\033[00;31m') 5 | GREEN=$(echo -en '\033[00;32m') 6 | YELLOW=$(echo -en '\033[00;33m') 7 | BLUE=$(echo -en '\033[00;34m') 8 | MAGENTA=$(echo -en '\033[00;35m') 9 | PURPLE=$(echo -en '\033[00;35m') 10 | CYAN=$(echo -en '\033[00;36m') 11 | LIGHTGRAY=$(echo -en '\033[00;37m') 12 | LRED=$(echo -en '\033[01;31m') 13 | LGREEN=$(echo -en '\033[01;32m') 14 | LYELLOW=$(echo -en '\033[01;33m') 15 | LBLUE=$(echo -en '\033[01;34m') 16 | LMAGENTA=$(echo -en '\033[01;35m') 17 | LPURPLE=$(echo -en '\033[01;35m') 18 | LCYAN=$(echo -en '\033[01;36m') 19 | WHITE=$(echo -en '\033[01;37m') 20 | ORANGE=$(echo -en '\033[01;33m') 21 | DARK=$(echo -en '\033[01;30m') 22 | 23 | OS=`cat /etc/os-release | grep PRETTY_NAME | sed 's/\"//g' | sed 's/.*=//g'` 24 | KERNEL=`uname -r` 25 | RAM=$(echo "$((`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`/1024))") 26 | RAM_USED=$(echo $((`cat /proc/meminfo | grep MemAvailable | awk '{print $2}'`/1024))) 27 | RAM_USED=$(echo $((RAM-RAM_USED))) 28 | UPTIME=`echo $(uptime | awk '{print $3}' | sed 's/,//g' | sed 's/\:/h /g')m` 29 | HOSTNAME=`cat /etc/hostname` 30 | USERNAME=`whoami` 31 | 32 | echo "" 33 | echo -e "${BLUE}┏━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓" 34 | echo -e "${BLUE}┃${RESTORE} .${ORANGE}~${RESTORE}. ${BLUE}┃ ${BLUE}$HOSTNAME${RESTORE}@${BLUE}$USERNAME""\t\t"${BLUE}┃ 35 | echo -e "${BLUE}┃${RESTORE} ${DARK}/${ORANGE}V${RESTORE}${DARK}\ ${BLUE}┃ ${PURPLE}os${RESTORE}\t\t$OS""\t"${BLUE}┃ 36 | echo -e "${BLUE}┃${RESTORE} ${DARK}/${WHITE}/ \\\\${DARK}\ ${BLUE}┃ ${PURPLE}uptime${RESTORE}\t$UPTIME""\t\t"${BLUE}┃ 37 | echo -e "${BLUE}┃${RESTORE} ${DARK}/${WHITE}( )${DARK}\ ${BLUE}┃ ${PURPLE}kernel${RESTORE}\t$KERNEL""\t"${BLUE}┃ 38 | echo -e "${BLUE}┃${RESTORE} ${DARK}^${WHITE}\`${ORANGE}~${WHITE}'${DARK}^ ${BLUE}┃ ${PURPLE}ram${RESTORE}\t""$RAM_USED"M / "$RAM"M"\t"${BLUE}┃ 39 | echo -e "${BLUE}┗━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛" 40 | echo "" 41 | -------------------------------------------------------------------------------- /templates/cfgParser.nim: -------------------------------------------------------------------------------- 1 | import std/parsecfg 2 | 3 | let 4 | cfg: Config = loadConfig("test.cfg") 5 | 6 | first: string = cfg.getSectionValue("", "first") 7 | second: string = cfg.getSectionValue("", "second") 8 | third: string = cfg.getSectionValue("", "third") 9 | 10 | 11 | echo first 12 | echo second 13 | echo third 14 | -------------------------------------------------------------------------------- /templates/colorTest.nim: -------------------------------------------------------------------------------- 1 | echo """ 2 | _ ___ ______ __ 3 | / |/ (_)_ __/___/ / 4 | / / / / / / __/ _ \ 5 | /_/|_/_/ /_/ \__/_//_/ 6 | 7 |  ╭───────────╮ 8 |  │   user │ ssleert 9 |  │   hname │ sfome 10 |  │ 󰻀  distro │ Arch Linux 11 |  │ 󰌢  kernel │ 5.18.5-1-clear 12 |  │   uptime │ 25.61h 13 |  │   shell │ /bin/fish 14 |  │   term │ vscode 15 |  │ 󰏖  pkgs │ 459 16 |  │ 󰍛  memory │ 8378 | 15890mb 17 |  ╰───────────╯ 18 | """ 19 | -------------------------------------------------------------------------------- /templates/data.dat: -------------------------------------------------------------------------------- 1 | │┌ ┐┘─┐ └│┘└ ┌─ ├ ┤ ┴ ┬ 2 | │╭ ╮╯─╮ ╰│╯╰ ╭─ ├ ┤ ┴ ┬ 3 | 4 | no flags 5 | or 6 | -f --fetch 7 | _ ___ ______ __ 8 | / |/ (_)_ __/___/ / 9 | / / / / / / __/ _ \ 10 | /_/|_/_/ /_/ \__/_//_/ 11 | 12 | ╭───────────╮ 13 | │  user │ ssleert 14 | │  hname │ sfome 15 | │ 󰻀 distro │ Arch Linux 16 | │ 󰌢 kernel │ 5.15.1 17 | │  uptime │ 24h 46m 18 | │  shell │ fish 19 | │ 󰏖 pkgs │ 1241 20 | │ 󰍛 memory │ 1605 | 16384m 21 | ╰───────────╯ 22 | 23 | 24 | -h --help 25 | 26 | nitch - incredibly fast system fetch written in nim 27 | 28 | -f --fetch | return fetch about system 29 | -h --help | return help message 30 | -v --version | return version of program 31 | 32 | 33 | -v --version 34 | nitch - 0.1.0 35 | -------------------------------------------------------------------------------- /templates/echo.sh: -------------------------------------------------------------------------------- 1 | echo "Hello World!" 2 | -------------------------------------------------------------------------------- /templates/listFiles.nim: -------------------------------------------------------------------------------- 1 | import std/os 2 | import std/sequtils 3 | 4 | proc listFiles(dir: string) = 5 | let 6 | filesInPath: seq[tuple] = toSeq(walkDir(dir, relative = true)) 7 | 8 | let 9 | asd: int = filesInPath.len - 1 10 | 11 | listFiles("/var/lib/pacman/local") 12 | -------------------------------------------------------------------------------- /templates/readLine.nim: -------------------------------------------------------------------------------- 1 | import std/strutils 2 | import std/strformat 3 | 4 | proc readLine(): string = 5 | let 6 | fileSeq: seq[string] = readLines("/proc/meminfo", 3) 7 | 8 | let 9 | memTotalSeq: seq[string] = fileSeq[0].split(" ") 10 | memAvailableSeq: seq[string] = fileSeq[2].split(" ") 11 | 12 | memTotalInt: int = parseInt(memTotalSeq[^2]) div 1024 13 | memAvailableInt: int = parseInt(memAvailableSeq[^2]) div 1024 14 | 15 | memUsedInt: int = memTotalInt - memAvailableInt 16 | 17 | return fmt"{memUsedInt} | {memTotalInt}mb" 18 | 19 | echo readLine() 20 | -------------------------------------------------------------------------------- /templates/refTest.nim: -------------------------------------------------------------------------------- 1 | let 2 | asd: ref = new(string) 3 | asd_ref: ref = asd 4 | asd_ref_ref: ref = asd_ref 5 | asd_ref_ref_ref: ref = asd_ref_ref 6 | asd_ref_ref_ref_ref: ref = asd_ref_ref_ref 7 | 8 | asd_ref_ref_ref_ref[] = "Hello, World!" 9 | 10 | echo asd_ref_ref_ref_ref.repr 11 | echo "" 12 | echo asd.repr 13 | 14 | -------------------------------------------------------------------------------- /templates/rxfetch: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | #colors 4 | #bold="(tput bold)" 5 | magenta="\033[1;35m" 6 | green="\033[1;32m" 7 | white="\033[1;37m" 8 | blue="\033[1;34m" 9 | red="\033[1;31m" 10 | black="\033[1;40;30m" 11 | yellow="\033[1;33m" 12 | cyan="\033[1;36m" 13 | reset="\033[0m" 14 | bgyellow="\033[1;43;33m" 15 | bgwhite="\033[1;47;37m" 16 | c0=${reset} 17 | c1=${magenta} 18 | c2=${green} 19 | c3=${white} 20 | c4=${blue} 21 | c5=${red} 22 | c6=${yellow} 23 | c7=${cyan} 24 | c8=${black} 25 | c9=${bgyellow} 26 | c10=${bgwhite} 27 | 28 | # Setup fonts 29 | setup_fonts() { 30 | os=$(uname -o) 31 | 32 | if [ "$os" != Android ]; then 33 | if ! fc-match :family='Material' | grep -Eq '^Material.ttf'; then 34 | mkdir -p "$HOME/.local/share/fonts" 35 | cp ttf-material-design-icons/* "$HOME/.local/share/fonts" 36 | fc-cache -vf &>/dev/null 37 | fi 38 | fi 39 | } 40 | 41 | # Get the init 42 | get_init() { 43 | os=$(uname -o) 44 | if [ "$os" = "Android" ]; then 45 | echo 'init.rc' 46 | elif pidof -q systemd; then 47 | echo 'systemd' 48 | elif [ -f '/sbin/openrc' ]; then 49 | echo 'openrc' 50 | else 51 | cut -d ' ' -f 1 /proc/1/comm 52 | fi 53 | } 54 | 55 | # Get count of packages installed 56 | get_pkg_count() { 57 | package_managers=('xbps-install' 'apk' 'apt' 'pacman' 'nix' 'dnf' 'rpm' 'emerge') 58 | for package_manager in "${package_managers[@]}"; do 59 | if command -v "$package_manager" 2>/dev/null >&2; then 60 | case "$package_manager" in 61 | xbps-install) xbps-query -l | wc -l ;; 62 | apk) apk search | wc -l ;; 63 | apt) echo $(($(apt list --installed 2>/dev/null | wc -l) - 1)) ;; 64 | pacman) pacman -Q | wc -l ;; 65 | nix) nix-env -qa --installed '*' | wc -l ;; 66 | dnf) dnf list installed | wc -l ;; 67 | rpm) rpm -qa | wc -l ;; 68 | emerge) qlist -I | wc -l ;; 69 | esac 70 | 71 | # if a package manager is found return from the function 72 | return 73 | fi 74 | done 75 | echo 0 76 | } 77 | 78 | # Get count of snaps installed 79 | get_snap_count() { 80 | if command -v snap 2>/dev/null >&2; then 81 | count=$(snap list | wc -l) 82 | 83 | # snap list shows a header line 84 | echo $((count - 1)) 85 | 86 | return 87 | fi 88 | 89 | echo 0 90 | } 91 | 92 | # Get count of flatpaks installed 93 | get_flatpak_count() { 94 | if command -v flatpak 2>/dev/null >&2; then 95 | flatpak list | wc -l 96 | return 97 | fi 98 | 99 | echo 0 100 | } 101 | 102 | # Get package information formatted 103 | get_package_info() { 104 | pkg_count=$(get_pkg_count) 105 | snap_count=$(get_snap_count) 106 | flatpak_count=$(get_flatpak_count) 107 | 108 | if [ "$pkg_count" -ne 0 ]; then 109 | echo -n "$pkg_count" 110 | if [ "$snap_count" -ne 0 ]; then 111 | echo -n " ($snap_count snaps" 112 | if [ "$flatpak_count" -ne 0 ]; then 113 | echo ", $flatpak_count flatpaks)" 114 | else 115 | echo ")" 116 | fi 117 | elif [ "$flatpak_count" -ne 0 ]; then 118 | echo " ($flatpak_count flatpaks)" 119 | else 120 | echo "" 121 | fi 122 | elif [ "$snap_count" -ne 0 ]; then 123 | echo -n "$snap_count snaps" 124 | 125 | if [ "$flatpak_count" -ne 0 ]; then 126 | echo ", $flatpak_count flatpaks" 127 | else 128 | echo "" 129 | fi 130 | elif [ "$flatpak_count" -ne 0 ]; then 131 | echo "$flatpak_count flatpaks" 132 | else 133 | echo "Unknown" 134 | fi 135 | } 136 | 137 | # Get distro name 138 | get_distro_name() { 139 | os=$(uname -o) 140 | if [ "$os" = "Android" ]; then 141 | echo 'Android' 142 | else 143 | awk -F '"' '/PRETTY_NAME/ { print $2 }' /etc/os-release 144 | fi 145 | } 146 | 147 | # Get root partition space used 148 | get_storage_info() { 149 | if [ "$os" = Android ]; then 150 | _MOUNTED_ON="/data" 151 | _GREP_ONE_ROW="$(df -h | grep ${_MOUNTED_ON})" 152 | _SIZE="$(echo "${_GREP_ONE_ROW}" | awk '{print $2}')" 153 | _USED="$(echo "${_GREP_ONE_ROW}" | awk '{print $3}')" 154 | echo "$(head -n1 <<<"${_USED}")B / $(head -n1 <<<"${_SIZE}")B" 155 | else 156 | df -h --output=used,size / | awk 'NR == 2 { print $1" / "$2 }' 157 | fi 158 | } 159 | 160 | # Get Memory usage 161 | get_mem() { 162 | free --mega | awk 'NR == 2 { print $3" / "$2" MB" }' 163 | } 164 | 165 | # Get uptime 166 | get_uptime() { 167 | uptime -p | sed 's/up//' 168 | } 169 | 170 | # Get DE/WM 171 | # Reference: https://github.com/unixporn/robbb/blob/master/fetcher.sh 172 | get_de_wm() { 173 | wm="${XDG_CURRENT_DESKTOP#*:}" 174 | [ "$wm" ] || wm="$DESKTOP_SESSION" 175 | 176 | # for most WMs 177 | [ ! "$wm" ] && [ "$DISPLAY" ] && command -v xprop >/dev/null && { 178 | id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK 2>/dev/null) 179 | id=${id##* } 180 | wm=$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t 2>/dev/null | grep '^_NET_WM_NAME' | cut -d\" -f 2) 181 | } 182 | 183 | # for non-EWMH WMs 184 | [ ! "$wm" ] || [ "$wm" = "LG3D" ] && 185 | wm=$(pgrep -m 1 -o \ 186 | -e "sway" \ 187 | -e "kiwmi" \ 188 | -e "wayfire" \ 189 | -e "sowm" \ 190 | -e "catwm" \ 191 | -e "fvwm" \ 192 | -e "dwm" \ 193 | -e "2bwm" \ 194 | -e "monsterwm" \ 195 | -e "tinywm" \ 196 | -e "xmonad") 197 | 198 | echo "${wm:-unknown}" 199 | } 200 | 201 | setup_fonts 202 | 203 | echo " " 204 | 205 | if [ "$os" = Android ]; then 206 | echo -e " ${c5}phone${c3} $(getprop ro.product.brand) $(getprop ro.product.model)" 207 | fi 208 | 209 | echo -e " ${c1}os${c3} $(get_distro_name) $(uname -m)" 210 | echo -e " ${c2}ker${c3} $(uname -r)" 211 | echo -e " ${c3}•${c8}_${c3}•${c0} ${c7}pkgs${c3} $(get_package_info)" 212 | echo -e " ${c8}${c0}${c9}oo${c0}${c8}|${c0} ${c4}sh${c3} ${SHELL##*/}" 213 | echo -e " ${c8}/${c0}${c10} ${c0}${c8}'\'${c0} ${c6}ram${c3} $(get_mem)" 214 | echo -e " ${c9}(${c0}${c8}\_;/${c0}${c9})${c0} ${c1}init${c3} $(get_init)" 215 | 216 | if [ -n "$DISPLAY" ]; then 217 | echo -e " ${c2}de/wm${c3} $(get_de_wm)" 218 | fi 219 | 220 | echo -e " ${c7}up${c3} $(get_uptime)" 221 | echo -e " ${c6}disk${c3} $(get_storage_info)" 222 | echo -e " " 223 | 224 | if [ "$os" != Android ]; then 225 | echo -e " ${c6}󰮯 ${c6}${c2}󰊠 ${c2}${c4}󰊠 ${c4}${c5}󰊠 ${c5}${c7}󰊠 ${c7}" 226 | fi 227 | 228 | echo -e " \033[0m" 229 | -------------------------------------------------------------------------------- /templates/shellCheck.nim: -------------------------------------------------------------------------------- 1 | import std/osproc 2 | 3 | stdout.write(execProcess("ls -lah")) 4 | -------------------------------------------------------------------------------- /templates/slice.nim: -------------------------------------------------------------------------------- 1 | const 2 | asd: string = "1234567890" 3 | 4 | 5 | echo asd[0 .. ^3] -------------------------------------------------------------------------------- /templates/test.cfg: -------------------------------------------------------------------------------- 1 | first="sfome first" 2 | second="sfome second" 3 | third="sfome third" 4 | -------------------------------------------------------------------------------- /templates/testCounter.nim: -------------------------------------------------------------------------------- 1 | import std/[strutils, osproc] 2 | 3 | proc getPacmanPkgs(): int = 4 | let 5 | count: string = osproc.execCmdEx("pacman -Qq")[0] 6 | 7 | result = count.split("\n").len - 1 8 | 9 | echo getPacmanPkgs() -------------------------------------------------------------------------------- /templates/testFile: -------------------------------------------------------------------------------- 1 | first line 2 | second line 3 | third line -------------------------------------------------------------------------------- /templates/testProc.nim: -------------------------------------------------------------------------------- 1 | proc testResult(asd: string): string = 2 | result = asd 3 | 4 | echo testResult("asd") 5 | -------------------------------------------------------------------------------- /templates/tupleTest.nim: -------------------------------------------------------------------------------- 1 | const 2 | asd: tuple = ("asd", 2, 's') 3 | 4 | 5 | echo asd[0] 6 | echo asd[1] 7 | echo asd[2] --------------------------------------------------------------------------------