Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions doc/rofi-theme.5.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,20 @@ icon-paste {
}
```

Alternatively, the property `exec` can be set to be a command such as a program or shell script instead of `action`. The optional property `exit-after-command` (default **false**) can be set so Rofi exits upon completion of that command.

For example, the following configuration would create an icon widget that, when clicked, opens an XTerm session and closes Rofi:

```css
icon-xterm {
expand: false;
filename: "/usr/share/pixmaps/mini.xterm_48x48.xpm";
size: 24;
exec: "xterm";
exit-after-command: true;
}
```

#### button

This is a textbox widget that can have a 'clickable' action. The `action` can
Expand All @@ -1337,6 +1351,18 @@ button-paste {
}
```

As with icon widgets, the button widget can alternatively be set to run a command when clicked with the `exec` property and Rofi can be set to exit upon the command's completion by setting the `exit-after-command` property to **true**.

```css
button-xterm {
expand: false;
content: "Launch XTerm";
vertical-align: 0.5;
exec: "xterm";
exit-after-command: true;
}
```

#### Children

To specify children, set the `children`
Expand Down
12 changes: 11 additions & 1 deletion source/view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,9 @@ WidgetTriggerActionResult textbox_button_trigger_action(
switch (action) {
case MOUSE_CLICK_DOWN: {
const char *type = rofi_theme_get_string(wid, "action", NULL);
const char *command = rofi_theme_get_string(wid, "exec", NULL);
const int exit_after = rofi_theme_get_boolean(wid, "exit-after-command", FALSE);

if (type) {
if (state->list_view) {
(state->selected_line) =
Expand All @@ -1565,6 +1568,12 @@ WidgetTriggerActionResult textbox_button_trigger_action(
}
state->skip_absorb = TRUE;
return WIDGET_TRIGGER_ACTION_RESULT_HANDLED;
} else if (command) {
if (helper_execute_command(NULL, command, FALSE, NULL)) {
if (exit_after) {
rofi_quit_main_loop();
}
}
}
}
case MOUSE_CLICK_UP:
Expand Down Expand Up @@ -1790,7 +1799,8 @@ static void rofi_view_add_widget(RofiViewState *state, widget *parent_widget,
icon *t = icon_create(parent_widget, name);
/* small hack to make it clickable */
const char *type = rofi_theme_get_string(WIDGET(t), "action", NULL);
if (type) {
const char *command = rofi_theme_get_string(WIDGET(t), "exec", NULL);
if (type || command) {
WIDGET(t)->type = WIDGET_TYPE_EDITBOX;
}
box_add((box *)parent_widget, WIDGET(t), TRUE);
Expand Down
Loading