Initial commit
This commit is contained in:
commit
4ed8808e57
19
LICENSE
Normal file
19
LICENSE
Normal file
|
@ -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.
|
12
Makefile
Normal file
12
Makefile
Normal file
|
@ -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
|
33
README.org
Normal file
33
README.org
Normal file
|
@ -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
|
78
fetchy.c
Normal file
78
fetchy.c
Normal file
|
@ -0,0 +1,78 @@
|
|||
#include <stdio.h>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
BIN
screenshot.png
Normal file
BIN
screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
Loading…
Reference in a new issue