diff options
author | Shipwreckt <Shipwreckt@mailfence.com> | 2024-07-07 15:05:25 +0100 |
---|---|---|
committer | Shipwreckt <Shipwreckt@mailfence.com> | 2024-07-07 15:05:25 +0100 |
commit | 2768d57c6ecdd3beb7760cbe0b5184893305cc31 (patch) | |
tree | 35d0f2409c1dc0f63fa4ce72ceb906d4a2c7ab3a | |
parent | daa70f17e36d91016328651628a3b1750b154964 (diff) |
Updating it to the C programming language
-rw-r--r-- | README.md | 9 | ||||
-rwxr-xr-x | fakefetch | bin | 10211 -> 15841 bytes | |||
-rw-r--r-- | fakefetch.c | 110 | ||||
-rwxr-xr-x | install.sh | 3 |
4 files changed, 118 insertions, 4 deletions
@@ -1,11 +1,14 @@ +IMPORTANT!!!! +Modify the fakefetch.c yourself to make sure it is how you want it + Fakefetch is just a little command I made that runs in the terminal, it just tells the person some things about there system, it won't do anything like reading your memory or cpu, it just prints an output into your terminal. -Note: This command does change the colour of your input +Note: This command does change the colour of your terminal input, I would suggest using +synth-shell with fakefetch. -Chmod +x setup.sh then ./setup.sh to run it then you should be all good to go -./fakefetch runs the command +webpage: https://shipwreckt.co.uk/projects/programs/Fakefetch.html#info If you want to make your own designes I suggest these tools, I use them to make my ascci art: diff --git a/fakefetch.c b/fakefetch.c new file mode 100644 index 0000000..c801a05 --- /dev/null +++ b/fakefetch.c @@ -0,0 +1,110 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +// __ _ __ _ _ +// / _| | | / _| | | | | +// | |_ __ _| | _____| |_ ___| |_ ___| |__ +// | _/ _` | |/ / _ \ _/ _ \ __/ __| '_ \ +// | || (_| | < __/ || __/ || (__| | | | +// |_| \__,_|_|\_\___|_| \___|\__\___|_| |_| + +// Note: I have tried to make this as user friendly as possable/ + +//----------------------------------------------------------------------------------| +// Welcome to fakefetch | +//----------------------------------------------------------------------------------| +// This is just neofetch but | +// You do it yourself, now in C! | +//----------------------------------------------------------------------------------| +// This is Libre code, you can do whatever you want with it since | +// it is under the GPL | +// ---------------------------------------------------------------------------------| +// Function to execute shell commands and get the output | +// ---------------------------------------------------------------------------------| +char* execute_command(const char* command) { + char* result = malloc(128 * sizeof(char)); + FILE* fp; + if ((fp = popen(command, "r")) == NULL) { + printf("Error opening pipe!\n"); + return NULL; + } + if (fgets(result, 128, fp) == NULL) { + printf("Error reading pipe!\n"); + return NULL; + } + pclose(fp); + + // Remove newline character + result[strcspn(result, "\n")] = '\0'; + return result; +} + +int main() { + // ---------------------------------------------------------------------------------------------------// + // Colour codes + // ---------------------------------------------------------------------------------------------------// + + // Define colours by changing the last two letters to Xterm number + const char* PURPLE = "\033[38;5;92m"; + const char* MAGENTA = "\033[38;5;98m"; + const char* RESET = "\033[0m"; + + // Set colours + const char* Text = MAGENTA; + const char* Background = PURPLE; + + // ---------------------------------------------------------------------------------------------------// + + // Get system information + char* USERNAME = execute_command("whoami"); + char* HOSTNAME = execute_command("uname -n"); + char* DISTRO = execute_command("lsb_release -sd | sed 's/\"//g'"); + char* CPU_INFO = execute_command("lscpu | grep 'Model name' | awk '{$1=$2=\"\"; print $0}' | sed 's/^[ \\t]*//'"); + char* CORES = execute_command("lscpu | grep 'Core(s) per socket' | awk '{print $NF}'"); + char* GPU_INFO = execute_command("lspci | grep -i 'VGA\\|3D' | sed 's/.*: //; s/ (.*//'"); + char* UPTIME = execute_command("uptime -p | sed 's/up //'"); + + // Terminal and package manager + const char* TERMINAL = "Alacritty"; //Still need to work on the terminal bit + char* PACKAGE_MANAGER = execute_command( + "if command -v pacman &> /dev/null; then echo Pacman; " + "elif command -v apt-get &> /dev/null; then echo APT; " + "else echo Unknown; fi" + ); + + // ---------------------------------------------------------------------------------------------------// + // Print output + // ---------------------------------------------------------------------------------------------------// + printf("%s :: %s\n", Background, RESET); + printf("%s .==. %s\n", Background, RESET); + printf("%s ==== %s\n", Background, RESET); + printf("%s -===== %s@%s%s\n", Background, USERNAME, HOSTNAME, RESET); + printf("%s -====== ========================================%s\n", Background, RESET); + printf("%s :========- OS → %s%s%s\n", Background, Text, DISTRO, RESET); + printf("%s :.:-=======- GPU → %s%s%s\n", Background, Text, GPU_INFO, RESET); + printf("%s :==---=======- PM → %s%s%s\n", Background, Text, PACKAGE_MANAGER, RESET); + printf("%s :==============- Term → %s%s%s\n", Background, Text, TERMINAL, RESET); + printf("%s :================- Uptime → %s%s%s\n", Background, Text, UPTIME, RESET); + printf("%s :==================- ========================================%s\n", Background, RESET); + printf("%s :========----========- %s\n", Background, RESET); + printf("%s -========. .========- %s\n", Background, RESET); + printf("%s -======== ========= %s\n", Background, RESET); + printf("%s -========: :======---. %s\n", Background, RESET); + printf("%s -=========: .=======-:. %s\n", Background, RESET); + printf("%s =========--: .--=======-: %s\n", Background, RESET); + printf("%s .=====-:.. ..:-=====%s\n", Background, RESET); + printf("%s .==-:. .:-==:%s\n", Background, RESET); + + // Free up memory + free(USERNAME); + free(HOSTNAME); + free(DISTRO); + free(CPU_INFO); + free(CORES); + free(GPU_INFO); + free(UPTIME); + free(PACKAGE_MANAGER); + + return 0; +} @@ -1,4 +1,5 @@ sudo pacman -S lsb-release #Change if your package manager is diffrent -chmod +x fakefetch + +gcc -o fakefetch fakefetch.c sudo mv fakefetch /bin/fakefetch |