From 72c86b99eb87b23c11fdc795ec6f3668f283b95c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 24 Jun 2022 23:27:02 +0200 Subject: added general:cursor_inactive_timeout --- src/helpers/Timer.cpp | 17 +++++++++++++++++ src/helpers/Timer.hpp | 15 +++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/helpers/Timer.cpp create mode 100644 src/helpers/Timer.hpp (limited to 'src/helpers') diff --git a/src/helpers/Timer.cpp b/src/helpers/Timer.cpp new file mode 100644 index 00000000..33162d30 --- /dev/null +++ b/src/helpers/Timer.cpp @@ -0,0 +1,17 @@ +#include "Timer.hpp" + +void CTimer::reset() { + m_tpLastReset = std::chrono::system_clock::now(); +} + +std::chrono::system_clock::duration CTimer::getDuration() { + return std::chrono::system_clock::now() - m_tpLastReset; +} + +int CTimer::getMillis() { + return std::chrono::duration_cast(getDuration()).count(); +} + +float CTimer::getSeconds() { + return std::chrono::duration_cast(getDuration()).count() / 1000.f; +} \ No newline at end of file diff --git a/src/helpers/Timer.hpp b/src/helpers/Timer.hpp new file mode 100644 index 00000000..2e8d6adc --- /dev/null +++ b/src/helpers/Timer.hpp @@ -0,0 +1,15 @@ +#pragma once + +#include "../defines.hpp" + +class CTimer { +public: + void reset(); + float getSeconds(); + int getMillis(); + +private: + std::chrono::system_clock::time_point m_tpLastReset; + + std::chrono::system_clock::duration getDuration(); +}; \ No newline at end of file -- cgit v1.2.3 From b46f45befab6e2aa6daba76ec04cec4286eec56b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 25 Jun 2022 11:50:09 +0200 Subject: additional keymap reload safety --- src/helpers/WLClasses.hpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/helpers') diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index 2a2d3c93..d6282224 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -71,6 +71,8 @@ struct SKeyboard { bool active = false; + xkb_rule_names currentRules; + // For the list lookup bool operator==(const SKeyboard& rhs) { return keyboard == rhs.keyboard; -- cgit v1.2.3 From 8de8f6667e6a409635c3473824a2e6e0bf70ecf7 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 25 Jun 2022 20:49:06 +0200 Subject: add system info logging --- src/helpers/MiscFunctions.cpp | 32 ++++++++++++++++++++++++++++++++ src/helpers/MiscFunctions.hpp | 2 ++ 2 files changed, 34 insertions(+) (limited to 'src/helpers') diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 55b0ec83..ce9dd788 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -2,6 +2,7 @@ #include "../defines.hpp" #include #include "../Compositor.hpp" +#include void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, std::string ownerString) { ASSERT(pSignal); @@ -232,4 +233,35 @@ float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Ve const float DX = std::max((double)0, std::max(p1.x - vec.x, vec.x - p2.x)); const float DY = std::max((double)0, std::max(p1.y - vec.y, vec.y - p2.y)); return DX * DX + DY * DY; +} + +// Execute a shell command and get the output +std::string execAndGet(const char* cmd) { + std::array buffer; + std::string result; + const std::unique_ptr pipe(popen(cmd, "r"), pclose); + if (!pipe) { + Debug::log(ERR, "execAndGet: failed in pipe"); + return ""; + } + while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) { + result += buffer.data(); + } + return result; +} + +void logSystemInfo() { + struct utsname unameInfo; + + uname(&unameInfo); + + Debug::log(LOG, "System name: %s", unameInfo.sysname); + Debug::log(LOG, "Node name: %s", unameInfo.nodename); + Debug::log(LOG, "Release: %s", unameInfo.release); + Debug::log(LOG, "Version: %s", unameInfo.version); + + // log etc + Debug::log(LOG, "os-release:"); + + Debug::log(NONE, "%s", execAndGet("cat /etc/os-release").c_str()); } \ No newline at end of file diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp index eed3670d..8470eb81 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -11,5 +11,7 @@ bool isNumber(const std::string&); bool isDirection(const std::string&); int getWorkspaceIDFromString(const std::string&, std::string&); float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2); +void logSystemInfo(); +std::string execAndGet(const char*); float getPlusMinusKeywordResult(std::string in, float relative); \ No newline at end of file -- cgit v1.2.3