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 Nov 6, 2024
2 parents 142e780 + c38dc9a commit 2baa809
Show file tree
Hide file tree
Showing 41 changed files with 1,602 additions and 1,253 deletions.
11 changes: 9 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ generate-manpage: doc/rofi.1\
doc/rofi-dmenu.5\
doc/rofi-keys.5\
doc/rofi-script.5\
doc/rofi-theme.5
doc/rofi-theme.5 \
doc/rofi-thumbnails.5

doc/rofi.1: doc/rofi.1.markdown
pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$<
Expand All @@ -204,6 +205,8 @@ doc/rofi-script.5: doc/rofi-script.5.markdown
pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$<
doc/rofi-theme.5: doc/rofi-theme.5.markdown
pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$<
doc/rofi-thumbnails.5: doc/rofi-thumbnails.5.markdown
pandoc --standalone --to=man --lua-filter=$(top_srcdir)/doc/man_filter.lua -f markdown-tex_math_dollars -o ./$@ ./$<

endif

Expand All @@ -217,10 +220,12 @@ dist_man5_MANS=\
doc/rofi-dmenu.5\
doc/rofi-keys.5\
doc/rofi-script.5\
doc/rofi-theme.5
doc/rofi-theme.5\
doc/rofi-thumbnails.5

EXTRA_DIST += \
doc/rofi-theme.5.markdown \
doc/rofi-thumbnails.5.markdown \
doc/rofi-debugging.5.markdown \
doc/rofi-script.5.markdown \
doc/rofi-keys.5.markdown \
Expand Down Expand Up @@ -668,6 +673,7 @@ desktop_DATA=\
data/rofi-theme-selector.desktop

EXTRA_DIST += \
doc/man_filter.lua \
doc/meson.build \
subprojects/libgwater/mpd/meson.build \
subprojects/libgwater/nl/meson.build \
Expand All @@ -692,6 +698,7 @@ EXTRA_DIST += \
subprojects/libgwater/alsa-mixer/libgwater-alsa-mixer.h \
subprojects/libgwater/alsa-mixer/libgwater-alsa-mixer.c \
data/rofi.png\
meson-dist-script \
meson_options.txt \
meson.build

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ For more up to date information, please see the manpages. The other sections and
- [rofi-debugging](doc/rofi-debugging.5.markdown)
- [rofi-script](doc/rofi-script.5.markdown)
- [rofi-theme-selector](doc/rofi-theme-selector.1.markdown)
- [rofi-thumbnails](doc/rofi-thumbnails.5.markdown)
- [rofi-keys](doc/rofi-keys.5.markdown)
- [rofi-dmenu](doc/rofi-dmenu.5.markdown)

Expand Down
5 changes: 4 additions & 1 deletion config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Settings config = {
/** Whether to load and show icons */
.show_icons = FALSE,

/** Custom command to generate preview icons */
.preview_cmd = NULL,

/** Terminal to use. (for ssh and open in terminal) */
.terminal_emulator = "rofi-sensible-terminal",
.ssh_client = "ssh",
Expand Down Expand Up @@ -160,5 +163,5 @@ Settings config = {
/** workaround for broken xserver (#300 on xserver, #611) */
.xserver_i300_workaround = FALSE,
/** What browser to use for completion */
.completer_mode = "recursivebrowser",
.completer_mode = "filebrowser",
};
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ AM_PROG_AR
dnl ---------------------------------------------------------------------
dnl Base CFLAGS
dnl ---------------------------------------------------------------------
AM_CFLAGS="-Wall -Wextra -Wparentheses -Winline -pedantic -Wno-overlength-strings -Wunreachable-code"
AM_CFLAGS="-Wall -Wextra -Wparentheses -Wno-inline -pedantic -Wno-overlength-strings -Wunreachable-code"

dnl ---------------------------------------------------------------------
dnl Enable source code coverage reporting for GCC
Expand Down Expand Up @@ -145,7 +145,7 @@ NK_INIT([bindings xdg-theme])
PKG_CHECK_MODULES([glib], [glib-2.0 >= ${glib_min_version} gio-unix-2.0 gmodule-2.0])
AC_DEFINE_UNQUOTED([GLIB_VERSION_MIN_REQUIRED], [(G_ENCODE_VERSION(${glib_min_major},${glib_min_minor}))], [The lower GLib version supported])
AC_DEFINE_UNQUOTED([GLIB_VERSION_MAX_ALLOWED], [(G_ENCODE_VERSION(${glib_min_major},${glib_min_minor}))], [The highest GLib version supported])
GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon xkbcommon-x11 xcb-ewmh xcb-icccm xcb-cursor xcb-randr xcb-xinerama ])
GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon xkbcommon-x11 xcb-ewmh xcb-icccm xcb-cursor xcb-randr xcb-xinerama xcb-keysyms ])


AC_ARG_ENABLE([imdkit], AS_HELP_STRING([--enable-imdkit], [Build with checks using check library (default: disabled)]))
Expand Down
1 change: 1 addition & 0 deletions doc/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ man_files = [
'rofi-keys.5',
'rofi-script.5',
'rofi-theme.5',
'rofi-thumbnails.5',
]

fs = import('fs')
Expand Down
15 changes: 13 additions & 2 deletions doc/rofi-script.5.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ 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.

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

Expand Down Expand Up @@ -182,11 +184,20 @@ To specify a script there are the following options:
- Specify an absolute path to the script.
- The script is executable and located in your $PATH

Scripts located in the following location are loaded on startup:
Scripts located in the following location are **loaded** on startup
and can be directly launched based on the filename (without extension):

- The script is in `$XDG_CONFIG_PATH/rofi/scripts/`, this is usually
- The script is in `$XDG_CONFIG_HOME/rofi/scripts/`, this is usually
`~/.config/rofi/scripts/`.

If you have a script 'mymode.sh' in this folder you can open it using:

```bash
rofi -show mymode
```

See `rofi -h` output for a list of detected scripts.

## SEE ALSO

rofi(1), rofi-sensible-terminal(1), dmenu(1), rofi-theme(5),
Expand Down
85 changes: 85 additions & 0 deletions doc/rofi-thumbnails.5.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# rofi-thumbnails(5)

## NAME

**rofi-thumbnails** - Rofi thumbnails system

## DESCRIPTION

**rofi** is now able to show thumbnails for all file types where an XDG compatible thumbnailer is present in the system.

This is done by default in filebrowser and recursivebrowser mode, if **rofi** is launched with the `-show-icons` argument.

In a custom user script or dmenu mode, it is possible to produce entry icons using XDG thumbnailers by adding the prefix `thumbnail://` to the filename
specified after `\0icon\x1f`, for example:

```bash
echo -en "EntryName\0icon\x1fthumbnail://path/to/file\n" | rofi -dmenu -show-icons
```

### XDG thumbnailers

XDG thumbnailers are files with a ".thumbnailer" suffix and a structure similar to ".desktop" files for launching applications. They are placed in `/usr/share/thumbnailers/` or `$HOME/.local/share/thumbnailers/`, and contain a list of mimetypes, for which is possible to produce the thumbnail image, and a string with the command to create said image. The example below shows the content of `librsvg.thumbnailer`, a thumbnailer for svg files using librsvg:

```
[Thumbnailer Entry]
TryExec=/usr/bin/gdk-pixbuf-thumbnailer
Exec=/usr/bin/gdk-pixbuf-thumbnailer -s %s %u %o
MimeType=image/svg+xml;image/svg+xml-compressed;
```

The images produced are named as the md5sum of the input files and placed, depending on their size, in the XDG thumbnails directories: `$HOME/.cache/thumbnails/{normal,large,x-large,xx-large}`. They are then loaded by **rofi** as entry icons and can also be used by file managers like Thunar, Caja or KDE Dolphin to show their thumbnails. Additionally, if a thumbnail for a file is found in the thumbnails directories (produced previously by **rofi** or a file manager), **rofi** will load it instead of calling the thumbnailer.

If a suitable thumbnailer for a given file is not found, **rofi** will try to use the corresponding mimetype icon from the icon theme.

### Custom command to create thumbnails

It is possible to use a custom command to generate thumbnails for generic entry names, for example a script that downloads an icon given its url or selects different icons depending on the input. This can be done providing the `-preview-cmd` argument followed by a string with the command to execute, with the following syntax:

```
rofi ... -preview-cmd 'path/to/script_or_cmd "{input}" "{output}" "{size}"'
```

**rofi** will call the script or command substituting `{input}` with the input entry icon name (the string after `\0icon\x1fthumbnail://`), `{output}` with the output filename of the thumbnail and `{size}` with the requested thumbnail size. The script or command is responsible of producing a thumbnail image (if possible respecting the requested size) and saving it in the given `{output}` filename.

### Issues with AppArmor

In Linux distributions using AppArmor (such as Ubuntu and Debian), the default rules shipped can cause issues with thumbnails generation. If that is the case, AppArmor can be disabled by issuing the following commands

```
sudo systemctl stop apparmor
sudo systemctl disable apparmor
```

In alternative, the following apparmor profile con be placed in a file named /etc/apparmor.d/usr.bin.rofi

```
#vim:syntax=apparmor
# AppArmor policy for rofi
#include <tunables/global>
/usr/bin/rofi {
#include <abstractions/base>
# TCP/UDP network access for NFS
network inet stream,
network inet6 stream,
network inet dgram,
network inet6 dgram,
/usr/bin/rofi mr,
@{HOME}/ r,
@{HOME}/** rw,
owner @{HOME}/.cache/thumbnails/** rw,
}
```

then run

```
apparmor_parser -r /etc/apparmor.d/usr.bin.rofi
```

to reload the rule. This assumes that **rofi** binary is in /usr/bin, that is the case of a standard package installation.
6 changes: 6 additions & 0 deletions doc/rofi.1.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ Use Pango markup to format output wherever possible.
Make **rofi** react like a normal application window. Useful for scripts like
Clerk that are basically an application.

`-transient-window`

Make **rofi** react like a modal dialog that is transient to the currently
focused window. Useful when you use a keyboard shortcut to run and show
on the window you are working with.

`-[no-]steal-focus`

Make rofi steal focus on launch and restore close to window that held it when
Expand Down
3 changes: 3 additions & 0 deletions include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ typedef struct {

/** Whether to load and show icons */
gboolean show_icons;

/** Custom command to generate preview icons */
char *preview_cmd;

/** Terminal to use */
char *terminal_emulator;
Expand Down
2 changes: 2 additions & 0 deletions include/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ typedef enum {
MENU_NORMAL_WINDOW = 2,
/** ERROR dialog */
MENU_ERROR_DIALOG = 4,
/** Create transient window. */
MENU_TRANSIENT_WINDOW = 8,
} MenuFlags;

/**
Expand Down
4 changes: 2 additions & 2 deletions include/widgets/icon.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ icon *icon_create(widget *parent, const char *name);
void icon_set_size(widget *icon, const int size);

/**
* @param icon The icon widget handle.
* @param icon_widget The icon widget handle.
* @param surf The surface to display.
*/
void icon_set_surface(icon *icon, cairo_surface_t *surf);
void icon_set_surface(icon *icon_widget, cairo_surface_t *surf);
/**@}*/
#endif // ROFI_ICON_H
11 changes: 10 additions & 1 deletion include/widgets/listview.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,27 @@ typedef void (*listview_selection_changed_callback)(listview *lv,
*/
typedef void (*listview_mouse_activated_cb)(listview *, gboolean, void *);


/**
* Callback when current page is changed.
*/
typedef void (*listview_page_changed_cb)(void);


/**
* @param parent The widget's parent.
* @param name The name of the to be created widget.
* @param cb The update callback.
* @param page_cb The page change callback.
* @param udata The user data to pass to the callback
* @param eh The height of one element
* @param reverse Reverse the listview order.
*
* @returns a new listview
*/
listview *listview_create(widget *parent, const char *name,
listview_update_callback cb, void *udata,
listview_update_callback cb,
listview_page_changed_cb page_cb, void *udata,
unsigned int eh, gboolean reverse);

/**
Expand Down
Loading

0 comments on commit 2baa809

Please sign in to comment.