summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-06-17 11:22:17 -0400
committerAndrew Opalach <andrew@akon.city> 2025-06-17 11:27:55 -0400
commit110be42a7d267647241905936c414a53ad18ddae (patch)
treef73e28f564a78775ab85656acc1e56d020f89474
parent5986c8bf61fc980a9a3383a426479a1296d179e7 (diff)
downloadmauri-110be42a7d267647241905936c414a53ad18ddae.tar.gz
mauri-110be42a7d267647241905936c414a53ad18ddae.tar.bz2
mauri-110be42a7d267647241905936c414a53ad18ddae.zip
Test packaging for debian and arch
Signed-off-by: Andrew Opalach <andrew@akon.city>
-rw-r--r--.gitignore16
-rw-r--r--PKGBUILD52
-rw-r--r--README.txt60
-rw-r--r--debian/changelog5
-rw-r--r--debian/control12
-rw-r--r--debian/copyright15
-rwxr-xr-xdebian/rules3
-rw-r--r--debian/source/format1
-rw-r--r--flake.lock39
-rw-r--r--flake.nix8
-rw-r--r--meson.build70
-rw-r--r--src/mauri.cc13
-rw-r--r--src/texture.cc17
-rw-r--r--subprojects/glm.wrap7
-rw-r--r--subprojects/janus.wrap2
-rw-r--r--subprojects/json.wrap4
-rw-r--r--subprojects/liblz4.wrap (renamed from subprojects/lz4.wrap)7
-rw-r--r--subprojects/libnaunet.wrap2
-rw-r--r--subprojects/nlohmann_json.wrap8
-rw-r--r--subprojects/notcurses.wrap6
-rw-r--r--subprojects/packagefiles/stb/meson.build2
-rw-r--r--subprojects/s3tc-dxt-decompression.wrap2
-rw-r--r--subprojects/stb.wrap4
-rw-r--r--subprojects/stela.wrap2
-rw-r--r--taro/config.h27
-rw-r--r--taro/daemon.c82
-rw-r--r--taro/meson.build5
-rw-r--r--taro/ui.c130
28 files changed, 416 insertions, 185 deletions
diff --git a/.gitignore b/.gitignore
index b6ca06f..14be12e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,29 +1,31 @@
**/build*/
+*.html
.cache/
+attic/test_*
compile_commands.json
result
subprojects/c89atomic-*/
subprojects/c89atomic.wrap
subprojects/glfw3-*/
subprojects/glfw3.wrap
-subprojects/glm/
+subprojects/glm-*/
subprojects/jansson-*/
subprojects/jansson.wrap
-subprojects/janus/
+subprojects/janus-*/
subprojects/jsmn.wrap
subprojects/jsmn/
-subprojects/json/
subprojects/libalabaster
subprojects/libalabaster/
subprojects/libev-4.33/
subprojects/libev.wrap
subprojects/libnaunet
subprojects/libnaunet/
-subprojects/lz4/
-subprojects/notcurses/
+subprojects/lz4-*/
+subprojects/nlohmann_json-*/
+subprojects/notcurses-*/
subprojects/packagecache/
-subprojects/s3tc-dxt-decompression/
-subprojects/stb/
+subprojects/s3tc-dxt-decompression-*/
+subprojects/stb-*/
subprojects/stela
subprojects/stela/
subprojects/wayland-protocols-*/
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 0000000..c5c2914
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,52 @@
+# Maintainer: Andrew Opalach <andrew@akon.city>
+pkgname=mauri
+pkgver=0.14
+pkgrel=1
+epoch=0
+pkgdesc="Wallpaper Engine Implementation"
+arch=('x86_64')
+url="https://git.akon.city/mauri"
+license=('GPL-3.0-only')
+groups=()
+depends=('wayland' 'libx11' 'libxext' 'libxrandr' 'libegl' 'libgl' 'nlohmann-json' 'lz4' 'stb' 'glm' 'jansson' 'ffmpeg' 'libdeflate')
+makedepends=('git' 'meson' 'cmake' 'wayland-protocols' 'wlr-protocols')
+checkdepends=()
+optdepends=()
+provides=()
+conflicts=()
+replaces=()
+backup=()
+options=()
+install=
+changelog=
+source=("https://git.akon.city/mauri/snapshot/mauri-0.14.tar.gz")
+noextract=()
+sha256sums=("7b557bd7626115813a9eb53f0b0ae8831e09405d04fee743f2dac6ee4c2cab9a")
+validpgpkeys=()
+
+prepare() {
+ cd "$pkgname-$pkgver"
+ meson subprojects download libalabaster libnaunet stela janus s3tc-dxt-decompression notcurses
+
+ cd subprojects/libalabaster
+ meson subprojects download c89atomic
+
+ cd ../libnaunet
+ meson subprojects download libev
+}
+
+build() {
+ cd "$pkgname-$pkgver"
+ meson setup build --prefix=/usr \
+ --sysconfdir=/etc \
+ --buildtype=plain \
+ --wrap-mode=nodownload \
+ -Dwindow=x11
+
+ meson compile -C build
+}
+
+package() {
+ cd "$pkgname-$pkgver"
+ meson install -C build --destdir "$pkgdir"
+}
diff --git a/README.txt b/README.txt
index 4993ad0..7a061ec 100644
--- a/README.txt
+++ b/README.txt
@@ -1,23 +1,43 @@
:source-highlighter: pygments
-= mauri: Wallpaper Engine Implementation (for Linux)
-
== Building
=== Dependencies
* C++17 and C99 compiler
* meson
+* cmake
+* libegl
+* libgl
+* nlohmann_json
* lz4
+* stb_image
* glm
-* nlohmann_json
* fftw3 `optional (audio)`
* notcurses `optional (taro)`
* jansson `optional (taro)`
-* libev `optional (taro)`
-debian12: sudo apt install gcc g++ meson ninja-build
+==== X11
+* libx11
+* libxext
+* libxrandr
+
+==== Wayland
+* wayland
+* wayland-egl
+* wayland-protocols
+* wlr-protocols
+
+debian12: +
+{nbsp} common: `sudo apt install git meson cmake pkg-config libegl-dev nlohmann-json3-dev liblz4-dev libstb-dev libglm-dev libjansson-dev libavcodec-dev libavdevice-dev libunistring-dev libdeflate-dev libtinfo-dev` +
+{nbsp} wayland: `sudo apt install libwayland-dev` +
+{nbsp} x11: `sudo apt install libxext-dev libxrandr-dev` +
+
+archlinux: +
+{nbsp} common: `sudo pacman -S --needed git meson cmake libegl nlohmann-json lz4 stb glm jansson ffmpeg libdeflate` +
+{nbsp} wayland: `sudo pacman -S --needed wayland wayland-protocols wlr-protocols` +
+{nbsp} x11: `sudo pacman -S --needed libxext libxrandr` +
=== Compiling
-[source,sh]
+[source,console]
----
$ meson setup build -Dwindow=(x11|wayland) -Daudio=(enabled|disabled) -Dtaro=(enabled|disabled)
$ ninja -C build
@@ -25,7 +45,7 @@ $ ninja -C build
== Installing
=== Local
-[source,sh]
+[source,console]
----
$ sudo ninja -C build install
----
@@ -53,7 +73,7 @@ nixosSystem {
----
== Usage
-[source,sh]
+[source,console]
----
$ mauri --help
----
@@ -69,36 +89,38 @@ Usage: mauri (-p, --package [path_to_scene.pkg]|-d, --directory [path_to_wallpap
-t, --target dump the scene tree into this directory and exit
----
=== Examples
-[source,sh]
+[source,console]
----
# Set as the background of DP-1.
-$ ./mauri -p /mnt/hdd/SteamLibrary/steamapps/workshop/content/431960/2452236180/scene.pkg \
+$ ./mauri -p /mnt/hdd/SteamLibrary/steamapps/workshop/content/431960/1761287874/scene.pkg \
-a /mnt/hdd/SteamLibrary/steamapps/common/wallpaper_engine/assets -w 2560 -h 1440 -m DP-1
# Dump the scene into ./output.
-$ ./mauri -p /mnt/hdd/SteamLibrary/steamapps/workshop/content/431960/2108234011/scene.pkg \
+$ ./mauri -p /mnt/hdd/SteamLibrary/steamapps/workshop/content/431960/1582967473/scene.pkg \
-a /mnt/hdd/SteamLibrary/steamapps/common/wallpaper_engine/assets -t ./output
----
-=== taro
-[source,sh]
+== Taro
+[source,console]
----
-# You must run tarod once before anything to generate the necessary files for your setup.
+# Run `tarod` once before anything to generate the necessary files for your setup.
$ tarod
# Open the terminal UI.
$ taro
----
-==== Keybinds
+=== Keybinds
*←↓↑→/hjkl* - Move Selection, Edit Value +
*Enter/Space* - Confirm Selection +
-*Tab* - Cycle Between Grid, Info/Options, and Monitor Selection +
+*Tab* - Cycle Between Grid and Info/Options +
+*m* - Goto Monitor Selection +
*f/b* - Next/Previous Page +
+*n/N* - Set Next/Previous Wallpaper in Grid +
*r* - Remove Current Wallpaper +
-==== Config
-[source,sh]
+=== Config
+[source,console]
----
$ cat $HOME/.config/taro/config.json
----
@@ -114,7 +136,7 @@ $ cat $HOME/.config/taro/config.json
}
----
-==== Sway Config Example
+=== Sway Config Example
[source,sh]
----
# Set wallpaper
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..a2286fc
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+mauri (0.14-1) UNRELEASED; urgency=low
+
+ * Initial release. (Closes: #XXXXXX)
+
+ -- Andrew Opalach <andrew@akon.city> Thu, 12 Jun 2025 14:20:55 -0400
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..afd2256
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,12 @@
+Source: mauri
+Maintainer: Andrew Opalach <andrew@akon.city>
+Section: misc
+Priority: optional
+Standards-Version: 4.6.2
+Build-Depends: debhelper-compat (= 13), meson, cmake, pkg-config, libegl-dev, libgl-dev, liblz4-dev, libstb-dev, libglm-dev, nlohmann-json3-dev, libjansson-dev, libavcodec-dev, libavdevice-dev, libunistring-dev, libdeflate-dev, libtinfo-dev, libx11-dev, libxext-dev, libxrandr-dev, libwayland-dev
+
+Package: mauri
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Wallpaper Engine Implementation
+ + Daemon and TUI.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..71b5226
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,15 @@
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Source: https://git.akon.city/mauri
+Upstream-Name: Mauri
+
+Files:
+ *
+Copyright: 2025 Andrew Opalach <andrew@akon.city>
+License: GPL-3.0-only
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
+ .
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License along with this program. If not, see &lt;https://www.gnu.org/licenses/&gt.
+Comment:
+ On Debian systems, the full text of the GNU General Public License version 3 can be found in the file '/usr/share/common-licenses/GPL-3'.
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..cbe925d
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,3 @@
+#!/usr/bin/make -f
+%:
+ dh $@
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/flake.lock b/flake.lock
index 68074f7..933a2f6 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,29 +1,12 @@
{
"nodes": {
- "flake-utils": {
- "inputs": {
- "systems": "systems"
- },
- "locked": {
- "lastModified": 1731533236,
- "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
- "owner": "numtide",
- "repo": "flake-utils",
- "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
- "type": "github"
- },
- "original": {
- "id": "flake-utils",
- "type": "indirect"
- }
- },
"nixpkgs": {
"locked": {
- "lastModified": 1749285348,
- "narHash": "sha256-frdhQvPbmDYaScPFiCnfdh3B/Vh81Uuoo0w5TkWmmjU=",
+ "lastModified": 1749794982,
+ "narHash": "sha256-Kh9K4taXbVuaLC0IL+9HcfvxsSUx8dPB5s5weJcc9pc=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "3e3afe5174c561dee0df6f2c2b2236990146329f",
+ "rev": "ee930f9755f58096ac6e8ca94a1887e0534e2d81",
"type": "github"
},
"original": {
@@ -35,24 +18,8 @@
},
"root": {
"inputs": {
- "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
- },
- "systems": {
- "locked": {
- "lastModified": 1681028828,
- "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
- "owner": "nix-systems",
- "repo": "default",
- "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
- "type": "github"
- },
- "original": {
- "owner": "nix-systems",
- "repo": "default",
- "type": "github"
- }
}
},
"root": "root",
diff --git a/flake.nix b/flake.nix
index 0e961af..7534ae8 100644
--- a/flake.nix
+++ b/flake.nix
@@ -5,7 +5,7 @@
};
};
- outputs = { self, nixpkgs, flake-utils }: let
+ outputs = { self, nixpkgs }: let
forAllSupportedSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
@@ -15,6 +15,7 @@
forAllDevSystems = function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
+ "i686-linux"
] (system: function nixpkgs.legacyPackages.${system});
in rec {
packages = forAllSupportedSystems (pkgs: {
@@ -29,7 +30,7 @@
cd "$out"
${lib.getExe meson} subprojects download \
- libalabaster libnaunet stela janus stb s3tc-dxt-decompression notcurses
+ libalabaster libnaunet stela janus s3tc-dxt-decompression notcurses
cd "$out/subprojects/libalabaster"
${lib.getExe meson} subprojects download c89atomic
@@ -54,6 +55,7 @@
];
buildInputs = [
lz4
+ stb
glm
nlohmann_json
fftw
@@ -120,6 +122,8 @@
libdisplay-info
libliftoff
hwdata
+ # notcurses oiio
+ openimageio
];
shellHook = ''
export SHELL="${pkgs.bashInteractive}/bin/bash"
diff --git a/meson.build b/meson.build
index 3de74dc..791cd82 100644
--- a/meson.build
+++ b/meson.build
@@ -1,67 +1,63 @@
project('mauri', ['cpp', 'c'], version: '0.14',
- default_options: ['warning_level=2', 'cpp_std=c++17', 'c_std=c99'])
+ default_options: ['warning_level=2', 'cpp_std=c++17', 'c_std=c99'],
+ license: 'GPL-3.0-only')
compiler = meson.get_compiler('cpp')
cmake = import('cmake')
-is_debug = get_option('buildtype').startswith('debug')
+is_debug = get_option('debug')
is_windows = host_machine.system() == 'windows'
-alabaster = subproject('libalabaster').get_variable('alabaster')
+mauri_src = [
+ 'src/mauri.cc',
+ 'src/assets.cc',
+ 'src/context.cc',
+ 'src/gl.cc',
+ 'src/shader.cc',
+ 'src/engine.cc',
+ 'src/texture.cc',
+ 'src/objects/scene.cc',
+ 'src/objects/object.cc',
+ 'src/objects/model.cc',
+ 'src/objects/effect.cc',
+ 'src/objects/material.cc',
+ 'src/objects/pass.cc'
+]
+mauri_deps = []
+mauri_cpp_args = []
+mauri_link_args = []
+alabaster = subproject('libalabaster').get_variable('alabaster')
naunet = subproject('libnaunet', default_options: [
get_option('taro').enabled() ? 'event-loop=enabled' : 'event-loop=disabled',
'curl=disabled',
'json=enabled'
]).get_variable('naunet')
-
stela = subproject('stela', default_options: [
'api=gl',
- is_windows ? 'window=glfw' : 'window='+get_option('window'),
+ 'window='+get_option('window'),
'poll=inline',
'event-buffer=false',
'pause=false'
]).get_variable('stela')
+mauri_deps += [alabaster, naunet, stela]
janus = subproject('janus').get_variable('janus')
-stb = subproject('stb').get_variable('stb')
-s3tc = subproject('s3tc-dxt-decompression').get_variable('s3tc')
-
-lz4 = compiler.find_library('lz4', required: false)
-if not lz4.found()
- lz4 = subproject('lz4').get_variable('liblz4_dep')
+json = dependency('nlohmann_json')
+lz4 = dependency('liblz4')
+if not (compiler.check_header('stb/stb_image.h') and compiler.check_header('stb/stb_image_write.h'))
+ stb = subproject('stb').get_variable('stb')
+ mauri_deps += [stb]
+ mauri_cpp_args += ['-DMAURI_LOCAL_STB']
endif
-
-glm = dependency('glm', required: false)
+s3tc = subproject('s3tc-dxt-decompression').get_variable('s3tc')
+glm = dependency('glm', required: false, allow_fallback: false)
if not glm.found()
glm_opts = cmake.subproject_options()
glm_opts.add_cmake_defines({ 'CMAKE_BUILD_TYPE': is_debug ? 'Debug' : 'Release' })
glm = cmake.subproject('glm', options: glm_opts).dependency('glm')
endif
-
-json = dependency('nlohmann_json', required: false)
-if not json.found()
- json = subproject('json').get_variable('nlohmann_json_dep')
-endif
-
-mauri_deps = [alabaster, naunet, stela, janus, stb, s3tc, lz4, glm, json]
-mauri_src = [
- 'src/mauri.cc',
- 'src/assets.cc',
- 'src/context.cc',
- 'src/gl.cc',
- 'src/shader.cc',
- 'src/engine.cc',
- 'src/texture.cc',
- 'src/objects/scene.cc',
- 'src/objects/object.cc',
- 'src/objects/model.cc',
- 'src/objects/effect.cc',
- 'src/objects/material.cc',
- 'src/objects/pass.cc'
-]
-mauri_cpp_args = []
-mauri_link_args = []
+mauri_deps += [janus, json, lz4, s3tc, glm]
if get_option('audio').enabled()
fftw3 = dependency('fftw3')
diff --git a/src/mauri.cc b/src/mauri.cc
index 7cb1476..a1b1b83 100644
--- a/src/mauri.cc
+++ b/src/mauri.cc
@@ -133,6 +133,15 @@ auto window_system_main(u32 argc, str *argv, void *extra) -> s32
}
#ifndef _WIN32
+#include <unistd.h>
+#include <signal.h>
+
+static void sigint_handler(s32 signum)
+{
+ (void)signum;
+ log_info("recieved SIGINT, pid is %d, expecting to be killed by daemon", getpid());
+}
+
auto main(s32 argc, char *argv[]) -> s32
#else
auto wmain(s32 argc, wchar_t **argv) -> s32
@@ -156,6 +165,10 @@ auto wmain(s32 argc, wchar_t **argv) -> s32
args.wparse(argc, argv);
#endif
+#ifndef _WIN32
+ if (args.found("monitor")) signal(SIGINT, sigint_handler);
+#endif
+
if (!stl_global_init(false)) return EXIT_FAILURE;
s32 ret = stl_swallow_main(0, NULL, window_system_main, &args);
diff --git a/src/texture.cc b/src/texture.cc
index 3128a23..a1651f3 100644
--- a/src/texture.cc
+++ b/src/texture.cc
@@ -1,16 +1,23 @@
-_Pragma("GCC diagnostic push")
-_Pragma("GCC diagnostic ignored \"-Wunused-function\"")
-_Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"")
+#include <al/lib.h>
+AL_IGNORE_WARNING("-Wunused-function")
+AL_IGNORE_WARNING("-Wmissing-field-initializers")
#define STB_IMAGE_WRITE_IMPLEMENTATION
#define STB_IMAGE_WRITE_STATIC
+#ifdef MAURI_LOCAL_STB
#include <stb_image_write.h>
-
+#else
+#include <stb/stb_image_write.h>
+#endif
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_STATIC
#define STBI_NO_STDIO
#define STBI_NO_FAILURE_STRINGS
+#ifdef MAURI_LOCAL_STB
#include <stb_image.h>
-_Pragma("GCC diagnostic pop")
+#else
+#include <stb/stb_image.h>
+#endif
+AL_IGNORE_WARNING_END
#include <lz4.h>
#include <s3tc.h>
diff --git a/subprojects/glm.wrap b/subprojects/glm.wrap
index dd52366..04a775a 100644
--- a/subprojects/glm.wrap
+++ b/subprojects/glm.wrap
@@ -1,4 +1,9 @@
[wrap-git]
+directory = glm-1.0.1
url = https://github.com/g-truc/glm.git
-revision =7a878c23723a5122078e07b0d870016afd8854ce
+revision = 1.0.1
depth = 1
+method = cmake
+
+[provide]
+dependency_names = glm
diff --git a/subprojects/janus.wrap b/subprojects/janus.wrap
index 4565144..e3860c7 100644
--- a/subprojects/janus.wrap
+++ b/subprojects/janus.wrap
@@ -1,6 +1,8 @@
[wrap-git]
+directory = janus-69c0137
url = https://github.com/dmulholl/argspp.git
revision = 69c01373399ab28c6090728c032226d4dc56dccf
depth = 1
+
patch_directory = janus
diff_files = janus/compiler_warnings.diff, janus/wparse.diff
diff --git a/subprojects/json.wrap b/subprojects/json.wrap
deleted file mode 100644
index ba8056c..0000000
--- a/subprojects/json.wrap
+++ /dev/null
@@ -1,4 +0,0 @@
-[wrap-git]
-url = https://github.com/nlohmann/json.git
-revision = 6eab7a2b187b10b2494e39c1961750bfd1bda500
-depth = 1
diff --git a/subprojects/lz4.wrap b/subprojects/liblz4.wrap
index cdbcd4c..387ceee 100644
--- a/subprojects/lz4.wrap
+++ b/subprojects/liblz4.wrap
@@ -1,6 +1,11 @@
[wrap-git]
+directory = lz4-v1.10.0
url = https://github.com/lz4/lz4.git
-revision = 07c526c0afe28866cdcb7f84f4aadcebd0d63ba7
+revision = v1.10.0
depth = 1
+
patch_directory = lz4
diff_files = lz4/move_meson_build.diff
+
+[provide]
+liblz4 = liblz4_dep
diff --git a/subprojects/libnaunet.wrap b/subprojects/libnaunet.wrap
index 8388a93..462c1a7 100644
--- a/subprojects/libnaunet.wrap
+++ b/subprojects/libnaunet.wrap
@@ -1,4 +1,4 @@
[wrap-git]
url = https://git.akon.city/libnaunet
-revision = 393e266f6bfceb25a97cd1cf28dfc72cac9e9f81
+revision = fc8df3fe9cd15fe7b0b86c6584e0b3fb487d6886
depth = 1
diff --git a/subprojects/nlohmann_json.wrap b/subprojects/nlohmann_json.wrap
new file mode 100644
index 0000000..95d1d9b
--- /dev/null
+++ b/subprojects/nlohmann_json.wrap
@@ -0,0 +1,8 @@
+[wrap-git]
+directory = nlohmann_json-v3.12.0
+url = https://github.com/nlohmann/json.git
+revision = v3.12.0
+depth = 1
+
+[provide]
+nlohmann_json = nlohmann_json_dep
diff --git a/subprojects/notcurses.wrap b/subprojects/notcurses.wrap
index 64f6731..bc58274 100644
--- a/subprojects/notcurses.wrap
+++ b/subprojects/notcurses.wrap
@@ -1,12 +1,12 @@
[wrap-git]
+directory = notcurses-93a4890
url = https://github.com/dankamongmen/notcurses.git
-revision = 9377370b59e31f3f3adde6eaa89aa875dd84377f
+revision = 93a4890f4c2b491cda62fea5110995c6a25691e2
depth = 1
+method = cmake
patch_directory = notcurses
diff_files = notcurses/duration_and_ffmpeg_fix.diff
-method = cmake
-
[provide]
dependency_names = notcurses, notcurses-core
diff --git a/subprojects/packagefiles/stb/meson.build b/subprojects/packagefiles/stb/meson.build
index e712682..fe0d601 100644
--- a/subprojects/packagefiles/stb/meson.build
+++ b/subprojects/packagefiles/stb/meson.build
@@ -1,2 +1,2 @@
-project('stb', 'c', version: 'git-31707d1')
+project('stb', 'c', version: 'git-f58f558')
stb = declare_dependency(include_directories: include_directories('.'))
diff --git a/subprojects/s3tc-dxt-decompression.wrap b/subprojects/s3tc-dxt-decompression.wrap
index cc70c7c..7be1585 100644
--- a/subprojects/s3tc-dxt-decompression.wrap
+++ b/subprojects/s3tc-dxt-decompression.wrap
@@ -1,6 +1,8 @@
[wrap-git]
+directory = s3tc-dxt-decompression-17074c2
url = https://github.com/Benjamin-Dobell/s3tc-dxt-decompression.git
revision = 17074c22c7857cfc4e843a07e99519a09c3a563f
depth = 1
+
patch_directory = s3tc-dxt-decompression
diff_files = s3tc-dxt-decompression/explicit_type_sizes.diff, s3tc-dxt-decompression/compiler_warnings.diff, s3tc-dxt-decompression/dxt1_default_alpha.diff
diff --git a/subprojects/stb.wrap b/subprojects/stb.wrap
index 79f7ec4..8f8efb8 100644
--- a/subprojects/stb.wrap
+++ b/subprojects/stb.wrap
@@ -1,5 +1,7 @@
[wrap-git]
+directory = stb-f58f558
url = https://github.com/nothings/stb.git
-revision = 31707d14fdb75da66b3eed52a2236a70af0d0960
+revision = f58f558c120e9b32c217290b80bad1a0729fbb2c
depth = 1
+
patch_directory = stb
diff --git a/subprojects/stela.wrap b/subprojects/stela.wrap
index 444d851..c34c19d 100644
--- a/subprojects/stela.wrap
+++ b/subprojects/stela.wrap
@@ -1,4 +1,4 @@
[wrap-git]
url = https://git.akon.city/stela
-revision = 658e476c3d43718a2c9eb2884f16ac37cc3f1da2
+revision = 234e3cb390c7bb149ddd281d695d81a368e1a441
depth = 1
diff --git a/taro/config.h b/taro/config.h
index cca7807..7c8e2a1 100644
--- a/taro/config.h
+++ b/taro/config.h
@@ -8,12 +8,20 @@
#define CONFIG_PATH "/.config/taro"
+enum {
+ CONFIG_CREATED = 0,
+ CONFIG_LOADED,
+ CONFIG_ERRORED
+};
+
struct config {
str config_dir;
str config_path;
+ bool newly_created;
str asset_dir;
array(str) wallpaper_dirs;
bool valid;
+ bool errored;
};
AL_IGNORE_WARNING("-Wunused-function")
@@ -96,9 +104,11 @@ out:
json_decref(root);
}
-static bool open_config(struct config *conf, bool create)
+static u8 open_config(struct config *conf, bool create)
{
al_memset(conf, 0, sizeof(struct config));
+ al_array_init(conf->wallpaper_dirs);
+ conf->errored = false;
char *envhome = getenv("HOME");
if (!envhome) goto err;
@@ -108,6 +118,8 @@ static bool open_config(struct config *conf, bool create)
if (!nn_dir_exists(&conf->config_dir)) {
if (!create || !nn_dir_create(&conf->config_dir)) {
goto err;
+ } else {
+ conf->newly_created = true;
}
}
@@ -127,14 +139,17 @@ static bool open_config(struct config *conf, bool create)
json_t *root = nn_file_open_as_json(&conf->config_path);
if (!root) goto err;
- al_array_init(conf->wallpaper_dirs);
-
- parse_config_json(conf, envhome, root);
+ if (!conf->newly_created) {
+ parse_config_json(conf, envhome, root);
+ } else {
+ conf->valid = false;
+ }
- return true;
+ return conf->newly_created ? CONFIG_CREATED : CONFIG_LOADED;
err:
+ conf->errored = true;
close_config(conf);
- return false;
+ return CONFIG_ERRORED;
}
AL_IGNORE_WARNING_END
diff --git a/taro/daemon.c b/taro/daemon.c
index 6ceba90..895ce53 100644
--- a/taro/daemon.c
+++ b/taro/daemon.c
@@ -14,6 +14,8 @@
#include "file_ext.h"
#include "config.h"
+//#define USE_SWAYIPC
+
struct monitor {
struct stl_monitor *os;
str config_dir;
@@ -26,15 +28,15 @@ struct monitor {
struct daemon *dmon;
};
-#define SWAY_IPC_HEADER_LENGTH 14
-#define SWAY_IPC_SUBSCRIBE 2
-
struct daemon {
struct nn_event_loop loop;
struct nn_signal quit_signal;
s32 context_poll_fd;
struct nn_poll context_poll;
array(struct monitor *) monitors;
+#ifdef USE_SWAYIPC
+#define SWAY_IPC_HEADER_LENGTH 14
+#define SWAY_IPC_SUBSCRIBE 2
struct nn_socket ipc_socket;
bool ipc_connected;
bool ipc_errored;
@@ -50,6 +52,7 @@ struct daemon {
ssize_t size;
ssize_t alloc;
} ipc;
+#endif
struct config conf;
struct nn_fs_event conf_event;
};
@@ -111,7 +114,7 @@ static pid_t exec_or_exit(char *args[])
// This should return the pid of init if the parent process has already exited.
pid_t ppid = getppid();
if (ppid != 1) send_signal_to_pid(ppid, SIGINT);
- exit(EXIT_FAILURE);
+ // Rely on maybe_kill_wallpaper() to kill this fork.
}
}
return pid;
@@ -119,28 +122,27 @@ static pid_t exec_or_exit(char *args[])
static void maybe_kill_wallpaper(struct monitor *monitor)
{
- if (monitor->pid != -1) {
- if (monitor->paused) {
- signal_monitor(monitor, SIGCONT);
- monitor->paused = false;
- }
- signal_monitor(monitor, SIGTERM);
- monitor->pid = -1;
+ if (monitor->pid == -1) return;
+ if (monitor->paused) {
+ signal_monitor(monitor, SIGCONT);
+ monitor->paused = false;
}
+ signal_monitor(monitor, SIGTERM);
+ monitor->pid = -1;
}
static bool search_wallpaper_dirs(struct daemon *dmon, str *id, str *path)
{
bool found = false;
- log_debug("searching for wallpaper of id %.*s", al_str_x(id));
+ log_info("searching for wallpaper of id %.*s", al_str_x(id));
str *dir;
al_array_foreach_ptr(dmon->conf.wallpaper_dirs, i, dir) {
- log_debug("checking dir %.*s", al_str_x(dir));
+ log_info("checking dir %.*s", al_str_x(dir));
al_str_clone(path, dir);
if (al_str_at(path, 1) != '/') al_str_cat(path, &al_str_c("/"));
al_str_cat(path, id);
if (nn_dir_exists(path)) {
- log_debug("found wallpaper");
+ log_info("found wallpaper");
found = true;
break;
}
@@ -155,6 +157,11 @@ static bool run_wallpaper(struct daemon *dmon, struct monitor *monitor)
{
maybe_kill_wallpaper(monitor);
+ if (dmon->conf.newly_created) {
+ al_assert(!dmon->conf.valid);
+ return false;
+ }
+
if (!dmon->conf.valid) {
log_error("config invalid, not setting wallpaper on %s", monitor->os->name);
return false;
@@ -272,6 +279,9 @@ static void output_discovered_callback(void *userdata, struct stl_monitor *os_mo
{
struct daemon *dmon = (struct daemon *)userdata;
+ log_info("Output discovered: %s (%ux%u) (vertical: %s).", os_monitor->name,
+ os_monitor->width, os_monitor->height, BOOLSTR(os_monitor->vertical));
+
struct monitor *monitor;
al_array_foreach(dmon->monitors, i, monitor) {
if (strcmp(monitor->os->name, os_monitor->name) == 0) {
@@ -299,10 +309,14 @@ static void conf_fs_event_callback(void *userdata, struct inotify_event *event)
{
struct daemon *dmon = (struct daemon *)userdata;
(void)event;
- close_config(&dmon->conf);
- if (!open_config(&dmon->conf, false)) {
- log_error("config became unavailable, exiting...");
- exit(EXIT_FAILURE);
+ nn_fs_event_stop(&dmon->conf_event);
+ nn_fs_event_start(&dmon->conf_event, &dmon->loop);
+ if (!dmon->conf.errored) close_config(&dmon->conf);
+ if (open_config(&dmon->conf, false) == CONFIG_LOADED && dmon->conf.valid) {
+ log_info("config successfully reloaded");
+ } else {
+ log_error("failed to reload config");
+ return;
}
struct monitor *monitor;
al_array_foreach(dmon->monitors, i, monitor) {
@@ -317,6 +331,7 @@ static void close_monitor(struct monitor *monitor)
nn_fs_event_free(&monitor->selection_event);
}
+#ifdef USE_SWAYIPC
static void ipc_handle_subscribe_success(json_t *root)
{
if (json_boolean_value(root)) {
@@ -442,6 +457,7 @@ static void ipc_poll_callback(void *userdata, s32 revents)
}
}
}
+#endif
static void context_poll_callback(void *userdata, s32 revents)
{
@@ -458,7 +474,9 @@ static void quit_signal_callback(void *userdata)
nn_fs_event_stop(&monitor->selection_event);
}
nn_fs_event_stop(&dmon->conf_event);
+#ifdef USE_SWAYIPC
if (!dmon->ipc_errored) nn_poll_stop(&dmon->ipc_poll);
+#endif
if (dmon->context_poll_fd != -1) nn_poll_stop(&dmon->context_poll);
nn_signal_stop(&dmon->quit_signal);
}
@@ -480,17 +498,27 @@ static void sigint_handler(s32 signum)
nn_signal_send(&dmon.quit_signal);
}
-s32 main(void)
+s32 main()
{
- if (!nn_common_init(NULL) || !open_config(&dmon.conf, true)) {
- return EXIT_FAILURE;
+ s32 exit_status = EXIT_FAILURE;
+
+ if (!nn_common_init(NULL)) return exit_status;
+
+ switch (open_config(&dmon.conf, true)) {
+ case CONFIG_CREATED:
+ log_info("config generated in $HOME%s, go fill it out", CONFIG_PATH);
+ break;
+ case CONFIG_LOADED:
+ break;
+ case CONFIG_ERRORED:
+ log_error("failed to open config");
+ nn_common_close();
+ return exit_status;
}
signal(SIGINT, sigint_handler);
signal(SIGCHLD, sigchld_handler);
- s32 ret = EXIT_FAILURE;
-
nn_event_loop_init(&dmon.loop);
nn_signal_init(&dmon.quit_signal, &dmon.loop, quit_signal_callback, &dmon);
@@ -525,6 +553,7 @@ s32 main(void)
al_str_free(&monitors);
if (!monitors_exists) goto out;
+#ifdef USE_SWAYIPC
dmon.ipc.buf = NULL;
dmon.ipc.size = 0;
dmon.ipc.index = 0;
@@ -544,19 +573,22 @@ s32 main(void)
dmon.ipc_errored = true;
log_warn("couldn't connect to sway ipc socket");
}
+#endif
nn_fs_event_init(&dmon.conf_event, &dmon.conf.config_path, NNWT_CLOSE_WRITE, conf_fs_event_callback, &dmon);
nn_fs_event_start(&dmon.conf_event, &dmon.loop);
nn_event_loop_run(&dmon.loop);
- ret = EXIT_SUCCESS;
+ exit_status = EXIT_SUCCESS;
nn_fs_event_free(&dmon.conf_event);
+#ifdef USE_SWAYIPC
al_free(dmon.out.buf);
al_free(dmon.ipc.buf);
nn_socket_close(&dmon.ipc_socket);
+#endif
out:
al_array_foreach(dmon.monitors, i, monitor) {
@@ -573,5 +605,5 @@ out:
stl_global_close();
nn_common_close();
- return ret;
+ return exit_status;
}
diff --git a/taro/meson.build b/taro/meson.build
index ffee872..a5be1e0 100644
--- a/taro/meson.build
+++ b/taro/meson.build
@@ -3,14 +3,15 @@ notcurses_core = dependency('notcurses-core', required: false, allow_fallback: f
if not notcurses.found() or not notcurses_core.found()
notcurses_opts = cmake.subproject_options()
notcurses_opts.add_cmake_defines({ 'CMAKE_BUILD_TYPE': is_debug ? 'Debug' : 'Release' })
- notcurses_opts.add_cmake_defines({ 'USE_CXX': false })
+ use_oiio = false
+ notcurses_opts.add_cmake_defines({ 'USE_CXX': use_oiio })
notcurses_opts.add_cmake_defines({ 'USE_DOCTEST': false })
notcurses_opts.add_cmake_defines({ 'USE_PANDOC': false })
notcurses_opts.add_cmake_defines({ 'BUILD_EXECUTABLES': false })
notcurses_opts.add_cmake_defines({ 'BUILD_FFI_LIBRARY': false })
notcurses_opts.add_cmake_defines({ 'USE_POC': false })
notcurses_opts.add_cmake_defines({ 'USE_STATIC': false })
- notcurses_opts.add_cmake_defines({ 'USE_MULTIMEDIA': 'ffmpeg' })
+ notcurses_opts.add_cmake_defines({ 'USE_MULTIMEDIA': use_oiio ? 'oiio' : 'ffmpeg' })
notcurses_proj = cmake.subproject('notcurses', options: notcurses_opts)
notcurses = notcurses_proj.dependency('notcurses')
notcurses_core = notcurses_proj.dependency('notcurses-core')
diff --git a/taro/ui.c b/taro/ui.c
index 1162196..2b1de3b 100644
--- a/taro/ui.c
+++ b/taro/ui.c
@@ -12,8 +12,6 @@
#include "file_ext.h"
#include "config.h"
-#define PIXEL_BLIT 1
-
#define TIMER_UPDATE_BASE 1.f
#define TIMER_TICK(delay) MAX(TIMER_UPDATE_BASE * (delay / 1000000.f), 0.001f)
@@ -116,6 +114,7 @@ enum {
struct ui {
struct notcurses *nc;
+ bool use_pixel_blit;
struct nn_event_loop loop;
struct nn_poll input_poll;
u64 delay;
@@ -183,11 +182,12 @@ static void write_selected_entry_to_config(struct ui *u)
if (u->g.set_index == -1) {
al_str_from(&config, "||");
} else {
- al_str_clone(&config, &u->n.e->id);
- al_str_cat(&config, u->n.e->has_package ? &al_str_c("_p") : &al_str_c("_d"));
+ struct entry *e = &al_array_at(u->db.entries, u->g.set_index);
+ al_str_clone(&config, &e->id);
+ al_str_cat(&config, e->has_package ? &al_str_c("_p") : &al_str_c("_d"));
al_str_cat(&config, &al_str_c("|false,100|"));
struct prop *p;
- al_array_foreach_ptr(u->n.e->props, i, p) {
+ al_array_foreach_ptr(e->props, i, p) {
switch (p->type) {
case PROP_TYPE_BOOL: {
bool value = *((bool *)p->value);
@@ -272,6 +272,7 @@ static bool init_monitors(struct ui *u, struct monitors *m)
} else {
u->selected_menu = MENU_MONITORS;
}
+ u->previous_menu = u->selected_menu;
return true;
}
@@ -293,10 +294,17 @@ static bool init_ui(struct ui *u)
log_error("failed to initialize notcurses");
return false;
}
+ //al_printf("%u\n", notcurses_palette_size(u->nc));
al_set_print(void_print_callback, NULL);
return true;
}
+static inline void ncplane_maybe_set_styles(struct ui *u, struct ncplane *p, u32 style)
+{
+ // Setting text to bold messes up colors on some terminals.
+ if (u->use_pixel_blit) ncplane_set_styles(p, style);
+}
+
struct image *get_image_from_pool(struct image_pool *pool, str *path)
{
u32 hash = al_str_hash(path);
@@ -710,7 +718,7 @@ void draw_monitors(struct ui *u, struct monitors *m)
}
}
- ncplane_set_styles(u->mp, NCSTYLE_BOLD);
+ ncplane_maybe_set_styles(u, u->mp, NCSTYLE_BOLD);
s32 x = ((ncplane_dim_x(u->mp) - 1) - width) / 2;
ncplane_cursor_move_yx(u->mp, 0, x);
@@ -748,8 +756,10 @@ void draw_info(struct ui *u, struct info *n, bool update_text)
ncplane_erase(u->ip);
struct ncvisual_options vopts = { 0 };
- vopts.scaling = PIXEL_BLIT ? NCSCALE_SCALE_HIRES : NCSCALE_STRETCH;
- vopts.blitter = PIXEL_BLIT ? NCBLIT_PIXEL : NCBLIT_2x1;
+ vopts.scaling = u->use_pixel_blit ? NCSCALE_SCALE_HIRES : NCSCALE_STRETCH;
+ vopts.blitter = u->use_pixel_blit ? NCBLIT_PIXEL : NCBLIT_2x1;
+ vopts.flags = NCVISUAL_OPTION_HORALIGNED;
+ vopts.x = NCALIGN_CENTER;
struct image *img = get_image_from_pool(&u->pool, &n->e->preview_path);
if (img && !n->blitted && !img->errored) {
ncplane_erase(n->ip);
@@ -759,10 +769,8 @@ void draw_info(struct ui *u, struct info *n, bool update_text)
ncvisual_blit(u->nc, img->v, &vopts);
n->blitted = !img->gif;
u->delay = ncvisual_get_duration(img->v);
- if (u->delay == 10000) {
- // Default 100fps gifs to 10fps, seems like some weird wallpaper engine behavior.
- u->delay = 100000;
- }
+ // Default 100fps gifs to 10fps, seems like some weird wallpaper engine behavior.
+ if (u->delay == 10000) u->delay = 100000;
}
} else if (!img) {
ncplane_erase(n->ip);
@@ -813,11 +821,14 @@ static void set_tile_highlight(struct tile *t, s32 findex, s32 bindex)
nccell_set_fg_default(&ncl);
ncplane_polyfill_yx(t->p, 1, 0, &ncl);
nccell_release(t->p, &ncl);
+
+ // Portion of the top row.
ncplane_set_bg_default(t->p);
ncplane_set_fg_palindex(t->p, bindex);
for (s32 i = 0; i < GRID_TILE_WIDTH; i++) {
ncplane_putwc_yx(t->p, 0, i, L'▃');
}
+
(void)findex;
//ncplane_set_fg_palindex(t->p, findex);
// If we set both fg and bg palindex here, the fg color
@@ -825,7 +836,6 @@ static void set_tile_highlight(struct tile *t, s32 findex, s32 bindex)
// This might be a notcurses bug, I need to look more carefully.
ncplane_set_fg_rgb8(t->p, 0, 0, 0);
ncplane_set_bg_palindex(t->p, bindex);
- ncplane_set_styles(t->p, NCSTYLE_BOLD);
}
void draw_grid_tiles(struct ui *u, struct grid *g, bool update_text)
@@ -833,8 +843,10 @@ void draw_grid_tiles(struct ui *u, struct grid *g, bool update_text)
if (!u->layed_out) return;
struct ncvisual_options vopts = { 0 };
- vopts.scaling = PIXEL_BLIT ? NCSCALE_SCALE_HIRES : NCSCALE_STRETCH;
- vopts.blitter = PIXEL_BLIT ? NCBLIT_PIXEL : NCBLIT_2x1;
+ vopts.scaling = u->use_pixel_blit ? NCSCALE_SCALE_HIRES : NCSCALE_STRETCH;
+ vopts.blitter = u->use_pixel_blit ? NCBLIT_PIXEL : NCBLIT_2x1;
+ vopts.flags = NCVISUAL_OPTION_HORALIGNED;
+ vopts.x = NCALIGN_CENTER;
struct tile *t;
al_array_foreach_ptr(g->tiles, i, t) {
@@ -847,19 +859,33 @@ void draw_grid_tiles(struct ui *u, struct grid *g, bool update_text)
}
}
}
+
s32 index = g->selected_index - (g->selected_index % g->tiles_per_page);
al_array_foreach_ptr(g->tiles, i, t) {
ncplane_erase(t->p);
if (!t->e) continue;
- if (index == g->selected_index && g->flash <= 0.f && u->selected_menu == MENU_GRID) {
- set_tile_highlight(t, 0, 8);
+ if (index == g->selected_index && u->selected_menu == MENU_GRID) {
+ if (g->flash >= 0.f) {
+ if (index == g->set_index) {
+ set_tile_highlight(t, 0, 7);
+ ncplane_maybe_set_styles(u, t->p, NCSTYLE_BOLD);
+ } else if (g->set_index == -1) {
+ ncplane_set_fg_default(t->p);
+ ncplane_set_bg_default(t->p);
+ ncplane_maybe_set_styles(u, t->p, NCSTYLE_NONE);
+ }
+ g->flash -= TIMER_TICK(u->delay);
+ } else {
+ set_tile_highlight(t, 0, 8);
+ ncplane_maybe_set_styles(u, t->p, NCSTYLE_BOLD);
+ }
} else if (index == g->set_index && g->set_index >= 0) {
set_tile_highlight(t, 0, 7);
- g->flash -= TIMER_TICK(u->delay);
+ ncplane_maybe_set_styles(u, t->p, NCSTYLE_BOLD);
} else {
ncplane_set_fg_default(t->p);
ncplane_set_bg_default(t->p);
- ncplane_set_styles(t->p, NCSTYLE_NONE);
+ ncplane_maybe_set_styles(u, t->p, NCSTYLE_NONE);
}
if (t->text.s && !al_wstr_is_empty(t->text.s)) {
draw_scrolling_text(t->p, &t->text, update_text);
@@ -894,9 +920,11 @@ static bool handle_input_monitors(struct ui *u, struct monitors *m, struct ncinp
}
case NCKEY_DOWN:
case 'j': {
- u->selected_menu = MENU_GRID;
- should_redraw_monitors = true;
- should_redraw_grid = true;
+ if (u->db.entries.count > 0) {
+ u->selected_menu = MENU_GRID;
+ should_redraw_monitors = true;
+ should_redraw_grid = true;
+ }
break;
}
case NCKEY_RETURN:
@@ -1106,8 +1134,35 @@ static bool handle_input_grid(struct ui *u, struct grid *g, struct ncinput *inpu
}
break;
}
+ case 'N':
+ case 'n': {
+ if (g->selected_index < 0) {
+ return false;
+ }
+ if (input->id == 'N' || input->modifiers & NCKEY_MOD_SHIFT) {
+ if (g->selected_index == 0) {
+ return false;
+ }
+ g->selected_index -= 1;
+ } else {
+ if ((u32)g->selected_index + 1 >= u->db.entries.count) {
+ return false;
+ }
+ g->selected_index += 1;
+ }
+ if (g->selected_index > g->max_index || g->selected_index < g->min_index) {
+ should_update_grid = true;
+ }
+ g->set_index = g->selected_index;
+ g->flash = FLASH_DURATION;
+ write_selected_entry_to_config(u);
+ should_redraw_grid = true;
+ should_redraw_info = true;
+ break;
+ }
case 'r': {
g->set_index = -1;
+ g->flash = FLASH_DURATION;
write_selected_entry_to_config(u);
should_redraw_grid = true;
should_redraw_info = true;
@@ -1126,10 +1181,11 @@ static bool handle_input_grid(struct ui *u, struct grid *g, struct ncinput *inpu
}
case NCKEY_RETURN:
case NCKEY_SPACE: {
- if (g->selected_index >= 0) {
- g->set_index = g->selected_index;
- g->flash = FLASH_DURATION;
+ if (g->selected_index < 0) {
+ return false;
}
+ g->set_index = g->selected_index;
+ g->flash = FLASH_DURATION;
write_selected_entry_to_config(u);
should_redraw_grid = true;
should_redraw_info = true;
@@ -1248,14 +1304,15 @@ static struct ui u = { 0 };
s32 main(void)
{
- if (!nn_common_init(NULL)) return EXIT_FAILURE;
+ s32 exit_status = EXIT_FAILURE;
- if (!open_config(&u.conf, false)) {
- log_error("failed to open config, run `tarod` at least once to generate needed config");
- return EXIT_FAILURE;
- }
+ if (!nn_common_init(NULL)) return exit_status;
- s32 ret = EXIT_FAILURE;
+ if (open_config(&u.conf, false) != CONFIG_LOADED) {
+ log_error("failed to open config, run `tarod` at least once to generate the required config");
+ nn_common_close();
+ return exit_status;
+ }
db_init(&u.db);
@@ -1266,6 +1323,13 @@ s32 main(void)
db_sort(&u.db);
+ const char *term_env = getenv("TERM");
+ if (strcmp(term_env, "xterm-kitty") == 0) {
+ u.use_pixel_blit = true;
+ } else {
+ u.use_pixel_blit = false;
+ }
+
if (!init_ui(&u)) goto out;
notcurses_stddim_yx(u.nc, &u.term_rows, &u.term_cols);
@@ -1295,12 +1359,12 @@ s32 main(void)
notcurses_stop(u.nc);
- ret = EXIT_SUCCESS;
+ exit_status = EXIT_SUCCESS;
out:
close_config(&u.conf);
nn_common_close();
- return ret;
+ return exit_status;
}