From 87c5a35f2d30dbf77929874cf20f7ae6273c54de Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 12 Nov 2026 17:48:05 +0100 Subject: [PATCH 1/3] Start new presentations in the current Omarchy theme Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- src/cli.cpp | 2 +- src/deck.cpp | 30 ++++++++++++++++++++---------- tests/tests.cpp | 14 ++++++++++++++ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index df0a35f..281be31 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Then open **Hype** from the app launcher, or run `hype` in a terminal. ## Make a presentation -Open Hype from your app launcher. It reopens your last presentation; use **Ctrl+N** to start a new one, or **Ctrl+O** to choose a Markdown file. +Open Hype from your app launcher. It reopens your last presentation; use **Ctrl+N** to start a new one in your current Omarchy theme, or **Ctrl+O** to choose a Markdown file. In **Visual** mode, select a slide in the sidebar and write its Markdown below the preview. Changes appear as you type. Drag the divider to give the preview or editor more room. Two buttons in the top bar switch modes. The grid button, or **Ctrl+M**, turns the **Overview** on and off, returning to the mode you came from. The button beside it shows a slide in **Visual** mode and `#` in **Markdown** mode; click it, or press **Ctrl+.**, to switch between them. Markdown mode edits the whole presentation, with the same formatting bar on top. diff --git a/src/cli.cpp b/src/cli.cpp index e9f3a46..67b2b91 100644 --- a/src/cli.cpp +++ b/src/cli.cpp @@ -309,7 +309,7 @@ int exportDeck(const QStringList &arguments) { int create(const QStringList &arguments) { Command command("new", "Start a presentation, with images/ and videos/ beside it."); command.parser.addOption({"title", "Presentation title (default: the file name)", "title"}); - command.parser.addOption({"theme", "Installed theme; see hype themes (default: tokyo-night)", "name"}); + command.parser.addOption({"theme", "Installed theme; see hype themes (default: the current Omarchy theme)", "name"}); command.parser.addOption({"font", "Installed font family (default: JetBrains Mono)", "family"}); command.json(); command.parser.process(arguments); diff --git a/src/deck.cpp b/src/deck.cpp index 8273ac4..26ed6a9 100644 --- a/src/deck.cpp +++ b/src/deck.cpp @@ -161,11 +161,27 @@ static QString slidesError(const ParsedDeck &parsed) { return {}; } // A new presentation, whose headline the window selects so typing replaces it. -static QString starterSource() { return "---\ntheme: tokyo-night\n---\n\n# " + tr("Your next idea") + "\n"; } +// Writes the theme's colors into the header too, so the deck looks the same where the theme isn't installed. +static QString themedHeader(QString header, const QString &name, const QString &colorsPath) { + header = setScalar(header, "theme", name); + header.remove(QRegularExpression("^color_[a-z_]+:[^\\n]*\\n", QRegularExpression::MultilineOption)); + for (const auto &[key, value] : readThemeColors(colorsPath)) + header = setScalar(header, "color_" + key, value); + return header; +} +// A new presentation starts in the desktop's current Omarchy theme. +static QString starterSource(const QMap &themes) { + QFile current(qEnvironmentVariable("XDG_STATE_HOME", QDir::homePath() + "/.local/state") + + "/omarchy/current/theme.name"); + QString name = current.open(QIODevice::ReadOnly) ? QString::fromUtf8(current.readAll()).trimmed() : QString(); + if (!themes.contains(name)) + name = "tokyo-night"; + return themedHeader(QString(), name, themes.value(name)) + "\n# " + tr("Your next idea") + "\n"; +} Deck::Deck(QObject *parent, const QString &exportProgram) : QAbstractListModel(parent), m_exportProgram(exportProgram.isEmpty() ? QCoreApplication::applicationFilePath() : exportProgram) { discoverThemes(); - m_source = starterSource(); + m_source = starterSource(m_themes); m_parsed = parseDeck(m_source); m_saved = m_source; // Writers may truncate, or remove and recreate, the file; read it once they settle. @@ -591,13 +607,7 @@ QColor Deck::background() const { return QColor(palette()["background"].toString QColor Deck::foreground() const { return QColor(palette()["foreground"].toString()); } QColor Deck::accent() const { return QColor(palette()["accent"].toString()); } void Deck::chooseTheme(const QString &name) { - QString header = setScalar(m_parsed.header, "theme", name); - // Remove old palette before reading the newly selected installed theme. - header.remove( - QRegularExpression("^color_[a-z_]+:[^\\n]*\\n", QRegularExpression::MultilineOption)); - for (const auto &[key, value] : readThemeColors(m_themes.value(name))) - header = setScalar(header, "color_" + key, value); - replaceHeader(header); + replaceHeader(themedHeader(m_parsed.header, name, m_themes.value(name))); } QStringList Deck::mediaPositions() const { return ::mediaPositions(); } QVariantMap Deck::media() const { @@ -962,7 +972,7 @@ void Deck::newDeck() { m_path.clear(); m_saved.clear(); m_externalChange = false; - apply(starterSource(), 0); + apply(starterSource(m_themes), 0); m_undo.clear(); m_redo.clear(); watch(); diff --git a/tests/tests.cpp b/tests/tests.cpp index 5a387c3..e0693a9 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -351,6 +351,8 @@ static void write(const QString &path, const QString &content) { void initTestCase() { QVERIFY(settingsDirectory.isValid()); QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, settingsDirectory.path()); + // New decks take the desktop's theme, so keep this machine's theme out of the tests. + qputenv("XDG_STATE_HOME", settingsDirectory.path().toUtf8()); } void portalFileDialogs() { if (!qEnvironmentVariableIsSet("HYPE_PORTAL_TESTS")) @@ -475,6 +477,18 @@ static void write(const QString &path, const QString &content) { QVERIFY(chosen.source().contains("color_background: \"#101020\"")); QVERIFY(chosen.source().contains("color_foreground: \"#eeeeee\"")); QCOMPARE(chosen.accent(), QColor("#7788ff")); + // A new presentation starts in the desktop's current theme. + const QByteArray previousState = qgetenv("XDG_STATE_HOME"); + const auto restoreState = qScopeGuard([&] { + if (previousState.isNull()) qunsetenv("XDG_STATE_HOME"); + else qputenv("XDG_STATE_HOME", previousState); + }); + qputenv("XDG_STATE_HOME", omarchy.path().toUtf8()); + QVERIFY(QDir().mkpath(omarchy.filePath("omarchy/current"))); + write(omarchy.filePath("omarchy/current/theme.name"), "hype-formats\n"); + Deck fresh; + QCOMPARE(fresh.themeName(), QString("hype-formats")); + QVERIFY(fresh.source().contains("color_background: \"#101020\"")); } void followsDesktopTheme() { QTemporaryDir files; From e9179ff9657c9c00b82431b1c8c7b37d72811100 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 12 Nov 2026 18:07:15 +0100 Subject: [PATCH 2/3] Find themes installed since Hype opened for a new deck Co-Authored-By: Claude Opus 5.5 --- src/deck.cpp | 3 +++ tests/tests.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/deck.cpp b/src/deck.cpp index 26ed6a9..833e7c0 100644 --- a/src/deck.cpp +++ b/src/deck.cpp @@ -527,6 +527,7 @@ void Deck::redo() { apply(state.source, state.selected, false, state.anchor, &state.parsed); } void Deck::discoverThemes() { + m_themes.clear(); QString root = qEnvironmentVariable("OMARCHY_PATH", QDir::homePath() + "/.local/share/omarchy"); QStringList roots{root + "/themes", QDir::homePath() + "/omarchy/themes", QDir::homePath() + "/.config/omarchy/themes"}; @@ -969,6 +970,8 @@ bool Deck::saveCopyPath(const QString &path) { void Deck::newDeck() { if (!confirmDiscard()) return; + // The current theme may have been installed since Hype opened. + discoverThemes(); m_path.clear(); m_saved.clear(); m_externalChange = false; diff --git a/tests/tests.cpp b/tests/tests.cpp index e0693a9..8d19b57 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -489,6 +489,13 @@ static void write(const QString &path, const QString &content) { Deck fresh; QCOMPARE(fresh.themeName(), QString("hype-formats")); QVERIFY(fresh.source().contains("color_background: \"#101020\"")); + // A theme installed while Hype is open is found for the next new deck. + QVERIFY(QDir().mkpath(omarchy.filePath("themes/hype-later"))); + write(omarchy.filePath("themes/hype-later/colors.toml"), "background = #203040\n"); + write(omarchy.filePath("omarchy/current/theme.name"), "hype-later\n"); + fresh.newDeck(); + QCOMPARE(fresh.themeName(), QString("hype-later")); + QCOMPARE(fresh.background(), QColor("#203040")); } void followsDesktopTheme() { QTemporaryDir files; From 4c0ccac729fed1e270e183934ab777ccf23e5d8f Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 12 Nov 2026 18:11:18 +0100 Subject: [PATCH 3/3] Refresh the theme picker when new themes are found Co-Authored-By: Claude Opus 5.5 --- src/deck.cpp | 1 + src/deck.h | 3 ++- tests/tests.cpp | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/deck.cpp b/src/deck.cpp index 833e7c0..4702a6e 100644 --- a/src/deck.cpp +++ b/src/deck.cpp @@ -972,6 +972,7 @@ void Deck::newDeck() { return; // The current theme may have been installed since Hype opened. discoverThemes(); + emit themesChanged(); m_path.clear(); m_saved.clear(); m_externalChange = false; diff --git a/src/deck.h b/src/deck.h index 3063b26..9510026 100644 --- a/src/deck.h +++ b/src/deck.h @@ -48,7 +48,7 @@ class Deck : public QAbstractListModel { Q_PROPERTY(bool exportFailed READ exportFailed NOTIFY exportChanged) Q_PROPERTY(QStringList fontNames READ fontNames CONSTANT) Q_PROPERTY(QString fontName READ fontName NOTIFY fontChanged) - Q_PROPERTY(QStringList themeNames READ themeNames CONSTANT) + Q_PROPERTY(QStringList themeNames READ themeNames NOTIFY themesChanged) Q_PROPERTY(QStringList mediaPositions READ mediaPositions CONSTANT) Q_PROPERTY(QString themeName READ themeName NOTIFY changed) Q_PROPERTY(QColor background READ background NOTIFY changed) @@ -148,6 +148,7 @@ class Deck : public QAbstractListModel { Q_INVOKABLE void setMediaSize(double percent); Q_INVOKABLE void setStatus(const QString &status); signals: + void themesChanged(); void changed(); // Document content, path, saved state, or media files; always followed by selectionChanged. void selectionChanged(); // Selection range or the selected slide's content/media. void fontChanged(); diff --git a/tests/tests.cpp b/tests/tests.cpp index 8d19b57..ca7f6a2 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -493,7 +493,10 @@ static void write(const QString &path, const QString &content) { QVERIFY(QDir().mkpath(omarchy.filePath("themes/hype-later"))); write(omarchy.filePath("themes/hype-later/colors.toml"), "background = #203040\n"); write(omarchy.filePath("omarchy/current/theme.name"), "hype-later\n"); + QSignalSpy themes(&fresh, &Deck::themesChanged); fresh.newDeck(); + QCOMPARE(themes.count(), 1); + QVERIFY(fresh.themeNames().contains("hype-later")); QCOMPARE(fresh.themeName(), QString("hype-later")); QCOMPARE(fresh.background(), QColor("#203040")); }