quickshell/src/core/paths.hpp
outfoxxed eabf79ebb6
core/command: allow qs log to retrieve logs of dead instances
If no live instances are found matching the current config, the
youngest dead instance will be used instead.
2025-03-19 15:35:10 -07:00

52 lines
1.3 KiB
C++

#pragma once
#include <qdatetime.h>
#include <qdir.h>
#include <qtypes.h>
#include "instanceinfo.hpp"
struct InstanceLockInfo {
pid_t pid = -1;
InstanceInfo instance;
};
QDataStream& operator<<(QDataStream& stream, const InstanceLockInfo& info);
QDataStream& operator>>(QDataStream& stream, InstanceLockInfo& info);
class QsPaths {
public:
static QsPaths* instance();
static void init(QString shellId, QString pathId);
static QDir crashDir(const QString& id);
static QString basePath(const QString& id);
static QString ipcPath(const QString& id);
static bool
checkLock(const QString& path, InstanceLockInfo* info = nullptr, bool allowDead = false);
static QVector<InstanceLockInfo> collectInstances(const QString& path, bool fallbackDead = false);
QDir* cacheDir();
QDir* baseRunDir();
QDir* shellRunDir();
QDir* instanceRunDir();
void linkRunDir();
void linkPathDir();
void createLock();
private:
enum class DirState : quint8 {
Unknown = 0,
Ready = 1,
Failed = 2,
};
QString shellId;
QString pathId;
QDir mCacheDir;
QDir mBaseRunDir;
QDir mShellRunDir;
QDir mInstanceRunDir;
DirState cacheState = DirState::Unknown;
DirState baseRunState = DirState::Unknown;
DirState shellRunState = DirState::Unknown;
DirState instanceRunState = DirState::Unknown;
};