Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/next' into wayland
Browse files Browse the repository at this point in the history
  • Loading branch information
lbonn committed Feb 13, 2025
2 parents 03a3a58 + 32a0374 commit cebb0fd
Show file tree
Hide file tree
Showing 38 changed files with 733 additions and 215 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -52,6 +52,6 @@ jobs:
cc: gcc

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ if FOUND_PANDOC
generate-manpage: doc/rofi.1\
doc/rofi-sensible-terminal.1\
doc/rofi-theme-selector.1\
doc/rofi-actions.5\
doc/rofi-debugging.5\
doc/rofi-dmenu.5\
doc/rofi-keys.5\
Expand Down
14 changes: 14 additions & 0 deletions config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ Settings config = {
/** Custom command to generate preview icons */
.preview_cmd = NULL,

/** Custom command to call when menu selection changes */
.on_selection_changed = NULL,
/** Custom command to call when menu mode changes */
.on_mode_changed = NULL,
/** Custom command to call when menu entry is accepted */
.on_entry_accepted = NULL,
/** Custom command to call when menu is canceled */
.on_menu_canceled = NULL,
/** Custom command to call when menu finds errors */
.on_menu_error = NULL,
/** Custom command to call when menu screenshot is taken */
.on_screenshot_taken = NULL,
/** Terminal to use. (for ssh and open in terminal) */
.terminal_emulator = "rofi-sensible-terminal",
.ssh_client = "ssh",
Expand Down Expand Up @@ -92,6 +104,8 @@ Settings config = {
.sorting_method = "normal",
/** Case sensitivity of the search */
.case_sensitive = FALSE,
/** Case smart of the search */
.case_smart = FALSE,
/** Cycle through in the element list */
.cycle = TRUE,
/** Height of an element in #chars */
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([rofi], [1.7.8], [https://github.com/davatorium/rofi/],[],[https://github.com/davatorium/rofi/discussions])
AC_INIT([rofi], [1.7.8-dev], [https://github.com/davatorium/rofi/],[],[https://github.com/davatorium/rofi/discussions])

AC_CONFIG_SRCDIR([source/rofi.c])
AC_CONFIG_HEADER([config.h])
Expand Down
13 changes: 10 additions & 3 deletions doc/default_theme.rasi
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,17 @@ textbox-num-sep {
str: "/";
}
inputbar {
padding: 1px ;
spacing: 0px ;
padding: 1px;
spacing: 0px;
text-color: var(normal-foreground);
children: [ prompt,textbox-prompt-colon,entry, num-filtered-rows, textbox-num-sep, num-rows, case-indicator ];
children: [ prompt,textbox-prompt-colon,entry, overlay,num-filtered-rows, textbox-num-sep, num-rows, case-indicator ];
}
overlay {
background-color: var(normal-foreground);
foreground-color: var(normal-background);
text-color: var(normal-background);
padding: 0 0.2em;
margin: 0 0.2em;
}
case-indicator {
spacing: 0;
Expand Down
1 change: 1 addition & 0 deletions doc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ man_files = [
'rofi.1',
'rofi-sensible-terminal.1',
'rofi-theme-selector.1',
'rofi-actions.5',
'rofi-debugging.5',
'rofi-dmenu.5',
'rofi-keys.5',
Expand Down
89 changes: 89 additions & 0 deletions doc/rofi-actions.5.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# rofi-actions(5)

## NAME

**rofi-actions** - Custom commands following interaction with rofi menus

## DESCRIPTION

**rofi** allows to set custom commands or scripts to be executed when some actions are performed in the menu, such as changing selection, accepting an entry or canceling.

This makes it possible for example to play sound effects or read aloud menu entries on selection.

## USAGE

Following is the list of rofi flags for specifying custom commands or scripts to execute on supported actions:

`-on-selection-changed` *cmd*

Command or script to run when the current selection changes. Selected text is forwarded to the command replacing the pattern *{entry}*.

`-on-entry-accepted` *cmd*

Command or script to run when a menu entry is accepted. Accepted text is forwarded to the command replacing the pattern *{entry}*.

`-on-mode-changed` *cmd*

Command or script to run when the menu mode (e.g. drun,window,ssh...) is changed.

`-on-menu-canceled` *cmd*

Command or script to run when the menu is canceled.

`-on-menu-error` *cmd*

Command or script to run when an error menu is shown (e.g. `rofi -e "error message"`). Error text is forwarded to the command replacing the pattern *{error}*.

`-on-screenshot-taken` *cmd*

Command or script to run when a screenshot of rofi is taken. Screenshot path is forwarded to the command replacing the pattern *{path}*.

### Example usage

Rofi command line:

```bash
rofi -on-selection-changed "/path/to/select.sh {entry}" \
-on-entry-accepted "/path/to/accept.sh {entry}" \
-on-menu-canceled "/path/to/exit.sh" \
-on-mode-changed "/path/to/change.sh" \
-on-menu-error "/path/to/error.sh {error}" \
-on-screenshot-taken "/path/to/camera.sh {path}" \
-show drun
```

Rofi config file:

```css
configuration {
on-selection-changed: "/path/to/select.sh {entry}";
on-entry-accepted: "/path/to/accept.sh {entry}";
on-menu-canceled: "/path/to/exit.sh";
on-mode-changed: "/path/to/change.sh";
on-menu-error: "/path/to/error.sh {error}";
on-screenshot-taken: "/path/to/camera.sh {path}";
}
```

### Play sound effects

Here's an example bash script that plays a sound effect using `aplay` when the current selection is changed:

```bash
#!/bin/bash

coproc aplay -q $HOME/Music/selecting_an_item.wav
```

The use of `coproc` for playing sounds is suggested, otherwise the rofi process will wait for sounds to end playback before exiting.

### Read aloud

Here's an example bash script that reads aloud currently selected entries using `espeak`:

```bash
#!/bin/bash

killall espeak
echo "selected: $@" | espeak
```
2 changes: 1 addition & 1 deletion doc/rofi-dmenu.5.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Hide the input text. This should not be considered secure!
`-markup-rows`

Tell **rofi** that DMenu input is Pango markup encoded, and should be rendered.
See [here](https://developer.gnome.org/pygtk/stable/pango-markup-language.html)
See [here](https://docs.gtk.org/Pango/pango_markup.html)
for details about Pango markup.

`-multi-select`
Expand Down
12 changes: 12 additions & 0 deletions doc/rofi-keys.5.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,18 @@ Go down in the entry history.

Default: Control+Down

`kb-matcher-up`

Select the next matcher.

Default: Super+equal

`kb-matcher-down`

Select the previous matcher.

Default: Super+minus

## Mouse Bindings

`ml-row-left`
Expand Down
3 changes: 2 additions & 1 deletion doc/rofi-script.5.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ An integer number with the current state:
- **0**: Initial call of script.
- **1**: Selected an entry.
- **2**: Selected a custom entry.
- **3**: Deleted an entry.
- **10-28**: Custom keybinding 1-19 ( need to be explicitly enabled by script ).

### `ROFI_INFO`
Expand Down Expand Up @@ -109,7 +110,7 @@ The following extra options exists:
- **keep-selection**: If set, the selection is not moved to the first entry,
but the current position is maintained. The filter is cleared.

- **keep-filter**: If set, the filter is not cleared.
- **keep-filter**: If set, the filter is not cleared.

- **new-selection**: If `keep-selection` is set, this allows you to override
the selected entry (absolute position).
Expand Down
12 changes: 12 additions & 0 deletions doc/rofi-theme.5.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,10 @@ The following properties are currently supported:
- **require-input**: boolean Listview requires user input to be unhidden.
The list is still present and hitting accept will activate the first entry.

### Overlay widget

- **timeout**: The time the widget is visible when showing a temporary message.

## Listview widget

The listview widget is special container widget.
Expand Down Expand Up @@ -1658,6 +1662,14 @@ If a filename is provided, it will try to resolve it in the following order:
A name is resolved (if it has no valid extension) as a filename by appending the `.rasi` and the `.rasinc` extension.
It will first look for files with `.rasi`, then for files with `.rasinc`.

If you want to do an optional import, e.g. no error when the file does not exists, you can do:

```css
?import "myfile"
```

This still throws an error on syntax error, but won't abort parsing if file does not exists.

## Examples

Several examples are installed together with **rofi**. These can be found in
Expand Down
9 changes: 9 additions & 0 deletions doc/rofi.1.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ exec command. For that case, `#` can be used as a separator.
Start in case-sensitive mode. This option can be changed at run-time using the
`-kb-toggle-case-sensitivity` key binding.

`-case-smart`

Start in case-smart mode behave like vim's `smartcase`, which determines
case-sensitivity by input. When enabled, this will suppress `-case-sensitive`
config.

`-cycle`

Cycle through the result list. Default is 'true'.
Expand Down Expand Up @@ -355,6 +361,9 @@ Currently, the following methods are supported:

Default: *normal*

Multiple matching methods can be specified in a comma separated list.
The matching up/down keybinding allows cycling through at runtime.

Note: glob matching might be slow for larger lists

`-tokenize`
Expand Down
27 changes: 25 additions & 2 deletions include/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,15 @@ char *rofi_expand_path(const char *input);
* @param needlelen The length of the needle
* @param haystack The string to match against
* @param haystacklen The length of the haystack
* @param case_sensitive Whether case is significant.
*
* UTF-8 aware levenshtein distance calculation
*
* @returns the levenshtein distance between needle and haystack
*/
unsigned int levenshtein(const char *needle, const glong needlelen,
const char *haystack, const glong haystacklen);
const char *haystack, const glong haystacklen,
const int case_sensitive);

/**
* @param data the unvalidated character array holding possible UTF-8 data
Expand Down Expand Up @@ -234,6 +236,7 @@ char *rofi_latin_to_utf8_strdup(const char *input, gssize length);
* @param plen Pattern length.
* @param str The input to match against pattern.
* @param slen Length of str.
* @param case_sensitive Whether case is significant.
*
* rofi_scorer_fuzzy_evaluate implements a global sequence alignment algorithm
* to find the maximum accumulated score by aligning `pattern` to `str`. It
Expand Down Expand Up @@ -263,7 +266,7 @@ char *rofi_latin_to_utf8_strdup(const char *input, gssize length);
* @returns the sorting weight.
*/
int rofi_scorer_fuzzy_evaluate(const char *pattern, glong plen, const char *str,
glong slen);
glong slen, const int case_sensitive);
/*@}*/

/**
Expand Down Expand Up @@ -353,6 +356,13 @@ cairo_surface_t *cairo_image_surface_create_from_svg(const gchar *file,
*/
void parse_ranges(char *input, rofi_range_pair **list, unsigned int *length);

/**
* @param input String to parse
*
* @returns String matching should be case sensitive or insensitive
*/
int parse_case_sensitivity(const char *input);

/**
* @param format The format string used. See below for possible syntax.
* @param string The selected entry.
Expand Down Expand Up @@ -432,6 +442,19 @@ ConfigEntry *rofi_config_find_widget(const char *name, const char *state,
*/
Property *rofi_theme_find_property(ConfigEntry *widget, PropertyType type,
const char *property, gboolean exact);

/**
* @returns get a human readable string with the current matching method.
*/
const char *helper_get_matching_mode_str(void);
/**
* Switch to the next matching method.
*/
void helper_select_next_matching_mode(void);
/**
* Switch to the previous matching method.
*/
void helper_select_previous_matching_mode(void);
G_END_DECLS

/**@} */
Expand Down
2 changes: 2 additions & 0 deletions include/keyb.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ typedef enum {
SELECT_ELEMENT_10,
ENTRY_HISTORY_UP,
ENTRY_HISTORY_DOWN,
MATCHER_UP,
MATCHER_DOWN
} KeyBindingAction;

/**
Expand Down
3 changes: 0 additions & 3 deletions include/mode-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
#include <gmodule.h>
G_BEGIN_DECLS

/** ABI version to check if loaded plugin is compatible. */
#define ABI_VERSION 7u

/**
* Indicator what type of mode this is.
* For now it can be the classic switcher, or also implement a completer.
Expand Down
Loading

0 comments on commit cebb0fd

Please sign in to comment.