Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/cli/schema_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,16 @@ namespace noctalia::cli {
{},
false
};
inline constexpr Command wallpaperPrefetch{
"wallpaper-prefetch",
"Prefetch wallpaper into cache",
{},
{},
{},
kMsgWallpaperSetPositionals,
{},
false
};
inline constexpr Command wifiDisable{"wifi-disable", "Disable Wi-Fi", {}, {}, {}, {}, {}, false};
inline constexpr Command wifiEnable{"wifi-enable", "Enable Wi-Fi", {}, {}, {}, {}, {}, false};
inline constexpr Command wifiStatus{"wifi-status", "Print Wi-Fi state", {}, {}, {}, {}, {}, false};
Expand Down Expand Up @@ -913,6 +923,7 @@ namespace noctalia::cli {
msg::wallpaperPrevious,
msg::wallpaperRandom,
msg::wallpaperSet,
msg::wallpaperPrefetch,
msg::wifiDisable,
msg::wifiEnable,
msg::wifiStatus,
Expand Down
29 changes: 29 additions & 0 deletions src/shell/wallpaper/wallpaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,35 @@ void Wallpaper::registerIpc(IpcService& ipc) {
return "ok\n";
}
);
ipc.bind(
noctalia::cli::Command{"wallpaper-prefetch", "Prefetch wallpaper into cache", {}, {}, {}, {}, {}, false},
[this, &ipc](const std::string& args) -> std::string {
if (m_config == nullptr || m_textureCache == nullptr) {
return "error: wallpaper service not initialized\n";
}
const auto tokens = StringUtils::splitWhitespace(StringUtils::trim(args));
if (tokens.empty()) {
return "error: path required\n";
}
const std::optional<std::string_view> callerCwd =
ipc.callerCwd().has_value() ? std::optional<std::string_view>{*ipc.callerCwd()} : std::nullopt;
std::string pathStr = StringUtils::join(tokens, " ");
auto resolved = resolveWallpaperPath(pathStr, callerCwd);
if (!resolved.has_value()) {
return "error: path does not exist or is not a regular file\n";
}
if (m_textureCache->peek(*resolved).id != 0) {
kLog.info("prefetch hit (already cached) {}", *resolved);
return "ok\n";
}
auto handle = m_textureCache->acquire(*resolved);
if (handle.id == 0) {
return "error: failed to prefetch (decode failed)\n";
}
kLog.info("prefetched {}", *resolved);
return "ok\n";
}
);
}

void Wallpaper::syncInstances() {
Expand Down