Skip to content

Commit 3c087c9

Browse files
authored
finders/desktop: add terminal config option (#133)
* desktop: add terminal config * desktop: fixed naming of terminal executable
1 parent 114828a commit 3c087c9

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

src/config/ConfigManager.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ CConfigManager::CConfigManager() : m_inotifyFd(inotify_init()) {
2626
m_config->addConfigValue("finders:font_prefix", Hyprlang::STRING{"'"});
2727

2828
m_config->addConfigValue("finders:desktop_launch_prefix", Hyprlang::STRING{""});
29+
m_config->addConfigValue("finders:desktop_terminal", Hyprlang::STRING{""});
2930
m_config->addConfigValue("finders:desktop_icons", Hyprlang::INT{1});
3031

3132
m_config->addConfigValue("ui:window_size", Hyprlang::VEC2{400, 260});

src/finders/desktop/DesktopFinder.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,12 @@ class CDesktopEntry : public IFinderResult {
5555

5656
virtual void run() {
5757
static auto PLAUNCHPREFIX = Hyprlang::CSimpleConfigValue<Hyprlang::STRING>(g_configManager->m_config.get(), "finders:desktop_launch_prefix");
58+
static auto PTERMINALEXEC = Hyprlang::CSimpleConfigValue<Hyprlang::STRING>(g_configManager->m_config.get(), "finders:desktop_terminal");
5859
const std::string_view LAUNCH_PREFIX = *PLAUNCHPREFIX;
60+
const std::string_view TERMINAL_EXEC = *PTERMINALEXEC;
5961

60-
auto toExec = std::format("{}{}", LAUNCH_PREFIX.empty() ? std::string{""} : std::string{LAUNCH_PREFIX} + std::string{" "}, m_exec);
62+
auto toExec = std::format("{}{}{}", LAUNCH_PREFIX.empty() ? std::string{""} : std::string{LAUNCH_PREFIX} + std::string{" "},
63+
m_terminal && !TERMINAL_EXEC.empty() ? std::string{TERMINAL_EXEC} + std::string{" "} : std::string{""}, m_exec);
6164

6265
Debug::log(TRACE, "Running {}", toExec);
6366

@@ -82,6 +85,7 @@ class CDesktopEntry : public IFinderResult {
8285
}
8386

8487
std::string m_name, m_exec, m_icon, m_fuzzable, m_stem;
88+
bool m_terminal = false;
8589

8690
uint32_t m_frequency = 0;
8791
};
@@ -241,6 +245,7 @@ void CDesktopFinder::cacheEntry(const std::filesystem::path& path) {
241245
const auto ICON = extract("Icon");
242246
const auto EXEC = extract("Exec");
243247
const auto NODISPLAY = extract("NoDisplay") == "true";
248+
const auto TERMINAL = extract("Terminal") == "true";
244249

245250
if (EXEC.empty() || NAME.empty() || NODISPLAY) {
246251
Debug::log(TRACE, "desktop: skipping entry, empty name / exec / NoDisplay");
@@ -260,6 +265,7 @@ void CDesktopFinder::cacheEntry(const std::filesystem::path& path) {
260265
e->m_name = NAME;
261266
e->m_fuzzable = NAME;
262267
e->m_stem = std::move(pathStem);
268+
e->m_terminal = TERMINAL;
263269
std::ranges::transform(e->m_fuzzable, e->m_fuzzable.begin(), ::tolower);
264270
e->m_frequency = m_entryFrequencyCache->getCachedEntry(e->m_fuzzable);
265271
m_desktopEntryCacheGeneric.emplace_back(e);

0 commit comments

Comments
 (0)