commit 4ed8808e578c9d6941a9cc9dd7d3d6a1c2ca32ae Author: Јован Ђокић-Шумарац Date: Sun Dec 13 02:03:40 2020 +0100 Initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6371659 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright 2020 vojjvoda + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fee07ad --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +all: + gcc fetchy.c -o fetchy + +clean: + rm fetchy + +install: + gcc fetchy.c -o fetchy + mv fetchy /usr/bin/ + +uninstall: + rm /usr/bin/fetchy diff --git a/README.org b/README.org new file mode 100644 index 0000000..efcb64e --- /dev/null +++ b/README.org @@ -0,0 +1,33 @@ +#+TITLE: Fetchy + +* Table of Contents :toc: +- [[#what-is-fetchy][What is fetchy?]] +- [[#install][Install]] + - [[#source][Source]] +- [[#run][Run]] + +* What is fetchy? + +#+CAPTION: fetchy Screenshot +#+ATTR_HTML: :alt fetchy Screenshot :title fetchy Screenshot :align left +[[https://gitlab.com/vojjvoda/fetchy/-/raw/master/screenshot.png]] + +fetchy is a minimal command line system information tool written in C + +It displays the os, kernel, uptime, number of installed packages and shell + +* Install + +** Source + +#+begin_src +git clone https://gitlab.com/vojjvoda/fetchy +cd fetchy +sudo make install +#+end_src + +* Run + +#+begin_src +fetchy +#+end_src diff --git a/fetchy.c b/fetchy.c new file mode 100644 index 0000000..9acaa22 --- /dev/null +++ b/fetchy.c @@ -0,0 +1,78 @@ +#include +int day, hour, min, sec, pacman; +char os[50], kernel[50], shell[25]; + +void getDistro() { + FILE *distroName = popen("cat /etc/*-release | grep 'PRETTY_NAME=' | cut -d '\"' -f2", "r"); + + fscanf(distroName, "%[^\n]%s", &os); + fclose(distroName); +} + +void getKernel() { + FILE *pathKernel = popen("uname -r", "r"); + + fscanf(pathKernel, "%[^\n]%s", &kernel); + fclose(pathKernel); +} + +void getUptime() { + FILE *pathUptime = fopen("/proc/uptime", "r"); + + fscanf(pathUptime, "%d", &sec); + fclose(pathUptime); + + day = (sec/60/60/24); + hour = (sec/60/60%24); + min = (sec/60%60); +} + +void getPackages() { + FILE *pacpackages = popen("pacman -Q | wc -l", "r"); + + fscanf(pacpackages, "%d", &pacman); + fclose(pacpackages); +} + +void getShell() { + FILE *shellpath = popen("echo $SHELL", "r"); + + fscanf(shellpath, "%s", &shell); + fclose(shellpath); +} + +void init() { + getDistro(); + getKernel(); + getUptime(); + getPackages(); + getShell(); +} + +int main() { + init(); + + + printf("\n"); + printf("\x1b[1m . \x1b\n"); + printf("\x1b[1m / \\ \x1b\n"); + printf("\x1b[1m / \\ \x1b[36mOS\x1b[0m: %s\n", os); + printf("\x1b[1m /^. \\ \x1b[36mKERNEL\x1b[0m: %s\n", kernel); + printf("\x1b[1m / .-. \\ \x1b[36mUPTIME\x1b[0m: %dd, %dh, %dm\n", day, hour, min); + printf("\x1b[1m / ( ) _\\ \x1b[36mPACKAGES\x1b[0m: %d (pacman)\n", pacman); + printf("\x1b[1m / _.~ ~._^\\ \x1b[36mSHELL\x1b[0m: %s\n", shell); + printf("\x1b[1m /.^ ^.\\ \x1b\n"); + printf("\n"); + + + return 0; +} + + + + + + + + + diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..ee9abca Binary files /dev/null and b/screenshot.png differ