Skip to content

Conversation

@Cetttok
Copy link

@Cetttok Cetttok commented Nov 16, 2025

created new module (themepresetmanager) and integrate it to conky in main.c.
implemented:

  • user can specify theme preset by alias in conifg option eg conky -c lean
  • theme presets stored in git repo with simple struct (themealias.theme - folder name and everywords.conf - main config name)
  • operations with git realise with libgit2 and I dont now there correct add includes ( in CMakeLists.txt files)
  • i dont know where i must to store my h and cpp files
  • this code testes with /var/lib/conky/themes repo path and exapmle repo https://github.com/Cetttok/testRepoForConkyThemes
  • this code cant clone repo with submodules and i dont know is it necessary
    please view and say me what i must correct
    i ready to perform yours requirements

Related to #2142

sorry for my English

@netlify
Copy link

netlify bot commented Nov 16, 2025

Deploy Preview for conkyweb canceled.

Name Link
🔨 Latest commit bb133b8
🔍 Latest deploy log https://app.netlify.com/projects/conkyweb/deploys/69230d3ade941500083e1ac8

@github-actions github-actions bot added sources PR modifies project sources build system related to build system (CMake) and/or building process/assumptions labels Nov 16, 2025
@Cetttok
Copy link
Author

Cetttok commented Nov 16, 2025

maybe need to add gitlib2 to dependencies and i didn know how to do it :(

@github-actions github-actions bot added the tests related to project tests label Nov 18, 2025
@github-actions github-actions bot removed the tests related to project tests label Nov 18, 2025
@github-actions github-actions bot added the gh-actions suggest changing GitHub actions label Nov 18, 2025
@Cetttok
Copy link
Author

Cetttok commented Nov 18, 2025

guys build test done! Maybe somebody say me that i do uncorrect?

Copy link
Collaborator

@Caellian Caellian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a preliminary review.

I'm not 100% sure about adding this feature and would like @brndnmtthws input before accepting this PR. It's a neat idea and I see how people would find it useful and convenient, but it also makes it very easy to distribute malicious configs because people won't check the presets/themes before updating them, just like they don't for AUR lol.

We could author an official repo with reviewed configs, but that's also a lot of work or trust to put into someone. So this would mostly be useful to Linux distribution authors.

CMakeLists.txt Outdated
Comment on lines 56 to 57
set(conky_libs ${conky_libs} PkgConfig::LIBGIT2)

Copy link
Collaborator

@Caellian Caellian Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a pretty detailed guide on the Wiki I wrote quite some time ago that describes how to add dependencies and compile-time options, so read that section.

Lua and Vc are added here because they're in thirdparty directory, but all the dependencies pulled from build system are added to conky_libs variable from cmake/ConkyPlatformChecks.cmake file. Search for BUILD_IMLIB2 in CMake files for a discrete example.

include(Catch)
endif()


Copy link
Collaborator

@Caellian Caellian Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go through the diff, either here on github in "Files changed" tab or using git diff and remove these unnecessary changes. This space for instace, blank comments later, etc. make the PR harder to review than it needs to be.

src/conky.cc Outdated

#ifdef BUILD_BUILTIN_CONFIG
#include "defconfig.h"
#include "themespresetmanager.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you added a guard like BUILD_IMLIB2, the include needs to be guarded with ifdefs, as well as any code that's using that.

src/main.cc Outdated
Comment on lines 304 to 305
const char * THEME_PRESETS_REPO_CLONING_URL = "https://github.com/Cetttok/testRepoForConkyThemes"; // it is example need to create norm repo
const char * THEME_PRESETS_REPO_PATH = "/var/lib/conky/themes";
Copy link
Collaborator

@Caellian Caellian Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these in main.cc? You're declaring them here, just to pass them to the function in another file. Declare them above that function so they're easy to find and modify and remove the arguments. This won't be called from several places, no need to parametrize the function when constants are fine.

However, these should really be configurable at build time, like HTTPPORT is (see cmake/ConkyBuildOptions.cmake). This would allow distro authors to easily swap them out for their own URL.

main.cc is already very large (much like conky.cc). Avoid placing more stuff in these two files.

src/main.cc Outdated
Comment on lines 370 to 373
// case 'S':
// std::cout << "optarg " << optarg << std::endl;
// std::cout << presets.getThemePath(std::string(optarg)) << std::endl;
// break;
Copy link
Collaborator

@Caellian Caellian Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before merge, these comments need to be removed if the code isn't used. Very rarely it makes sense to leave code commented out.

return false;
}
git_reference * mainBranch = nullptr;
if (git_reference_lookup(&mainBranch, _repo, "refs/remotes/origin/main")!=0){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding "main" ref for repositories feels bad. It should be specified in the same place the repository URI is in the build file (e.g. using THEME_REPO_URL and THEME_REPO_BRANCH).

Comment on lines 225 to 228
if (git_clone(&_repo, _repoUrl.c_str(), _pathToFolder.c_str(), NULL)!=0){
std::cout << "SystemGitRepoSource::error while git clone(init url): "<<git_error_last()->message << std::endl;
return false;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bad idea. Cloning a repo with themes can result in HUGE amounts of traffic and freeze conky for a very long time. It's possible for themes to include arbitrary assets (like pictures they draw with cairo).

Git allows pulling only a specific (in this case, the requested one) directory:

git init
git remote add origin GIT_URL
git fetch origin
git checkout origin/BRANCH -- path/to/directory

It's reasonable to expect the theme repository to contain some top-level theme listing. We already use libxml for some things, so it would be a good choice in this case.

<repository>
  <theme name="Theme name" path="manjaro/default">
    <include>common/lua/my_util.lua</include> <!-- Not really that important for first version/MVP -->
    <author>Author 1</author> <!-- You'd ignore these, just don't error if found -->
    <author>Author 2</author>
  </theme>
</repository>

Another issue is that current code will not initialize submodules. You need to check if theme->path is a submodule and tell git to initialize it first.

Comment on lines 25 to 28
#include <map>
#include <string>
#include <vector>
#include <git2.h>
Copy link
Collaborator

@Caellian Caellian Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add newline between standard library and git2 library include.

Comment on lines 75 to 77
git_repository * _repo = NULL;
// /std::string _pathToRepo = "";
std::string _repoUrl = "";
Copy link
Collaborator

@Caellian Caellian Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't prefix with _ in C++. All _ prefixed names are reserved for compiler and standard library implementations. See this SO answer.

If you're exposing the repo_url() function, then the variable should be named m_repo_url to avoid naming conflict.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for your review! I try to fix all

AbstractThemesSource();
virtual bool loadThemesDb() = 0; // or reload
virtual std::map<std::string, std::string> getThemesDb() = 0;
virtual std::vector<std::string> loadPossibleAliasOfThemes() = 0 ;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run clang format on your code. It will remove 99% of jank like the space between 0 and ; here.

We should really have a CI that fails if the code isn't formatted using the project .clang-format file.

- xml repo config
- git submodules support (i fuck that make)
- build optionts add
- code style change
- not full pull
- pulling one dir or file
- another small fixes
@github-actions github-actions bot added the dependencies adds or removes dependencies, or suggests alternatives label Nov 21, 2025
@Caellian Caellian added the feature suggest addition of new functionality that isn't currently supported in any way label Nov 21, 2025
- libgit2 memory leaks fixed
- clang-format on all themepresetsmanager module code
- increase verbosity of headers
- example xml added
- presets repo pulling/cloning log
@Cetttok
Copy link
Author

Cetttok commented Nov 23, 2025

to be honest, I don't understand why nix crashes.

@Cetttok Cetttok requested a review from Caellian November 23, 2025 09:08
@Cetttok
Copy link
Author

Cetttok commented Nov 23, 2025

Halo guys! I make most of all that @Caellian told me.
That changed in last commits:

  • repo not pulling of every path replacing request. only pulling one folder or subrepo of requested theme
  • fixed memory leaks for libgit2
  • build options (bool BUILD_PRESETS string PRESETS_REPO_URL PRESETS_REPO_PATH)
  • code used libgit masked in it option
  • repo configuration file in xml (repo.conf) example in theme-presets-manager.h after advanced_repo_source declaration
  • code in conky code style
  • clang format on my module
  • add loging about long operations (eg pulling ont theme) and theme presets repo that used
  • adding support custom branches in non main repo (in submodules etc)
  • git fetch git clone and another standart (and not standart) methods realised
    thats not all.

@Cetttok
Copy link
Author

Cetttok commented Nov 29, 2025

@Caellian i know that it is opensource (free of all) but will be nice (for me) if you maybe say my Judgment for this

@Cetttok
Copy link
Author

Cetttok commented Dec 30, 2025

apparently, this pull request will soon become last year's 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build system related to build system (CMake) and/or building process/assumptions dependencies adds or removes dependencies, or suggests alternatives feature suggest addition of new functionality that isn't currently supported in any way gh-actions suggest changing GitHub actions sources PR modifies project sources

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants