From 66183209475ef13d9bf479220fb13773130c9a67 Mon Sep 17 00:00:00 2001
From: patrick96
Date: Sun, 24 May 2020 01:29:38 +0200
Subject: [PATCH] actions: Use #name.action[.data] format
This looks a bit nicer than #name#action[.data]
---
src/components/controller.cpp | 12 ++++++------
src/utils/actions.cpp | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/components/controller.cpp b/src/components/controller.cpp
index 8cefd1c8..aa1fcd15 100644
--- a/src/components/controller.cpp
+++ b/src/components/controller.cpp
@@ -402,15 +402,15 @@ void controller::process_inputdata() {
m_log.trace("controller: Processing inputdata: %s", cmd);
/*
- * Module inputs have the following form (w/o the quotes): "#NAME#ACTION[.DATA]"
- * where 'NAME' is the name of the module (for which '#' is a forbidden
+ * Module inputs have the following form (w/o the quotes): "#NAME.ACTION[.DATA]"
+ * where 'NAME' is the name of the module (for which '.' is a forbidden
* character) and 'ACTION' is the input that is sent to the module. 'DATA'
* is optional data that is attached to the action and is also sent to the
* module.
*/
if (cmd.front() == '#') {
- // Find the second delimiter '#'
- auto end_pos = cmd.find('#', 1);
+ // Find the second delimiter '.'
+ auto end_pos = cmd.find('.', 1);
if (end_pos == string::npos) {
m_log.err("Invalid action string (input: %s)", cmd);
@@ -535,9 +535,9 @@ void controller::process_inputdata() {
// TODO make this message more descriptive and maybe link to some documentation
// TODO use route to string methods to print action name that should be used.
if (data.empty()) {
- m_log.warn("The action '%s' is deprecated, use '#%s#%s' instead!", cmd, handler_name, action);
+ m_log.warn("The action '%s' is deprecated, use '#%s.%s' instead!", cmd, handler_name, action);
} else {
- m_log.warn("The action '%s' is deprecated, use '#%s#%s.%s' instead!", cmd, handler_name, action, data);
+ m_log.warn("The action '%s' is deprecated, use '#%s.%s.%s' instead!", cmd, handler_name, action, data);
}
m_log.info("Forwarding legacy action '%s' to module '%s' as '%s' with data '%s'", cmd, handler_name, action, data);
if (!handler_ptr->input(std::forward(action), std::forward(data))) {
diff --git a/src/utils/actions.cpp b/src/utils/actions.cpp
index 51e50935..b0d4ecb7 100644
--- a/src/utils/actions.cpp
+++ b/src/utils/actions.cpp
@@ -6,7 +6,7 @@ POLYBAR_NS
namespace actions_util {
string get_action_string(const modules::input_handler& handler, string action, string data) {
- string str = "#" + handler.input_handler_name() + "#" + action;
+ string str = "#" + handler.input_handler_name() + "." + action;
if (!data.empty()) {
str += "." + data;
}