mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-11-16 22:25:59 +01:00
clean old preloads
This commit is contained in:
parent
2c7927aa5a
commit
3de17d1636
4 changed files with 30 additions and 2 deletions
|
@ -36,7 +36,7 @@ execute_process(
|
||||||
#
|
#
|
||||||
|
|
||||||
include_directories(.)
|
include_directories(.)
|
||||||
add_compile_options(-std=c++20 -DWLR_USE_UNSTABLE )
|
add_compile_options(-std=c++23 -DWLR_USE_UNSTABLE )
|
||||||
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing)
|
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
CHyprpaper::CHyprpaper() { }
|
CHyprpaper::CHyprpaper() { }
|
||||||
|
|
||||||
void CHyprpaper::init() {
|
void CHyprpaper::init() {
|
||||||
|
|
||||||
|
removeOldHyprpaperImages();
|
||||||
|
|
||||||
g_pConfigManager = std::make_unique<CConfigManager>();
|
g_pConfigManager = std::make_unique<CConfigManager>();
|
||||||
g_pIPCSocket = std::make_unique<CIPCSocket>();
|
g_pIPCSocket = std::make_unique<CIPCSocket>();
|
||||||
|
|
||||||
|
@ -108,6 +111,30 @@ void CHyprpaper::recheckMonitor(SMonitor* pMonitor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CHyprpaper::removeOldHyprpaperImages() {
|
||||||
|
int cleaned = 0;
|
||||||
|
uint64_t memoryFreed = 0;
|
||||||
|
|
||||||
|
for (const auto& entry : std::filesystem::directory_iterator(std::string(getenv("XDG_RUNTIME_DIR")))) {
|
||||||
|
if (entry.is_directory())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const auto FILENAME = entry.path().filename().string();
|
||||||
|
|
||||||
|
if (FILENAME.contains(".hyprpaper_")) {
|
||||||
|
// unlink it
|
||||||
|
|
||||||
|
memoryFreed += entry.file_size();
|
||||||
|
std::filesystem::remove(FILENAME);
|
||||||
|
cleaned++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cleaned != 0) {
|
||||||
|
Debug::log(LOG, "Cleaned old hyprpaper preloads (%i), removing %.1fMB", cleaned, ((float)memoryFreed) / 1000000.f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SMonitor* CHyprpaper::getMonitorFromName(const std::string& monname) {
|
SMonitor* CHyprpaper::getMonitorFromName(const std::string& monname) {
|
||||||
for (auto& m : m_vMonitors) {
|
for (auto& m : m_vMonitors) {
|
||||||
if (m->name == monname)
|
if (m->name == monname)
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
std::vector<std::unique_ptr<SPoolBuffer>> m_vBuffers;
|
std::vector<std::unique_ptr<SPoolBuffer>> m_vBuffers;
|
||||||
std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
|
std::vector<std::unique_ptr<SMonitor>> m_vMonitors;
|
||||||
|
|
||||||
|
void removeOldHyprpaperImages();
|
||||||
void preloadAllWallpapersFromConfig();
|
void preloadAllWallpapersFromConfig();
|
||||||
void recheckAllMonitors();
|
void recheckAllMonitors();
|
||||||
void ensureMonitorHasActiveWallpaper(SMonitor*);
|
void ensureMonitorHasActiveWallpaper(SMonitor*);
|
||||||
|
|
Loading…
Reference in a new issue