Skip to content
greylocklabsPublic

About

⚙️ shared code, themes and tooling for our apps

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Greylock Labs core

The code, themes and tooling that the Greylock Labs apps share: Callie, Jot and, where it fits, Woodshed. Each app includes core as a git submodule, so a change made here reaches an app only when the app takes a new release of core.

For now core holds the tooling, the themes and the theme engine, the start of the greylock::core C++ library. More of the shared C++, the Greylock.Ui QML module and the shared site files move in next.

What is here

  • CMakeLists.txt and cpp/ build greylock::core, a static Qt 6 library in the greylock:: namespace, with the built-in themes compiled in at :/greylock/themes/<id>.toml. It needs Qt 6.8 or later, with Qt Network, and toml++. It holds:

    • greylock::App and greylock::identity: the app's name, id and folders.
    • The theme engine: greylock::color (OKLCH, contrast and hex parsing), greylock::ThemeSpec, greylock::ThemeLoader and greylock::base16.
    • greylock::ThemeLibrary: the user's own theme files.
    • The desktop session, over D-Bus, for an app that keeps running in the background: greylock::TrayItem (its tray entry, with the menu the app gives it), greylock::FreedesktopNotifications, greylock::SingleInstance (one copy per session, which a second launch brings forward), and greylock::Autostart with greylock::StartAtLogin (start at login, through the Background portal in a Flatpak). They need Qt D-Bus.
    • greylock::desktop::useDesktopFileDialogs(): called first in main, it gives file and folder dialogs the desktop's own chooser, through its portal, with its places and bookmarks.
    • greylock::installTranslations() and cmake/GreylockTranslations.cmake: an app's strings, core's among them, in Qt translation files, with English wording that can be edited apart from the code.
    • greylock::logfile: the app's log file beside the terminal, kept short, with debug messages on request.
    • greylock::problemreport and greylock::issues: "Report a problem", sent to the shared report service or opened as a new issue in the app's repository.
    • greylock::ui, linked apart from greylock::core by apps drawn in Qt Quick: LiveQml serves the app's QML from its source folder and reloads it on every save.
    • The command line, in greylock::cli: Paint and Palette color a terminal's output in the theme, UpdateHint ends a command with a word about a newer release, and Upgrade is an app's upgrade and downgrade commands, installing GitHub's package for this system after checking its checksum.
    • Releases: greylock::ReleaseNotes reads the app's built-in changelog, greylock::releases and greylock::PackageSystem read GitHub's releases and pick this system's package, and greylock::UpdateCheck asks GitHub for the latest release at most once a day.

    Callie and Callie Light are the suite's built-in theme names in every app, and callie is the default theme every other inherits from.

  • android/ builds org.greylocklabs:ui, the Compose library the Android apps share: every built-in theme as Kotlin, generated from themes/ at build time, GreylockTheme to draw an app in one, the fonts, and the components every app uses, such as StickerButton, PillChoice, SwitchRow and EmptyState. It needs JDK 21 and the Android SDK.

  • fonts/ holds Nunito and Fraunces, the suite's fonts, with their SIL Open Font License files.

  • themes/*.toml are the built-in themes every app ships: Callie, Callie Light, Minimal, Minimal Dark, Paper, Tomorrow and Tomorrow Night. callie.toml sets every key, and the others inherit what they leave out.

  • tooling/release.sh, check-version.sh and release-notes.sh release an app: they date the notes in CHANGELOG.md, set the version, run make check, then commit, tag and push, undoing the commit and tag if the push is refused. A Qt app's version is set in CMake, the RPM spec, the Debian changelog and the AppStream metainfo, and its name and id come from its CMakeLists.txt. An Android app's version is its VERSION file, kept within Play's version code, and its name comes from settings.gradle.kts.

  • tooling/release.mk holds the release and release-dry targets. common.mk includes it, and an app without common.mk, such as Woodshed, includes it alone, setting RELEASE_SCOPE if its commits need a scope.

  • tooling/source-tarball.sh writes an app's release tarball with core's buildable files, such as the themes, included at core/, since git archive leaves submodules out.

  • tooling/common.mk holds the everyday make targets: build, run, logs, watch, gallery, screenshots, test, lint, format, check, release and the rest. An app's Makefile sets its own values and includes it.

  • tooling/format.sh formats or checks C++ and QML with clang-format and qmlformat.

  • tooling/commitlint.mjs holds the commit rules; an app passes in its own scopes.

  • tooling/commit-msg runs commitlint as a git hook.

  • The format and lint configs: .clang-format, .clangd, .qmlformat.ini, .qmllint.ini, .editorconfig, .prettierrc, .prettierignore, .markdownlint-cli2.yaml and cliff.toml.

Using it in an app

Add core on its release branch, which only moves when core tags a release:

git submodule add -b release https://github.com/greylocklabs/core core

Then, from the app's root:

  • Add core to the top-level CMakeLists.txt, after the app's warning flags so they apply to core too, saying which app it is built for, and link the targets that use it to greylock::core:

    set(GREYLOCK_APP_ID "org.example.Demo")    # the release build's id; a development build adds .Devel
    set(GREYLOCK_APP_NAME "Demo")
    set(GREYLOCK_APP_DIR "demo")               # the folder under each XDG directory, the package and the resource prefix
    set(GREYLOCK_APP_ENV "DEMO")               # the prefix of environment overrides, such as DEMO_FLATPAK
    set(GREYLOCK_APP_REPO "greylocklabs/demo") # the GitHub repository releases are published to
    set(GREYLOCK_APP_UBUNTU_DEBS OFF)          # Ubuntu takes demo-ubuntu_*.deb, built apart from Debian's demo_*.deb
    set(GREYLOCK_APP_DEVEL OFF)                # a development build, with its own identity
    add_subdirectory(core)
  • Keep the app's strings in translations/<GREYLOCK_APP_DIR>_en.ts, with core's included, by naming the targets whose code has them, and call greylock::installTranslations(app) right after making the application:

    greylock_add_translations(democore SOURCE_TARGETS democore demoui demo-gui)

    make translations reads the strings out of the code again, and the translations_current test fails while a file is stale. Another language is another translations/demo_<language>.ts. The build needs Qt's Linguist tools: qt6-qttools-devel and qt6-linguist on Fedora, qt6-tools-dev and qt6-l10n-tools on Debian.

  • Link each config into the root, where the tools look for it, for example ln -s core/tooling/.clang-format .clang-format, and the hook as ln -s ../core/tooling/commit-msg .githooks/commit-msg.

  • Write commitlint.config.mjs as:

    import { config } from "./core/tooling/commitlint.mjs";
    
    export default config(["core", "gui", "ci", "deps", "deps-dev"]);
  • Write the Makefile as the app's own values followed by include core/tooling/common.mk; the top of common.mk lists the values it reads.

  • Call the scripts from the root, as core/tooling/release.sh minor, from CI.

  • Check out submodules in CI, with submodules: true on actions/checkout, and build the release tarball with core/tooling/source-tarball.sh. Add /core export-ignore to the app's .gitattributes, so the app's own archive leaves the empty submodule folder out; the script adds core's files back.

  • Add a gitsubmodule entry to .github/dependabot.yml, so each core release opens a pull request.

An Android app includes the Compose library from the same submodule, in settings.gradle.kts:

includeBuild("core/android")

and depends on it with implementation("org.greylocklabs:ui"), then wraps its content in GreylockTheme { }.

common.mk also expects dev and ci CMake presets, with a ci workflow and an all_qmllint target, format:md and format:md:check scripts in package.json, a GUI and gallery that take --theme, --screenshot and --live-qml, and a CLI with logs --follow. The top of common.mk lists the same.

The scripts expect the app's files where Callie and Jot keep them: CMakeLists.txt with project(<app> and set(<APP>_APP_ID ...), packaging/rpm/<app>.spec, packaging/debian/control and changelog, data/<app id>.metainfo.xml, and CHANGELOG.md with an ## Unreleased section. An Android app, as Woodshed, needs VERSION, settings.gradle.kts with rootProject.name, and the same CHANGELOG.md.

Developing

npm install
cmake -S . -B build -G Ninja -DGREYLOCK_WERROR=ON && cmake --build build && ctest --test-dir build
tests/release_test.sh   # releases made-up Qt and Android apps to local remotes
tests/tarball_test.sh   # builds a made-up app's release tarball
tests/make_test.sh      # includes common.mk, and release.mk alone, in made-up apps
npm run format:check
(cd android && ./gradlew spotlessCheck :ui:testDebugUnitTest :ui:lintRelease)

Releasing core

Write the notes under ## Unreleased in CHANGELOG.md, then on an up-to-date main run scripts/release.sh 0.2.0. It dates the notes, tags v0.2.0, and moves the release branch to it.

About

⚙️ shared code, themes and tooling for our apps

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages