From 85a70d8a18477d84632d0c1107d33cb2acfa15e7 Mon Sep 17 00:00:00 2001 From: Luis Guilherme Coelho Date: Sun, 11 Feb 2024 13:12:54 -0300 Subject: [PATCH] packages: image-viewers: Add libsixel --- modules/radix/packages/image-viewers.scm | 154 ++++++++++++++++++ .../patches/uerberzug++-cmakelists.patch | 115 +++++++++++++ 2 files changed, 269 insertions(+) create mode 100644 modules/radix/packages/image-viewers.scm create mode 100644 modules/radix/patches/uerberzug++-cmakelists.patch diff --git a/modules/radix/packages/image-viewers.scm b/modules/radix/packages/image-viewers.scm new file mode 100644 index 0000000..87e8ef4 --- /dev/null +++ b/modules/radix/packages/image-viewers.scm @@ -0,0 +1,154 @@ +(define-module (radix packages image-viewers) + #:use-module (gnu packages algebra) + #:use-module (gnu packages cpp) + #:use-module (gnu packages ghostscript) + #:use-module (gnu packages glib) + #:use-module (gnu packages gnome) + #:use-module (gnu packages graphics) + #:use-module (gnu packages gstreamer) + #:use-module (gnu packages gtk) + #:use-module (gnu packages image) + #:use-module (gnu packages image-processing) + #:use-module (gnu packages image-viewers) + #:use-module (gnu packages imagemagick) + #:use-module (gnu packages logging) + #:use-module (gnu packages maths) + #:use-module (gnu packages pdf) + #:use-module (gnu packages photo) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages pretty-print) + #:use-module (gnu packages tbb) + #:use-module (gnu packages tls) + #:use-module (gnu packages xml) + #:use-module (gnu packages xorg) + #:use-module (gnu packages) + #:use-module (guix build-system cmake) + #:use-module (guix build-system gnu) + #:use-module (guix download) + #:use-module (guix gexp) + #:use-module (guix git-download) + #:use-module (guix packages) + #:use-module ((guix licenses) #:prefix license:)) + +(define-public libsixel + (package + (name "libsixel") + (version "1.8.6") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/saitoha/libsixel") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "1saxdj6sldv01g6w6yk8vr7px4bl31xca3a82j6v1j3fw5rbfphy")))) + (build-system gnu-build-system) + (home-page "https://github.com/saitoha/libsixel") + (synopsis "A SIXEL encoder/decoder implementation derived from kmiya's +sixel.") + (description "Libsixel provides encoder/decoder implementation for DEC SIXEL +graphics, and some converter programs.") + (license (list license:expat + (license:non-copyleft "file:///LICENSE.images") + (license:non-copyleft "file:///LICENSE.pngsuite") + (license:non-copyleft "file:///LICENSE.sixel") + (license:non-copyleft "file:///LICENSE.std") + (license:non-copyleft "file:///LICENSE.pnmcolormap") + (license:non-copyleft "file:///LICENSE.mesa"))))) + +;; Currently broken +(define-public ueberzug++ + (package + (name "ueberzug++") + (version "2.9.2") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/jstkdng/ueberzugpp") + (commit (string-append "v" version)))) + (patches (list (local-file "../patches/uerberzug++-cmakelists.patch"))) + (file-name (git-file-name name version)) + (sha256 + (base32 "1ibpyy7ypj4lk837n24ws6dq4aq6crm0kjx0zcnnrdkjjjj232n8")))) + (build-system cmake-build-system) + (arguments + (list #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'absolutize-headers + (lambda _ + (let ((libxcb-file + (lambda (path) + (string-append "\"" #$libxcb path "\""))) + (nlohmann-json-file + (lambda (path) + (string-append "\"" #$nlohmann-json path "\"")))) + (substitute* "src/util/x11.cpp" + (("") (libxcb-file "/include/xcb/res.h"))) + #;(substitute* + (list "src/canvas/wayland/config/hyprland.hpp" + "src/canvas/wayland/config/sway.hpp" + "src/canvas/wayland/config/wayfire.hpp" + "src/util/util.cpp" + "src/application.cpp" + "src/flags.cpp") + (("json/json\\.h") + (nlohmann-json-file "/include/nlohmann/json.hpp"))))))))) + (native-inputs + (list pkg-config + spdlog + gsl + fmt + libxcb + libgsf + orc + fftw + imagemagick + matio + expat + librsvg + lcms + openexr + cairo + pango + libwebp + libexif + imath + poppler + opencv + gobject-introspection + xcb-util-image + cli11 + nlohmann-json)) + (inputs + (list libsixel + vips + chafa + openssl + tbb)) + (home-page "https://github.com/jstkdng/ueberzugpp") + (synopsis "Drop in replacement for ueberzug written in C++.") + (description "Ɯberzug++ is a command line utility written in C++ which +allows to draw images on terminals by using X11/wayland child windows, sixels, +kitty and iterm2.. + +Advantages over w3mimgdisplay and ueberzug: + +@itemize +@item support for wayland: sway, hyprland and wayfire +@item support for MacOS +@item no race conditions as a new window is created to display images +@item expose events will be processed, so images will be redrawn on switch +workspaces +@item tmux support on X11, sway and hyprland +@item terminals without the WINDOWID environment variable are supported +@item chars are used as position - and size unit +@item No memory leak (usage of smart pointers) +@item A lot of image formats supported (through opencv and libvips). +@item GIF and animated WEBP support on X11, Sixel, Sway and hyprland +@item Fast image downscaling (through opencv and opencl) +@item Cache resized images for faster viewing") + (license license:gpl3))) + +ueberzug++ diff --git a/modules/radix/patches/uerberzug++-cmakelists.patch b/modules/radix/patches/uerberzug++-cmakelists.patch new file mode 100644 index 0000000..bda81f7 --- /dev/null +++ b/modules/radix/patches/uerberzug++-cmakelists.patch @@ -0,0 +1,115 @@ +diff --git a/CMakeLists.txt b/home/radio/a +index 92ff7f2..8b9bf6e 100644 +--- a/CMakeLists.txt ++++ b/home/radio/a +@@ -40,7 +40,6 @@ option(ENABLE_OPENCV "Enable OpenCV image processing." ON) + option(ENABLE_TURBOBASE64 "Enable Turbo-Base64 for base64 encoding." OFF) + option(ENABLE_OPENGL "Enable canvas rendering with OpenGL." OFF) + +-include(FetchContent) + include(GNUInstallDirs) + include(CheckCXXSymbolExists) + +@@ -56,55 +55,6 @@ if (HAVE_STD_EXECUTION_H) + target_compile_definitions(ueberzug PRIVATE HAVE_STD_EXECUTION_H) + endif() + +-find_package(Microsoft.GSL CONFIG QUIET) +-if (NOT Microsoft.GSL_FOUND) +- FetchContent_Declare(GSL +- URL https://github.com/microsoft/GSL/archive/refs/tags/v4.0.0.tar.gz +- ) +- list(APPEND FC_LIBS GSL) +-endif() +- +-find_package(CLI11 QUIET) +-if(NOT CLI11_FOUND) +- if (FETCHCONTENT_FULLY_DISCONNECTED) +- add_subdirectory("${CMAKE_SOURCE_DIR}/third_party/CLI11") +- else() +- FetchContent_Declare(cli11 +- URL https://github.com/CLIUtils/CLI11/archive/refs/tags/v2.3.2.tar.gz +- ) +- list(APPEND FC_LIBS cli11) +- endif() +-endif() +- +-find_package(nlohmann_json QUIET) +-if(NOT nlohmann_json_FOUND) +- FetchContent_Declare(nlohmann_json +- URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz +- ) +- list(APPEND FC_LIBS nlohmann_json) +-endif() +- +-find_package(fmt QUIET) +-if(NOT fmt_FOUND) +- FetchContent_Declare(fmt +- URL https://github.com/fmtlib/fmt/archive/refs/tags/10.1.0.tar.gz +- ) +- list(APPEND FC_LIBS fmt) +-endif() +- +-find_package(spdlog QUIET) +-if(NOT spdlog_FOUND) +- set(SPDLOG_FMT_EXTERNAL ON) +- FetchContent_Declare(spdlog +- URL https://github.com/gabime/spdlog/archive/refs/tags/v1.12.0.tar.gz +- ) +- list(APPEND FC_LIBS spdlog) +-endif() +- +-if(FC_LIBS) +- FetchContent_MakeAvailable(${FC_LIBS}) +-endif() +- + if(ENABLE_OPENGL) + target_compile_definitions(ueberzug PRIVATE ENABLE_OPENGL) + find_package(OpenGL REQUIRED) +@@ -196,23 +146,6 @@ if(ENABLE_OPENCV) + ) + endif() + +-if(ENABLE_TURBOBASE64) +- add_compile_definitions(ENABLE_TURBOBASE64) +- find_package(turbobase64 QUIET) +- if (NOT turbobase64_FOUND) +- FetchContent_Declare( +- turbobase64 +- URL https://github.com/powturbo/Turbo-Base64/archive/refs/tags/2023.08.tar.gz +- ) +- FetchContent_Populate(turbobase64) +- add_subdirectory(${turbobase64_SOURCE_DIR} ${turbobase64_BINARY_DIR} EXCLUDE_FROM_ALL) +- list(APPEND UEBERZUG_LIBRARIES base64) +- else() +- add_compile_definitions(WITH_SYSTEM_TURBOBASE64) +- list(APPEND UEBERZUG_LIBRARIES turbo::base64) +- endif() +-endif() +- + set(PROJECT_WARNINGS_CXX + -Wall + -Wextra +@@ -235,22 +168,6 @@ pkg_check_modules(VIPS REQUIRED IMPORTED_TARGET vips-cpp) + pkg_check_modules(SIXEL REQUIRED IMPORTED_TARGET libsixel) + pkg_check_modules(CHAFA REQUIRED IMPORTED_TARGET chafa>=1.6) + +-if (APPLE) +- list(APPEND UEBERZUG_SOURCES src/process/apple.cpp) +- +- find_package(range-v3 QUIET) +- if (NOT range-v3_FOUND) +- FetchContent_Declare(range-v3 +- URL https://github.com/ericniebler/range-v3/archive/refs/tags/0.12.0.tar.gz +- ) +- FetchContent_Populate(range-v3) +- add_subdirectory(${range-v3_SOURCE_DIR} ${range-v3_BINARY_DIR} EXCLUDE_FROM_ALL) +- endif() +- list(APPEND UEBERZUG_LIBRARIES range-v3) +-else() +- list(APPEND UEBERZUG_SOURCES src/process/linux.cpp) +-endif() +- + configure_file("include/version.hpp.in" version.hpp) + configure_file("docs/ueberzugpp.1.in" ueberzugpp.1) +