diff --git a/.gitignore b/.gitignore index e972a4b..760e2c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,56 @@ paleofetch + +# create by https://github.com/iamcco/coc-gitignore (Fri Jun 04 2021 13:56:04 GMT-0500 (hora estándar de Perú)) +# CMake.gitignore: +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +# CMake.patch: +# External projects +*-prefix/ + +# create by https://github.com/iamcco/coc-gitignore (Fri Jun 04 2021 13:56:12 GMT-0500 (hora estándar de Perú)) +# C++.gitignore: +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a438107 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,66 @@ +cmake_minimum_required(VERSION 3.16.0) + +project(paleofetch + VERSION 0.0.0 + DESCRIPTION "Neofetch, but written in C" + HOMEPAGE_URL "https://github.com/JaGoLi/paleofetch" +) + +# Without this, paths are not relative in the sources list +cmake_policy(SET CMP0076 NEW) + +include(GNUInstallDirs) +include(FindPkgConfig) + +# The program itself +add_executable(${PROJECT_NAME}) + +# Distro logo +set(DISTRO_LOGO "arch" CACHE STRING "The logo that will be displayed.") + +add_subdirectory(src) # Sources list + +# Shared libraries +pkg_check_modules(libs + REQUIRED IMPORTED_TARGET + libpci + x11 +) + +# Linking +target_link_libraries(${PROJECT_NAME} + PRIVATE + PkgConfig::libs +) + +# Battery directory +execute_process(COMMAND + find + -L + /sys/class/power_supply/ + -maxdepth 1 + -iname "bat*" + -print0 + + OUTPUT_VARIABLE BATTERY_DIRECTORY +) + +target_compile_definitions(${PROJECT_NAME} + PRIVATE + "BATTERY_DIRECTORY=\"${BATTERY_DIRECTORY}\"" +) + +# Default flags +if(UNIX) + if(NOT (DEFINED ENV{CFLAGS} OR CMAKE_C_FLAGS)) + set(CMAKE_C_FLAGS "-Wall -Wextra -g") + endif() + if(NOT (DEFINED ENV{CXXFLAGS} OR CMAKE_CXX_FLAGS)) + set(CMAKE_CXX_FLAGS "-Wall -Wextra -g") + endif() +endif() + +# Install target +install(TARGETS ${PROJECT_NAME} + DESTINATION ${CMAKE_INSTALL_BINDIR} +) diff --git a/Makefile b/Makefile deleted file mode 100644 index 0f79ef1..0000000 --- a/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -CFLAGS=-O2 -Wall -Wextra -lX11 -lpci -PREFIX=$(HOME)/.local -CACHE=$(shell if [ "$$XDG_CACHE_HOME" ]; then echo "$$XDG_CACHE_HOME"; else echo "$$HOME"/.cache; fi) - -all: paleofetch - -clean: - rm -f paleofetch $(CACHE)/paleofetch - -paleofetch: paleofetch.c paleofetch.h config.h - $(eval battery_path := $(shell ./config_scripts/battery_config.sh)) - $(CC) paleofetch.c -o paleofetch $(CFLAGS) -D $(battery_path) - strip paleofetch - -install: paleofetch - mkdir -p $(PREFIX)/bin - install ./paleofetch $(PREFIX)/bin/paleofetch diff --git a/config_scripts/battery_config.sh b/config_scripts/battery_config.sh deleted file mode 100755 index 0a49740..0000000 --- a/config_scripts/battery_config.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -BATTERY_DIRECTORY=`ls /sys/class/power_supply | grep -i "^bat" | head -n 1` - -echo "BATTERY_DIRECTORY='\"/sys/class/power_supply/$BATTERY_DIRECTORY\"'" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..43ba880 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,12 @@ +target_sources(${PROJECT_NAME} + PRIVATE + paleofetch.c +) + +# Fill @DISTRO_LOGO@ +configure_file(config.h.in config.h @ONLY) +target_include_directories(${PROJECT_NAME} + PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}" + "${CMAKE_CURRENT_SOURCE_DIR}" +) diff --git a/config.h b/src/config.h.in similarity index 97% rename from config.h rename to src/config.h.in index a4bd4af..eb032c4 100644 --- a/config.h +++ b/src/config.h.in @@ -1,4 +1,7 @@ -#include "logos/arch.h" +#pragma once + +#include "logos/@DISTRO_LOGO@.h" + //define colors #define BLACK "\e[1;30m" #define RED "\e[1;31m" diff --git a/logos/arch.h b/src/logos/arch.h similarity index 100% rename from logos/arch.h rename to src/logos/arch.h diff --git a/logos/artix.h b/src/logos/artix.h similarity index 100% rename from logos/artix.h rename to src/logos/artix.h diff --git a/logos/debian.h b/src/logos/debian.h similarity index 100% rename from logos/debian.h rename to src/logos/debian.h diff --git a/logos/fedora.h b/src/logos/fedora.h similarity index 100% rename from logos/fedora.h rename to src/logos/fedora.h diff --git a/logos/gentoo.h b/src/logos/gentoo.h similarity index 100% rename from logos/gentoo.h rename to src/logos/gentoo.h diff --git a/logos/manjaro.h b/src/logos/manjaro.h similarity index 100% rename from logos/manjaro.h rename to src/logos/manjaro.h diff --git a/logos/ubuntu.h b/src/logos/ubuntu.h similarity index 100% rename from logos/ubuntu.h rename to src/logos/ubuntu.h diff --git a/paleofetch.c b/src/paleofetch.c similarity index 100% rename from paleofetch.c rename to src/paleofetch.c diff --git a/paleofetch.h b/src/paleofetch.h similarity index 98% rename from paleofetch.h rename to src/paleofetch.h index 0e4578f..c9053d6 100644 --- a/paleofetch.h +++ b/src/paleofetch.h @@ -1,6 +1,8 @@ /* Forward-declare our functions so users can mention them in their * configs at the top of the file rather than near the bottom. */ +#pragma once + static char *get_title(), *get_bar(), *get_os(),