i3-nagbar: add option for button that runs commands without a terminal (#3258)
Fixes #2199.
This commit is contained in:
parent
c583f81c80
commit
dfe89cc4f1
|
@ -147,7 +147,7 @@ bindsym Mod1+Shift+c reload
|
|||
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
|
||||
bindsym Mod1+Shift+r restart
|
||||
# exit i3 (logs you out of your X session)
|
||||
bindsym Mod1+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
|
||||
bindsym Mod1+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"
|
||||
|
||||
# resize window (you can also use the mouse for that)
|
||||
mode "resize" {
|
||||
|
|
|
@ -133,7 +133,7 @@ bindcode $mod+Shift+54 reload
|
|||
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
|
||||
bindcode $mod+Shift+27 restart
|
||||
# exit i3 (logs you out of your X session)
|
||||
bindcode $mod+Shift+26 exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
|
||||
bindcode $mod+Shift+26 exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"
|
||||
|
||||
# resize window (you can also use the mouse for that)
|
||||
mode "resize" {
|
||||
|
|
|
@ -55,6 +55,7 @@ typedef struct {
|
|||
char *action;
|
||||
int16_t x;
|
||||
uint16_t width;
|
||||
bool terminal;
|
||||
} button_t;
|
||||
|
||||
static xcb_window_t win;
|
||||
|
@ -187,7 +188,11 @@ static void handle_button_release(xcb_connection_t *conn, xcb_button_release_eve
|
|||
}
|
||||
|
||||
char *terminal_cmd;
|
||||
if (button->terminal) {
|
||||
sasprintf(&terminal_cmd, "i3-sensible-terminal -e %s", link_path);
|
||||
} else {
|
||||
terminal_cmd = sstrdup(link_path);
|
||||
}
|
||||
printf("argv0 = %s\n", argv0);
|
||||
printf("terminal_cmd = %s\n", terminal_cmd);
|
||||
|
||||
|
@ -361,12 +366,13 @@ int main(int argc, char *argv[]) {
|
|||
{"version", no_argument, 0, 'v'},
|
||||
{"font", required_argument, 0, 'f'},
|
||||
{"button", required_argument, 0, 'b'},
|
||||
{"button-no-terminal", required_argument, 0, 'B'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"message", required_argument, 0, 'm'},
|
||||
{"type", required_argument, 0, 't'},
|
||||
{0, 0, 0, 0}};
|
||||
|
||||
char *options_string = "b:f:m:t:vh";
|
||||
char *options_string = "b:B:f:m:t:vh";
|
||||
|
||||
prompt = i3string_from_utf8("Please do not run this program.");
|
||||
|
||||
|
@ -388,12 +394,14 @@ int main(int argc, char *argv[]) {
|
|||
break;
|
||||
case 'h':
|
||||
printf("i3-nagbar " I3_VERSION "\n");
|
||||
printf("i3-nagbar [-m <message>] [-b <button> <action>] [-t warning|error] [-f <font>] [-v]\n");
|
||||
printf("i3-nagbar [-m <message>] [-b <button> <action>] [-B <button> <action>] [-t warning|error] [-f <font>] [-v]\n");
|
||||
return 0;
|
||||
case 'b':
|
||||
case 'B':
|
||||
buttons = srealloc(buttons, sizeof(button_t) * (buttoncnt + 1));
|
||||
buttons[buttoncnt].label = i3string_from_utf8(optarg);
|
||||
buttons[buttoncnt].action = argv[optind];
|
||||
buttons[buttoncnt].terminal = (o == 'b');
|
||||
printf("button with label *%s* and action *%s*\n",
|
||||
i3string_as_utf8(buttons[buttoncnt].label),
|
||||
buttons[buttoncnt].action);
|
||||
|
|
|
@ -9,7 +9,7 @@ i3-nagbar - displays an error bar on top of your screen
|
|||
|
||||
== SYNOPSIS
|
||||
|
||||
i3-nagbar [-m <message>] [-b <button> <action>] [-t warning|error] [-f <font>] [-v]
|
||||
i3-nagbar [-m <message>] [-b <button> <action>] [-B <button> <action>] [-t warning|error] [-f <font>] [-v]
|
||||
|
||||
== OPTIONS
|
||||
|
||||
|
@ -32,6 +32,12 @@ Select font that is being used.
|
|||
*-b, --button* 'button' 'action'::
|
||||
Create a button with text 'button'. The 'action' are the shell commands that
|
||||
will be executed by this button. Multiple buttons can be defined.
|
||||
Will launch the shell commands inside a terminal emulator, using
|
||||
i3-sensible-terminal.
|
||||
|
||||
*-B, --button-no-terminal* 'button' 'action'::
|
||||
Same as above, but will execute the shell commands directly, without launching a
|
||||
terminal emulator.
|
||||
|
||||
== DESCRIPTION
|
||||
|
||||
|
|
Loading…
Reference in New Issue