Skip to content

Commit cebb0fd

Browse files
committed
Merge remote-tracking branch 'upstream/next' into wayland
2 parents 03a3a58 + 32a0374 commit cebb0fd

38 files changed

+733
-215
lines changed

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

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

5454
- name: Perform CodeQL Analysis
55-
uses: github/codeql-action/analyze@v2
55+
uses: github/codeql-action/analyze@v3
5656
with:
5757
category: "/language:${{matrix.language}}"

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ if FOUND_PANDOC
182182
generate-manpage: doc/rofi.1\
183183
doc/rofi-sensible-terminal.1\
184184
doc/rofi-theme-selector.1\
185+
doc/rofi-actions.5\
185186
doc/rofi-debugging.5\
186187
doc/rofi-dmenu.5\
187188
doc/rofi-keys.5\

config/config.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ Settings config = {
4949
/** Custom command to generate preview icons */
5050
.preview_cmd = NULL,
5151

52+
/** Custom command to call when menu selection changes */
53+
.on_selection_changed = NULL,
54+
/** Custom command to call when menu mode changes */
55+
.on_mode_changed = NULL,
56+
/** Custom command to call when menu entry is accepted */
57+
.on_entry_accepted = NULL,
58+
/** Custom command to call when menu is canceled */
59+
.on_menu_canceled = NULL,
60+
/** Custom command to call when menu finds errors */
61+
.on_menu_error = NULL,
62+
/** Custom command to call when menu screenshot is taken */
63+
.on_screenshot_taken = NULL,
5264
/** Terminal to use. (for ssh and open in terminal) */
5365
.terminal_emulator = "rofi-sensible-terminal",
5466
.ssh_client = "ssh",
@@ -92,6 +104,8 @@ Settings config = {
92104
.sorting_method = "normal",
93105
/** Case sensitivity of the search */
94106
.case_sensitive = FALSE,
107+
/** Case smart of the search */
108+
.case_smart = FALSE,
95109
/** Cycle through in the element list */
96110
.cycle = TRUE,
97111
/** Height of an element in #chars */

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([rofi], [1.7.8], [https://github.com/davatorium/rofi/],[],[https://github.com/davatorium/rofi/discussions])
1+
AC_INIT([rofi], [1.7.8-dev], [https://github.com/davatorium/rofi/],[],[https://github.com/davatorium/rofi/discussions])
22

33
AC_CONFIG_SRCDIR([source/rofi.c])
44
AC_CONFIG_HEADER([config.h])

doc/default_theme.rasi

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,17 @@ textbox-num-sep {
141141
str: "/";
142142
}
143143
inputbar {
144-
padding: 1px ;
145-
spacing: 0px ;
144+
padding: 1px;
145+
spacing: 0px;
146146
text-color: var(normal-foreground);
147-
children: [ prompt,textbox-prompt-colon,entry, num-filtered-rows, textbox-num-sep, num-rows, case-indicator ];
147+
children: [ prompt,textbox-prompt-colon,entry, overlay,num-filtered-rows, textbox-num-sep, num-rows, case-indicator ];
148+
}
149+
overlay {
150+
background-color: var(normal-foreground);
151+
foreground-color: var(normal-background);
152+
text-color: var(normal-background);
153+
padding: 0 0.2em;
154+
margin: 0 0.2em;
148155
}
149156
case-indicator {
150157
spacing: 0;

doc/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ man_files = [
22
'rofi.1',
33
'rofi-sensible-terminal.1',
44
'rofi-theme-selector.1',
5+
'rofi-actions.5',
56
'rofi-debugging.5',
67
'rofi-dmenu.5',
78
'rofi-keys.5',

doc/rofi-actions.5.markdown

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# rofi-actions(5)
2+
3+
## NAME
4+
5+
**rofi-actions** - Custom commands following interaction with rofi menus
6+
7+
## DESCRIPTION
8+
9+
**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.
10+
11+
This makes it possible for example to play sound effects or read aloud menu entries on selection.
12+
13+
## USAGE
14+
15+
Following is the list of rofi flags for specifying custom commands or scripts to execute on supported actions:
16+
17+
`-on-selection-changed` *cmd*
18+
19+
Command or script to run when the current selection changes. Selected text is forwarded to the command replacing the pattern *{entry}*.
20+
21+
`-on-entry-accepted` *cmd*
22+
23+
Command or script to run when a menu entry is accepted. Accepted text is forwarded to the command replacing the pattern *{entry}*.
24+
25+
`-on-mode-changed` *cmd*
26+
27+
Command or script to run when the menu mode (e.g. drun,window,ssh...) is changed.
28+
29+
`-on-menu-canceled` *cmd*
30+
31+
Command or script to run when the menu is canceled.
32+
33+
`-on-menu-error` *cmd*
34+
35+
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}*.
36+
37+
`-on-screenshot-taken` *cmd*
38+
39+
Command or script to run when a screenshot of rofi is taken. Screenshot path is forwarded to the command replacing the pattern *{path}*.
40+
41+
### Example usage
42+
43+
Rofi command line:
44+
45+
```bash
46+
rofi -on-selection-changed "/path/to/select.sh {entry}" \
47+
-on-entry-accepted "/path/to/accept.sh {entry}" \
48+
-on-menu-canceled "/path/to/exit.sh" \
49+
-on-mode-changed "/path/to/change.sh" \
50+
-on-menu-error "/path/to/error.sh {error}" \
51+
-on-screenshot-taken "/path/to/camera.sh {path}" \
52+
-show drun
53+
```
54+
55+
Rofi config file:
56+
57+
```css
58+
configuration {
59+
on-selection-changed: "/path/to/select.sh {entry}";
60+
on-entry-accepted: "/path/to/accept.sh {entry}";
61+
on-menu-canceled: "/path/to/exit.sh";
62+
on-mode-changed: "/path/to/change.sh";
63+
on-menu-error: "/path/to/error.sh {error}";
64+
on-screenshot-taken: "/path/to/camera.sh {path}";
65+
}
66+
```
67+
68+
### Play sound effects
69+
70+
Here's an example bash script that plays a sound effect using `aplay` when the current selection is changed:
71+
72+
```bash
73+
#!/bin/bash
74+
75+
coproc aplay -q $HOME/Music/selecting_an_item.wav
76+
```
77+
78+
The use of `coproc` for playing sounds is suggested, otherwise the rofi process will wait for sounds to end playback before exiting.
79+
80+
### Read aloud
81+
82+
Here's an example bash script that reads aloud currently selected entries using `espeak`:
83+
84+
```bash
85+
#!/bin/bash
86+
87+
killall espeak
88+
echo "selected: $@" | espeak
89+
```

doc/rofi-dmenu.5.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Hide the input text. This should not be considered secure!
159159
`-markup-rows`
160160

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

165165
`-multi-select`

doc/rofi-keys.5.markdown

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,18 @@ Go down in the entry history.
495495

496496
Default: Control+Down
497497

498+
`kb-matcher-up`
499+
500+
Select the next matcher.
501+
502+
Default: Super+equal
503+
504+
`kb-matcher-down`
505+
506+
Select the previous matcher.
507+
508+
Default: Super+minus
509+
498510
## Mouse Bindings
499511

500512
`ml-row-left`

doc/rofi-script.5.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ An integer number with the current state:
5959
- **0**: Initial call of script.
6060
- **1**: Selected an entry.
6161
- **2**: Selected a custom entry.
62+
- **3**: Deleted an entry.
6263
- **10-28**: Custom keybinding 1-19 ( need to be explicitly enabled by script ).
6364

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

112-
- **keep-filter**: If set, the filter is not cleared.
113+
- **keep-filter**: If set, the filter is not cleared.
113114

114115
- **new-selection**: If `keep-selection` is set, this allows you to override
115116
the selected entry (absolute position).

doc/rofi-theme.5.markdown

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,10 @@ The following properties are currently supported:
11181118
- **require-input**: boolean Listview requires user input to be unhidden.
11191119
The list is still present and hitting accept will activate the first entry.
11201120

1121+
### Overlay widget
1122+
1123+
- **timeout**: The time the widget is visible when showing a temporary message.
1124+
11211125
## Listview widget
11221126

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

1665+
If you want to do an optional import, e.g. no error when the file does not exists, you can do:
1666+
1667+
```css
1668+
?import "myfile"
1669+
```
1670+
1671+
This still throws an error on syntax error, but won't abort parsing if file does not exists.
1672+
16611673
## Examples
16621674

16631675
Several examples are installed together with **rofi**. These can be found in

doc/rofi.1.markdown

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ exec command. For that case, `#` can be used as a separator.
246246
Start in case-sensitive mode. This option can be changed at run-time using the
247247
`-kb-toggle-case-sensitivity` key binding.
248248

249+
`-case-smart`
250+
251+
Start in case-smart mode behave like vim's `smartcase`, which determines
252+
case-sensitivity by input. When enabled, this will suppress `-case-sensitive`
253+
config.
254+
249255
`-cycle`
250256

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

356362
Default: *normal*
357363

364+
Multiple matching methods can be specified in a comma separated list.
365+
The matching up/down keybinding allows cycling through at runtime.
366+
358367
Note: glob matching might be slow for larger lists
359368

360369
`-tokenize`

include/helper.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,15 @@ char *rofi_expand_path(const char *input);
200200
* @param needlelen The length of the needle
201201
* @param haystack The string to match against
202202
* @param haystacklen The length of the haystack
203+
* @param case_sensitive Whether case is significant.
203204
*
204205
* UTF-8 aware levenshtein distance calculation
205206
*
206207
* @returns the levenshtein distance between needle and haystack
207208
*/
208209
unsigned int levenshtein(const char *needle, const glong needlelen,
209-
const char *haystack, const glong haystacklen);
210+
const char *haystack, const glong haystacklen,
211+
const int case_sensitive);
210212

211213
/**
212214
* @param data the unvalidated character array holding possible UTF-8 data
@@ -234,6 +236,7 @@ char *rofi_latin_to_utf8_strdup(const char *input, gssize length);
234236
* @param plen Pattern length.
235237
* @param str The input to match against pattern.
236238
* @param slen Length of str.
239+
* @param case_sensitive Whether case is significant.
237240
*
238241
* rofi_scorer_fuzzy_evaluate implements a global sequence alignment algorithm
239242
* to find the maximum accumulated score by aligning `pattern` to `str`. It
@@ -263,7 +266,7 @@ char *rofi_latin_to_utf8_strdup(const char *input, gssize length);
263266
* @returns the sorting weight.
264267
*/
265268
int rofi_scorer_fuzzy_evaluate(const char *pattern, glong plen, const char *str,
266-
glong slen);
269+
glong slen, const int case_sensitive);
267270
/*@}*/
268271

269272
/**
@@ -353,6 +356,13 @@ cairo_surface_t *cairo_image_surface_create_from_svg(const gchar *file,
353356
*/
354357
void parse_ranges(char *input, rofi_range_pair **list, unsigned int *length);
355358

359+
/**
360+
* @param input String to parse
361+
*
362+
* @returns String matching should be case sensitive or insensitive
363+
*/
364+
int parse_case_sensitivity(const char *input);
365+
356366
/**
357367
* @param format The format string used. See below for possible syntax.
358368
* @param string The selected entry.
@@ -432,6 +442,19 @@ ConfigEntry *rofi_config_find_widget(const char *name, const char *state,
432442
*/
433443
Property *rofi_theme_find_property(ConfigEntry *widget, PropertyType type,
434444
const char *property, gboolean exact);
445+
446+
/**
447+
* @returns get a human readable string with the current matching method.
448+
*/
449+
const char *helper_get_matching_mode_str(void);
450+
/**
451+
* Switch to the next matching method.
452+
*/
453+
void helper_select_next_matching_mode(void);
454+
/**
455+
* Switch to the previous matching method.
456+
*/
457+
void helper_select_previous_matching_mode(void);
435458
G_END_DECLS
436459

437460
/**@} */

include/keyb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ typedef enum {
145145
SELECT_ELEMENT_10,
146146
ENTRY_HISTORY_UP,
147147
ENTRY_HISTORY_DOWN,
148+
MATCHER_UP,
149+
MATCHER_DOWN
148150
} KeyBindingAction;
149151

150152
/**

include/mode-private.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
#include <gmodule.h>
3232
G_BEGIN_DECLS
3333

34-
/** ABI version to check if loaded plugin is compatible. */
35-
#define ABI_VERSION 7u
36-
3734
/**
3835
* Indicator what type of mode this is.
3936
* For now it can be the classic switcher, or also implement a completer.

0 commit comments

Comments
 (0)