aboutsummaryrefslogtreecommitdiffstats
path: root/swaynag/config.c
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-11-27 23:27:44 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-11-27 23:34:51 -0500
commit673da8326038e0deb9837fd90d9e02351783b564 (patch)
tree1546629686b2afe4c7dbae18eb4233cbf0f0b4c6 /swaynag/config.c
parentMerge pull request #3175 from emersion/rename-gtk-primary-selection (diff)
downloadsway-673da8326038e0deb9837fd90d9e02351783b564.tar.gz
sway-673da8326038e0deb9837fd90d9e02351783b564.tar.zst
sway-673da8326038e0deb9837fd90d9e02351783b564.zip
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,
52 52
53 static struct option opts[] = { 53 static struct option opts[] = {
54 {"button", required_argument, NULL, 'b'}, 54 {"button", required_argument, NULL, 'b'},
55 {"button-no-terminal", required_argument, NULL, 'B'},
55 {"config", required_argument, NULL, 'c'}, 56 {"config", required_argument, NULL, 'c'},
56 {"debug", no_argument, NULL, 'd'}, 57 {"debug", no_argument, NULL, 'd'},
57 {"edge", required_argument, NULL, 'e'}, 58 {"edge", required_argument, NULL, 'e'},
@@ -86,7 +87,10 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
86 "Usage: swaynag [options...]\n" 87 "Usage: swaynag [options...]\n"
87 "\n" 88 "\n"
88 " -b, --button <text> <action> Create a button with text that " 89 " -b, --button <text> <action> Create a button with text that "
89 "executes action when pressed. Multiple buttons can be defined.\n" 90 "executes action in a terminal when pressed. Multiple buttons can "
91 "be defined.\n"
92 " -B, --button-no-terminal <text> <action> Like --button, but does"
93 "not run the action in a terminal.\n"
90 " -c, --config <path> Path to config file.\n" 94 " -c, --config <path> Path to config file.\n"
91 " -d, --debug Enable debugging.\n" 95 " -d, --debug Enable debugging.\n"
92 " -e, --edge top|bottom Set the edge to use.\n" 96 " -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,
117 121
118 optind = 1; 122 optind = 1;
119 while (1) { 123 while (1) {
120 int c = getopt_long(argc, argv, "b:c:de:f:hlL:m:o:s:t:v", opts, NULL); 124 int c = getopt_long(argc, argv, "b:B:c:de:f:hlL:m:o:s:t:v", opts, NULL);
121 if (c == -1) { 125 if (c == -1) {
122 break; 126 break;
123 } 127 }
124 switch (c) { 128 switch (c) {
125 case 'b': // Button 129 case 'b': // Button
130 case 'B': // Button (No Terminal)
126 if (swaynag) { 131 if (swaynag) {
127 if (optind >= argc) { 132 if (optind >= argc) {
128 fprintf(stderr, "Missing action for button %s\n", optarg); 133 fprintf(stderr, "Missing action for button %s\n", optarg);
@@ -133,6 +138,7 @@ int swaynag_parse_options(int argc, char **argv, struct swaynag *swaynag,
133 button->text = strdup(optarg); 138 button->text = strdup(optarg);
134 button->type = SWAYNAG_ACTION_COMMAND; 139 button->type = SWAYNAG_ACTION_COMMAND;
135 button->action = strdup(argv[optind]); 140 button->action = strdup(argv[optind]);
141 button->terminal = c == 'b';
136 list_add(swaynag->buttons, button); 142 list_add(swaynag->buttons, button);
137 } 143 }
138 optind++; 144 optind++;