Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ configure
i3blocks-config.h*
stamp-h1

build/*
.cache/*
AGENTS.md
CLAUDE.md
16 changes: 16 additions & 0 deletions .nvim.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local function save_and_run()
vim.cmd([[wa]])
vim.cmd([[belowright split]])
vim.cmd([[resize -4]])
vim.cmd([[terminal cmake -S . -B ./build && cmake --build build && ./build/i3blocks]])
end

local function save_and_debug()
vim.cmd([[wa]])
vim.cmd([[terminal cmake -S . -B ./build && cmake --build build]])
vim.cmd([[terminal cmake -S . -B ./build && cmake --build build && gdb -q ./build/i3blocks]])
end

local opts = { noremap = true, silent = true }
vim.keymap.set("n", "<C-R>", save_and_run, opts)
vim.keymap.set("n", "<F5>", save_and_debug, opts)
89 changes: 89 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
cmake_minimum_required(VERSION 3.16)

project(i3blocks)
enable_language(C ASM)
include(GNUInstallDirs)
###############################################################################
## file globbing ##############################################################
###############################################################################

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# set(CMAKE_C_COMPILER clang)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")

set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp")

if(CMAKE_BUILD_TYPE MATCHES Debug)
message("Debug build.")
elseif(CMAKE_BUILD_TYPE MATCHES Release)
message("Release build.")
else()
message("Some other build type. Setting up default = Release")
set(CMAKE_BUILD_TYPE Release)
endif()

file(GLOB_RECURSE sources src/*.c src/*.s inc/*.h)
file(GLOB_RECURSE sources_test tests/*.c)
file(GLOB_RECURSE data resources/*)

option(ENABLE_BASH_COMPLETION "Install bash completion for i3blocks" ON)
# Default path similar to many distros:
set(BASH_COMPLETION_DIR
"${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions"
CACHE PATH "Directory for bash-completion files")

###############################################################################
## target definitions #########################################################
###############################################################################

set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "1.5.01")

add_compile_definitions(
PACKAGE_NAME="${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}"
PACKAGE_VERSION="${CPACK_PACKAGE_VERSION}"
SYSCONFDIR=\"${CMAKE_INSTALL_FULL_SYSCONFDIR}\"
)

add_executable(${PROJECT_NAME} ${sources} ${data})
target_include_directories(${PROJECT_NAME} PRIVATE inc)

set(warning_level -Wall -Wextra -pedantic)
target_compile_options(${PROJECT_NAME} PUBLIC ${warning_level} ${sse_flags})

# This copies all resource files in the build directory.
# We need this, because we want to work with paths relative to the executable.
file(COPY ${data} DESTINATION resources)

# All install commands get the same destination. this allows us to use paths
# relative to the executable.
install(TARGETS ${PROJECT_NAME} DESTINATION ${PROJECT_NAME}_destination)

# This is basically a repeat of the file copy instruction that copies the
# resources in the build directory, but here we tell cmake that we want it
# in the package.
install(DIRECTORY resources DESTINATION ${PROJECT_NAME}_destination)

# Manpage: install to share/man/man1
install(FILES docs/i3blocks.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)

# Default config: install to sysconfdir (e.g. /etc)
install(FILES i3blocks.conf
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR})

if(ENABLE_BASH_COMPLETION)
install(FILES bash-completion
DESTINATION "${BASH_COMPLETION_DIR}"
RENAME i3blocks)
endif()

set(CPACK_MONOLITHIC_INSTALL 1)

# This must be last
include(CPack)
46 changes: 24 additions & 22 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,38 +1,40 @@
DEFS += \
-DSYSCONFDIR=\"$(sysconfdir)\"

AM_CPPFLAGS = $(I3BLOCKS_CPPFLAGS)

bin_PROGRAMS = i3blocks
i3blocks_SOURCES = \
bar.c \
bar.h \
block.c \
block.h \
config.c \
config.h \
i3bar.c \
ini.c \
ini.h \
json.c \
json.h \
line.c \
line.h \
log.h \
main.c \
map.c \
map.h \
sys.c \
sys.h \
term.h
src/bar.c \
src/block.c \
src/config.c \
src/i3bar.c \
src/ini.c \
src/json.c \
src/line.c \
src/main.c \
src/map.c \
src/sys.c \
inc/bar.h \
inc/block.h \
inc/config.h \
inc/ini.h \
inc/json.h \
inc/line.h \
inc/log.h \
inc/map.h \
inc/sys.h \
inc/term.h

dist_man1_MANS = \
docs/i3blocks.1

dist_sysconf_DATA = \
i3blocks.conf
data/i3blocks.conf

if ENABLE_BASH_COMPLETION
bashcompletiondir = $(BASH_COMPLETION_DIR)
bashcompletion_DATA = bash-completion
bashcompletion_DATA = data/bash-completion

install-data-local: install-bashcompletionDATA
( cd '$(DESTDIR)$(BASH_COMPLETION_DIR)' && mv bash-completion i3blocks )
Expand Down
2 changes: 2 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#! /bin/sh
set -e
mkdir -p build-aux
autoreconf -fiv
Loading