mirror of https://github.com/ericonr/kanshi.git
Implement SelectProfile in kanshictl.
Rework how varlink_connection_call is called so the logic is used by all methods. Uses method_name as a sign that argv[1] was matched by some known method.
This commit is contained in:
parent
81c330a77f
commit
55a3d3b326
21
ctl.c
21
ctl.c
|
@ -10,10 +10,13 @@
|
|||
|
||||
#include "ipc.h"
|
||||
|
||||
#define PREFIX "fr.emersion.kanshi."
|
||||
|
||||
static void usage(const char *progname) {
|
||||
fprintf(stderr, "Usage: %s [command]\n"
|
||||
"Accepted commands:\n"
|
||||
" reload - reload the config file\n",
|
||||
" reload - reload the config file\n"
|
||||
" set-profile <profile name> - try to apply a named profile\n",
|
||||
progname);
|
||||
}
|
||||
|
||||
|
@ -74,9 +77,22 @@ int main(int argc, char *argv[]) {
|
|||
"Is the kanshi daemon running?\n", address);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const char *method_name = NULL;
|
||||
VarlinkObject *parameter = NULL;
|
||||
if (strcmp(argv[1], "reload") == 0) {
|
||||
method_name = PREFIX "Reload";
|
||||
} else if (strcmp(argv[1], "set-profile") == 0) {
|
||||
if (argc != 3) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
method_name = PREFIX "SetProfile";
|
||||
varlink_object_new(¶meter);
|
||||
varlink_object_set_string(parameter, "profile", argv[2]);
|
||||
}
|
||||
if (method_name) {
|
||||
long result = varlink_connection_call(connection,
|
||||
"fr.emersion.kanshi.Reload", NULL, 0, reload_callback, NULL);
|
||||
method_name, parameter, 0, reload_callback, NULL);
|
||||
if (result != 0) {
|
||||
fprintf(stderr, "varlink_connection_call failed: %s\n",
|
||||
varlink_error_string(-result));
|
||||
|
@ -84,6 +100,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
return wait_for_event(connection);
|
||||
}
|
||||
|
||||
fprintf(stderr, "invalid command: %s\n", argv[1]);
|
||||
usage(argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
|
|
|
@ -17,6 +17,8 @@ kanshictl - control the kanshi daemon remotely
|
|||
|
||||
reload - reload the config file
|
||||
|
||||
set-profile <profile name> - try to apply a named profile
|
||||
|
||||
# AUTHORS
|
||||
|
||||
Maintained by Simon Ser <contact@emersion.fr>, who is assisted by other
|
||||
|
|
Loading…
Reference in New Issue