aboutsummaryrefslogtreecommitdiff
path: root/swaynag/config.c
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2018-11-27 23:27:44 -0500
committerFurkan Sahin <furkan-dev@proton.me>2018-11-27 23:27:44 -0500
commite7f0d57b0bc909789f2e3b341d0cc338da45c17d (patch)
tree1546629686b2afe4c7dbae18eb4233cbf0f0b4c6 /swaynag/config.c
parent12e7e5c5b3a5d15f2cce95fa3a6b38f3ce416db9 (diff)
Implement swaynag -B/--button-no-terminal
In `i3 4.16`, `i3-nagbar` introduces the flags `-B/--button-no-terminal` to run the action directly instead of inside a terminal. This implements the flags for swaynag for compatibility. Since swaynag does not use an equivalent to `i3-sensible-terminal`, the flags `-b/--button` only uses a terminal when the environment variable `TERMINAL` is set, otherwise it acts the same as these new flags.
Diffstat (limited to 'swaynag/config.c')
-rw-r--r--swaynag/config.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/swaynag/config.c b/swaynag/config.c
index 63808ce4..e724aa0c 100644
--- a/swaynag/config.c
+++ b/swaynag/config.c
@@ -52,6 +52,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
static struct option opts[] = {
{"button", required_argument, NULL, 'b'},
+ {"button-no-terminal", required_argument, NULL, 'B'},
{"config", required_argument, NULL, 'c'},
{"debug", no_argument, NULL, 'd'},
{"edge", required_argument, NULL, 'e'},
@@ -86,7 +87,10 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
"Usage: swaynag [options...]\n"
"\n"
" -b, --button <text> <action> Create a button with text that "
- "executes action when pressed. Multiple buttons can be defined.\n"
+ "executes action in a terminal when pressed. Multiple buttons can "
+ "be defined.\n"
+ " -B, --button-no-terminal <text> <action> Like --button, but does"
+ "not run the action in a terminal.\n"
" -c, --config <path> Path to config file.\n"
" -d, --debug Enable debugging.\n"
" -e, --edge top|bottom Set the edge to use.\n"
@@ -117,12 +121,13 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
optind = 1;
while (1) {
- int c = getopt_long(argc, argv, "b:c:de:f:hlL:m:o:s:t:v", opts, NULL);
+ int c = getopt_long(argc, argv, "b:B:c:de:f:hlL:m:o:s:t:v", opts, NULL);
if (c == -1) {
break;
}
switch (c) {
case 'b': // Button
+ case 'B': // Button (No Terminal)
if (swaynag) {
if (optind >= argc) {
fprintf(stderr, "Missing action for button %s\n", optarg);
@@ -133,6 +138,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
button->text = strdup(optarg);
button->type = SWAYNAG_ACTION_COMMAND;
button->action = strdup(argv[optind]);
+ button->terminal = c == 'b';
list_add(swaynag->buttons, button);
}
optind++;