Add hyprctl animations

This commit is contained in:
vaxerski 2023-01-25 15:16:28 +00:00
parent 12e293e309
commit 9813ba2f56
6 changed files with 80 additions and 11 deletions

View File

@ -341,6 +341,8 @@ int main(int argc, char** argv) {
request(fullRequest);
else if (fullRequest.contains("/cursorpos"))
request(fullRequest);
else if (fullRequest.contains("/animations"))
request(fullRequest);
else if (fullRequest.contains("/switchxkblayout"))
request(fullRequest, 2);
else if (fullRequest.contains("/seterror"))

View File

@ -1704,3 +1704,7 @@ void CConfigManager::addExecRule(const SExecRequestedRule& rule) {
ICustomConfigValueData::~ICustomConfigValueData() {
; // empty
}
std::unordered_map<std::string, SAnimationPropertyConfig> CConfigManager::getAnimationConfig() {
return animationConfig;
}

View File

@ -155,6 +155,8 @@ class CConfigManager {
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
std::unordered_map<std::string, SAnimationPropertyConfig> getAnimationConfig();
// no-op when done.
void dispatchExecOnce();

View File

@ -469,6 +469,59 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) {
return result;
}
std::string animationsRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string ret = "";
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) {
ret += "animations:\n";
for (auto& ac : g_pConfigManager->getAnimationConfig()) {
ret += getFormat("\n\tname: %s\n\t\toverriden: %i\n\t\tbezier: %s\n\t\tenabled: %i\n\t\tspeed: %.2f\n\t\tstyle: %s\n", ac.first.c_str(), (int)ac.second.overriden,
ac.second.internalBezier.c_str(), ac.second.internalEnabled, ac.second.internalSpeed, ac.second.internalStyle.c_str());
}
ret += "beziers:\n";
for (auto& bz : g_pAnimationManager->getAllBeziers()) {
ret += getFormat("\n\tname: %s\n", bz.first.c_str());
}
} else {
// json
ret += "[[";
for (auto& ac : g_pConfigManager->getAnimationConfig()) {
ret += getFormat(R"#(
{
"name": "%s",
"overriden": %s,
"bezier": "%s",
"enabled": %s,
"speed": %.2f,
"style": "%s"
},)#",
ac.first.c_str(), ac.second.overriden ? "true" : "false", ac.second.internalBezier.c_str(), ac.second.internalEnabled ? "true" : "false",
ac.second.internalSpeed, ac.second.internalStyle.c_str());
}
ret[ret.length() - 1] = ']';
ret += ",\n[";
for (auto& bz : g_pAnimationManager->getAllBeziers()) {
ret += getFormat(R"#(
{
"name": "%s"
},)#",
bz.first.c_str());
}
ret.pop_back();
ret += "]";
}
return ret;
}
std::string bindsRequest(HyprCtl::eHyprCtlOutputFormat format) {
std::string ret = "";
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) {
@ -1074,6 +1127,8 @@ std::string getReply(std::string request) {
return cursorPosRequest(format);
else if (request == "binds")
return bindsRequest(format);
else if (request == "animations")
return animationsRequest(format);
else if (request.find("setprop") == 0)
return dispatchSetProp(request);
else if (request.find("seterror") == 0)

View File

@ -464,3 +464,7 @@ CBezierCurve* CAnimationManager::getBezier(const std::string& name) {
return BEZIER == m_mBezierCurves.end() ? &m_mBezierCurves["default"] : &BEZIER->second;
}
std::unordered_map<std::string, CBezierCurve> CAnimationManager::getAllBeziers() {
return m_mBezierCurves;
}

View File

@ -22,6 +22,8 @@ class CAnimationManager {
std::string styleValidInConfigVar(const std::string&, const std::string&);
std::unordered_map<std::string, CBezierCurve> getAllBeziers();
std::list<CAnimatedVariable*> m_lAnimatedVariables;
private: