mirror of
https://github.com/lbonn/rofi
synced 2024-11-12 23:27:15 +00:00
Merge remote-tracking branch 'upstream/next' into wayland
This commit is contained in:
commit
2baa809d8a
41 changed files with 1600 additions and 1251 deletions
11
Makefile.am
11
Makefile.am
|
@ -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 ./$@ ./$<
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 \
|
||||
|
@ -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 \
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
@ -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",
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
@ -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)]))
|
||||
|
|
|
@ -7,6 +7,7 @@ man_files = [
|
|||
'rofi-keys.5',
|
||||
'rofi-script.5',
|
||||
'rofi-theme.5',
|
||||
'rofi-thumbnails.5',
|
||||
]
|
||||
|
||||
fs = import('fs')
|
||||
|
|
|
@ -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).
|
||||
|
||||
|
@ -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),
|
||||
|
|
85
doc/rofi-thumbnails.5.markdown
Normal file
85
doc/rofi-thumbnails.5.markdown
Normal file
|
@ -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.
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -60,6 +60,8 @@ typedef enum {
|
|||
MENU_NORMAL_WINDOW = 2,
|
||||
/** ERROR dialog */
|
||||
MENU_ERROR_DIALOG = 4,
|
||||
/** Create transient window. */
|
||||
MENU_TRANSIENT_WINDOW = 8,
|
||||
} MenuFlags;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -84,10 +84,18 @@ 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.
|
||||
|
@ -95,7 +103,8 @@ typedef void (*listview_mouse_activated_cb)(listview *, gboolean, void *);
|
|||
* @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);
|
||||
|
||||
/**
|
||||
|
|
|
@ -83,7 +83,7 @@ typedef enum {
|
|||
} WidgetTriggerActionResult;
|
||||
|
||||
/**
|
||||
* @param widget The container widget itself
|
||||
* @param wid The container widget itself
|
||||
* @param type The widget type searched for
|
||||
* @param x The X coordination of the mouse event relative to #widget
|
||||
* @param y The Y coordination of the mouse event relative to #widget
|
||||
|
@ -93,11 +93,11 @@ typedef enum {
|
|||
*
|
||||
* @returns A child widget if found, NULL otherwise
|
||||
*/
|
||||
typedef widget *(*widget_find_mouse_target_cb)(widget *widget, WidgetType type,
|
||||
typedef widget *(*widget_find_mouse_target_cb)(widget *wid, WidgetType type,
|
||||
gint x, gint y);
|
||||
|
||||
/**
|
||||
* @param widget The target widget
|
||||
* @param wid The target widget
|
||||
* @param action The action value (which enum it is depends on the widget type)
|
||||
* @param x The X coordination of the mouse event relative to #widget
|
||||
* @param y The Y coordination of the mouse event relative to #widget
|
||||
|
@ -108,7 +108,7 @@ typedef widget *(*widget_find_mouse_target_cb)(widget *widget, WidgetType type,
|
|||
*
|
||||
* @returns Whether the action was handled or not, see enum values for details
|
||||
*/
|
||||
typedef WidgetTriggerActionResult (*widget_trigger_action_cb)(widget *widget,
|
||||
typedef WidgetTriggerActionResult (*widget_trigger_action_cb)(widget *wid,
|
||||
guint action,
|
||||
gint x, gint y,
|
||||
void *user_data);
|
||||
|
@ -117,7 +117,7 @@ typedef WidgetTriggerActionResult (*widget_trigger_action_cb)(widget *widget,
|
|||
#define WIDGET(a) ((widget *)(a))
|
||||
|
||||
/**
|
||||
* @param widget The widget to check
|
||||
* @param wid The widget to check
|
||||
* @param x The X position relative to parent window
|
||||
* @param y the Y position relative to parent window
|
||||
*
|
||||
|
@ -125,65 +125,63 @@ typedef WidgetTriggerActionResult (*widget_trigger_action_cb)(widget *widget,
|
|||
*
|
||||
* @return TRUE if x,y falls within the widget
|
||||
*/
|
||||
int widget_intersect(const widget *widget, int x, int y);
|
||||
int widget_intersect(const widget *wid, int x, int y);
|
||||
|
||||
/**
|
||||
* @param widget The widget to move
|
||||
* @param wid The widget to move
|
||||
* @param x The new X position relative to parent window
|
||||
* @param y The new Y position relative to parent window
|
||||
*
|
||||
* Moves the widget.
|
||||
*/
|
||||
void widget_move(widget *widget, short x, short y);
|
||||
void widget_move(widget *wid, short x, short y);
|
||||
|
||||
/**
|
||||
* @param widget Handle to widget
|
||||
* @param wid Handle to widget
|
||||
* @param type The widget type.
|
||||
*
|
||||
* Set the widget type.
|
||||
*/
|
||||
void widget_set_type(widget *widget, WidgetType type);
|
||||
void widget_set_type(widget *wid, WidgetType type);
|
||||
|
||||
/**
|
||||
* @param widget Handle to widget
|
||||
* @param wid Handle to widget
|
||||
*
|
||||
* Check if widget is enabled.
|
||||
* @returns TRUE when widget is enabled.
|
||||
*/
|
||||
gboolean widget_enabled(widget *widget);
|
||||
gboolean widget_enabled(widget *wid);
|
||||
|
||||
/**
|
||||
* @param widget Handle to widget
|
||||
* @param wid Handle to widget
|
||||
* @param enabled The new state
|
||||
*
|
||||
* Disable the widget.
|
||||
*/
|
||||
void widget_set_enabled(widget *widget, gboolean enabled);
|
||||
void widget_set_enabled(widget *wid, gboolean enabled);
|
||||
|
||||
/**
|
||||
* @param widget Handle to widget
|
||||
* @param wid Handle to widget
|
||||
*
|
||||
* Disable the widget.
|
||||
*/
|
||||
static inline void widget_disable(widget *widget) {
|
||||
widget_set_enabled(widget, FALSE);
|
||||
static inline void widget_disable(widget *wid) {
|
||||
widget_set_enabled(wid, FALSE);
|
||||
}
|
||||
/**
|
||||
* @param widget Handle to widget
|
||||
* @param wid Handle to widget
|
||||
*
|
||||
* Enable the widget.
|
||||
*/
|
||||
static inline void widget_enable(widget *widget) {
|
||||
widget_set_enabled(widget, TRUE);
|
||||
}
|
||||
static inline void widget_enable(widget *wid) { widget_set_enabled(wid, TRUE); }
|
||||
|
||||
/**
|
||||
* @param widget widget Handle to the widget
|
||||
* @param wid widget Handle to the widget
|
||||
* @param d The cairo object used to draw itself.
|
||||
*
|
||||
* Render the textbox.
|
||||
*/
|
||||
void widget_draw(widget *widget, cairo_t *d);
|
||||
void widget_draw(widget *wid, cairo_t *d);
|
||||
|
||||
/**
|
||||
* @param wid Handle to the widget
|
||||
|
@ -193,58 +191,58 @@ void widget_draw(widget *widget, cairo_t *d);
|
|||
void widget_free(widget *wid);
|
||||
|
||||
/**
|
||||
* @param widget The widget toresize
|
||||
* @param wid The widget toresize
|
||||
* @param w The new width
|
||||
* @param h The new height
|
||||
*
|
||||
* Resizes the widget.
|
||||
*/
|
||||
void widget_resize(widget *widget, short w, short h);
|
||||
void widget_resize(widget *wid, short w, short h);
|
||||
|
||||
/**
|
||||
* @param widget The widget handle
|
||||
* @param wid The widget handle
|
||||
*
|
||||
* @returns the height of the widget.
|
||||
*/
|
||||
int widget_get_height(widget *widget);
|
||||
int widget_get_height(widget *wid);
|
||||
|
||||
/**
|
||||
* @param widget The widget handle
|
||||
* @param wid The widget handle
|
||||
*
|
||||
* @returns the width of the widget.
|
||||
*/
|
||||
int widget_get_width(widget *widget);
|
||||
int widget_get_width(widget *wid);
|
||||
|
||||
/**
|
||||
* @param widget The widget handle
|
||||
* @param wid The widget handle
|
||||
*
|
||||
* @returns the y position of the widget relative to its parent.
|
||||
*/
|
||||
int widget_get_y_pos(widget *widget);
|
||||
int widget_get_y_pos(widget *wid);
|
||||
|
||||
/**
|
||||
* @param widget The widget handle
|
||||
* @param wid The widget handle
|
||||
*
|
||||
* @returns the x position of the widget relative to its parent.
|
||||
*/
|
||||
int widget_get_x_pos(widget *widget);
|
||||
int widget_get_x_pos(widget *wid);
|
||||
|
||||
/**
|
||||
* @param widget The widget handle
|
||||
* @param wid The widget handle
|
||||
* @param x A pointer to the absolute X coordinates
|
||||
* @param y A pointer to the absolute Y coordinates
|
||||
*
|
||||
* Will modify param x and param y to make them relative to param widget .
|
||||
* Will modify param x and param y to make them relative to param wid .
|
||||
*/
|
||||
void widget_xy_to_relative(widget *widget, gint *x, gint *y);
|
||||
void widget_xy_to_relative(widget *wid, gint *x, gint *y);
|
||||
|
||||
/**
|
||||
* @param widget The widget handle
|
||||
* @param wid The widget handle
|
||||
*
|
||||
* Update the widget, and its parent recursively.
|
||||
* This should be called when size of widget changes.
|
||||
*/
|
||||
void widget_update(widget *widget);
|
||||
void widget_update(widget *wid);
|
||||
/**
|
||||
* @param wid The widget handle
|
||||
*
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include <libgwater-xcb.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
#include <xcb/xcb_keysyms.h>
|
||||
|
||||
#include <nkutils-bindings.h>
|
||||
|
||||
|
@ -49,6 +50,7 @@ struct _xcb_stuff {
|
|||
#ifdef XCB_IMDKIT
|
||||
xcb_xic_t ic;
|
||||
xcb_xim_t *im;
|
||||
xcb_key_symbols_t *syms;
|
||||
#endif
|
||||
xcb_ewmh_connection_t ewmh;
|
||||
xcb_screen_t *screen;
|
||||
|
|
|
@ -362,13 +362,13 @@ t_entry_list T_CONFIGURATION T_BOPEN t_config_property_list_optional T_BCLOSE {
|
|||
| t_entry_list t_name_prefix_optional t_entry_name_path_selectors T_BOPEN t_property_list_optional T_BCLOSE
|
||||
{
|
||||
for ( GList *liter = g_list_first ( $3); liter; liter = g_list_next ( liter ) ) {
|
||||
ThemeWidget *widget = $1;
|
||||
for ( GList *iter = g_list_first ( (GList*)liter->data ); widget && iter ; iter = g_list_next ( iter ) ) {
|
||||
widget = rofi_theme_find_or_create_name ( widget, iter->data );
|
||||
ThemeWidget *wid = $1;
|
||||
for ( GList *iter = g_list_first ( (GList*)liter->data ); wid && iter ; iter = g_list_next ( iter ) ) {
|
||||
wid = rofi_theme_find_or_create_name ( wid, iter->data );
|
||||
}
|
||||
g_list_free_full ( (GList*)liter->data, g_free );
|
||||
widget->set = TRUE;
|
||||
rofi_theme_widget_add_properties ( widget, $5);
|
||||
wid->set = TRUE;
|
||||
rofi_theme_widget_add_properties ( wid, $5);
|
||||
}
|
||||
if ( $5 ) {
|
||||
g_hash_table_destroy ( $5 );
|
||||
|
@ -376,78 +376,78 @@ t_entry_list T_CONFIGURATION T_BOPEN t_config_property_list_optional T_BCLOSE {
|
|||
g_list_free ( $3 );
|
||||
}
|
||||
| t_entry_list T_PDEFAULTS T_BOPEN t_property_list_optional T_BCLOSE {
|
||||
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, "*" );
|
||||
rofi_theme_widget_add_properties (widget, $4);
|
||||
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, "*" );
|
||||
rofi_theme_widget_add_properties (wid, $4);
|
||||
if ( $4 ) {
|
||||
g_hash_table_destroy ( $4 );
|
||||
}
|
||||
}
|
||||
| t_entry_list T_MEDIA T_PARENT_LEFT T_MEDIA_TYPE T_PSEP t_property_number T_PARENT_RIGHT T_BOPEN t_entry_list T_BCLOSE {
|
||||
gchar *name = g_strdup_printf("@media ( %s: %f )",$4, $6);
|
||||
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name );
|
||||
widget->set = TRUE;
|
||||
widget->media = g_slice_new0(ThemeMedia);
|
||||
widget->media->type = rofi_theme_parse_media_type ( $4 );
|
||||
widget->media->value = $6;
|
||||
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
|
||||
wid->set = TRUE;
|
||||
wid->media = g_slice_new0(ThemeMedia);
|
||||
wid->media->type = rofi_theme_parse_media_type ( $4 );
|
||||
wid->media->value = $6;
|
||||
for ( unsigned int i = 0; i < $9->num_widgets; i++ ) {
|
||||
ThemeWidget *d = $9->widgets[i];
|
||||
rofi_theme_parse_merge_widgets(widget, d);
|
||||
rofi_theme_parse_merge_widgets(wid, d);
|
||||
}
|
||||
g_free ( $4 );
|
||||
g_free ( name );
|
||||
}
|
||||
| t_entry_list T_MEDIA T_PARENT_LEFT T_MEDIA_TYPE T_PSEP T_INT T_UNIT_PX T_PARENT_RIGHT T_BOPEN t_entry_list T_BCLOSE {
|
||||
gchar *name = g_strdup_printf("@media ( %s: %d px )",$4, $6);
|
||||
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name );
|
||||
widget->set = TRUE;
|
||||
widget->media = g_slice_new0(ThemeMedia);
|
||||
widget->media->type = rofi_theme_parse_media_type ( $4 );
|
||||
widget->media->value = (double)$6;
|
||||
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
|
||||
wid->set = TRUE;
|
||||
wid->media = g_slice_new0(ThemeMedia);
|
||||
wid->media->type = rofi_theme_parse_media_type ( $4 );
|
||||
wid->media->value = (double)$6;
|
||||
for ( unsigned int i = 0; i < $10->num_widgets; i++ ) {
|
||||
ThemeWidget *d = $10->widgets[i];
|
||||
rofi_theme_parse_merge_widgets(widget, d);
|
||||
rofi_theme_parse_merge_widgets(wid, d);
|
||||
}
|
||||
g_free ( $4 );
|
||||
g_free ( name );
|
||||
}
|
||||
| t_entry_list T_MEDIA T_PARENT_LEFT T_MEDIA_TYPE T_PSEP T_BOOLEAN T_PARENT_RIGHT T_BOPEN t_entry_list T_BCLOSE {
|
||||
gchar *name = g_strdup_printf("@media ( %s: %s )",$4, $6?"true":"false");
|
||||
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name );
|
||||
widget->set = TRUE;
|
||||
widget->media = g_slice_new0(ThemeMedia);
|
||||
widget->media->type = rofi_theme_parse_media_type ( $4 );
|
||||
widget->media->boolv = $6;
|
||||
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
|
||||
wid->set = TRUE;
|
||||
wid->media = g_slice_new0(ThemeMedia);
|
||||
wid->media->type = rofi_theme_parse_media_type ( $4 );
|
||||
wid->media->boolv = $6;
|
||||
for ( unsigned int i = 0; i < $9->num_widgets; i++ ) {
|
||||
ThemeWidget *d = $9->widgets[i];
|
||||
rofi_theme_parse_merge_widgets(widget, d);
|
||||
rofi_theme_parse_merge_widgets(wid, d);
|
||||
}
|
||||
g_free ( $4 );
|
||||
g_free ( name );
|
||||
}
|
||||
| t_entry_list T_MEDIA T_PARENT_LEFT T_MEDIA_TYPE T_PSEP T_ENV_START T_PARENT_LEFT T_BOOLEAN T_COMMA T_BOOLEAN T_PARENT_RIGHT T_PARENT_RIGHT T_BOPEN t_entry_list T_BCLOSE {
|
||||
gchar *name = g_strdup_printf("@media ( %s: %s )",$4, $8?"true":"false");
|
||||
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name );
|
||||
widget->set = TRUE;
|
||||
widget->media = g_slice_new0(ThemeMedia);
|
||||
widget->media->type = rofi_theme_parse_media_type ( $4 );
|
||||
widget->media->boolv = $8;
|
||||
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
|
||||
wid->set = TRUE;
|
||||
wid->media = g_slice_new0(ThemeMedia);
|
||||
wid->media->type = rofi_theme_parse_media_type ( $4 );
|
||||
wid->media->boolv = $8;
|
||||
for ( unsigned int i = 0; i < $14->num_widgets; i++ ) {
|
||||
ThemeWidget *d = $14->widgets[i];
|
||||
rofi_theme_parse_merge_widgets(widget, d);
|
||||
rofi_theme_parse_merge_widgets(wid, d);
|
||||
}
|
||||
g_free ( $4 );
|
||||
g_free ( name );
|
||||
}
|
||||
| t_entry_list T_MEDIA T_PARENT_LEFT T_MEDIA_TYPE T_PSEP T_ENV_START T_PARENT_LEFT T_COMMA T_BOOLEAN T_PARENT_RIGHT T_PARENT_RIGHT T_BOPEN t_entry_list T_BCLOSE {
|
||||
gchar *name = g_strdup_printf("@media ( %s: %s )",$4, $9?"true":"false");
|
||||
ThemeWidget *widget = rofi_theme_find_or_create_name ( $1, name );
|
||||
widget->set = TRUE;
|
||||
widget->media = g_slice_new0(ThemeMedia);
|
||||
widget->media->type = rofi_theme_parse_media_type ( $4 );
|
||||
widget->media->boolv = $9;
|
||||
ThemeWidget *wid = rofi_theme_find_or_create_name ( $1, name );
|
||||
wid->set = TRUE;
|
||||
wid->media = g_slice_new0(ThemeMedia);
|
||||
wid->media->type = rofi_theme_parse_media_type ( $4 );
|
||||
wid->media->boolv = $9;
|
||||
for ( unsigned int i = 0; i < $13->num_widgets; i++ ) {
|
||||
ThemeWidget *d = $13->widgets[i];
|
||||
rofi_theme_parse_merge_widgets(widget, d);
|
||||
rofi_theme_parse_merge_widgets(wid, d);
|
||||
}
|
||||
g_free ( $4 );
|
||||
g_free ( name );
|
||||
|
@ -487,10 +487,10 @@ t_config_property
|
|||
{
|
||||
|
||||
for ( GList *iter = g_list_first( $1) ; iter; iter = g_list_next(iter)){
|
||||
ThemeWidget *widget = rofi_configuration;
|
||||
widget = rofi_theme_find_or_create_name ( widget, iter->data );
|
||||
widget->set = TRUE;
|
||||
rofi_theme_widget_add_properties ( widget, $3);
|
||||
ThemeWidget *wid = rofi_configuration;
|
||||
wid = rofi_theme_find_or_create_name ( wid, iter->data );
|
||||
wid->set = TRUE;
|
||||
rofi_theme_widget_add_properties ( wid, $3);
|
||||
}
|
||||
if ( $3 ) {
|
||||
g_hash_table_destroy ( $3 );
|
||||
|
|
|
@ -25,7 +25,8 @@ flags = [
|
|||
'-Wunreachable-code',
|
||||
'-Werror=missing-prototypes',
|
||||
'-Wno-overlength-strings',
|
||||
'-Wno-inline' # A bit too noisy with Bison…
|
||||
'-Wno-inline', # A bit too noisy with Bison…
|
||||
'-Wshadow'
|
||||
]
|
||||
foreach f : flags
|
||||
if c_compiler.has_argument(f)
|
||||
|
@ -86,6 +87,7 @@ if xcb_enabled
|
|||
dependency('xcb-randr'),
|
||||
dependency('xcb-cursor'),
|
||||
dependency('xcb-xinerama'),
|
||||
dependency('xcb-keysyms'),
|
||||
dependency('cairo-xcb'),
|
||||
dependency('libstartup-notification-1.0'),
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
option('drun', type: 'boolean', value: true, description: 'Desktop file mode')
|
||||
option('window', type: 'boolean', value: true, description: 'Window switcher mode')
|
||||
option('check', type: 'feature', description: 'Build and run libcheck-based tests')
|
||||
option('imdkit', type: 'boolean', value: true, description: 'IMDKit support')
|
||||
option('wayland', type: 'feature', value: 'enabled', description: 'Build with wayland support')
|
||||
option('xcb', type: 'feature', value: 'enabled', description: 'Build with X11/xcb support')
|
||||
option('imdkit', type: 'boolean', value: false, description: 'IMDKit support')
|
||||
|
|
|
@ -158,6 +158,13 @@ Force **rofi** mode to first read all data from stdin before showing the selecti
|
|||
Note: the default asynchronous mode will also be automatically disabled if used with conflicting options,
|
||||
such as `-dump`, `-only-match` or `-auto-select`.
|
||||
|
||||
`-async-pre-read` *number*
|
||||
|
||||
Reads the first *number* entries blocking, then switches to async mode.
|
||||
This makes it feel more 'snappy'.
|
||||
|
||||
*default*: 25
|
||||
|
||||
`-window-title` *title*
|
||||
|
||||
Set name used for the window title. Will be shown as Rofi - *title*
|
||||
|
@ -170,37 +177,6 @@ Position **rofi** over the window with the given X11 window ID.
|
|||
|
||||
Set ellipsize mode to start. So, the end of the string is visible.
|
||||
|
||||
`-display-columns`
|
||||
|
||||
A comma seperated list of columns to show.
|
||||
|
||||
`-display-column-separator`
|
||||
|
||||
The column separator. This is a regex.
|
||||
|
||||
*default*: '\t'
|
||||
|
||||
`-ballot-selected-str` *string*
|
||||
|
||||
When multi-select is enabled, prefix this string when element is selected.
|
||||
|
||||
*default*: "☑ "
|
||||
|
||||
`-ballot-unselected-str` *string*
|
||||
|
||||
When multi-select is enabled, prefix this string when element is not selected.
|
||||
|
||||
*default*: "☐ "
|
||||
|
||||
`-ellipsize-mode` (start|middle|end)
|
||||
|
||||
Set ellipsize mode on the listview.
|
||||
|
||||
*default* "end"
|
||||
|
||||
## PARSING ROW OPTIONS
|
||||
|
||||
Extra options for individual rows can be also set. See the **rofi-script(5)** manpage for details; the syntax and supported features are identical.
|
||||
|
||||
## RETURN VALUE
|
||||
|
||||
|
@ -211,7 +187,7 @@ Extra options for individual rows can be also set. See the **rofi-script(5)** ma
|
|||
|
||||
## SEE ALSO
|
||||
|
||||
rofi(1), rofi-sensible-terminal(1), dmenu(1), rofi-theme(5), rofi-script(5), rofi-theme-selector(1), ascii(7)
|
||||
rofi(1), rofi-sensible-terminal(1), dmenu(1), rofi-theme(5), rofi-script(5), rofi-theme-selector(1)
|
||||
|
||||
## AUTHOR
|
||||
|
||||
|
|
|
@ -52,15 +52,6 @@ configuration {
|
|||
}
|
||||
```
|
||||
|
||||
## Unsetting a binding
|
||||
|
||||
To unset a binding, pass an empty string.
|
||||
|
||||
```css
|
||||
configuration {
|
||||
kb-clear-line: "";
|
||||
}
|
||||
```
|
||||
|
||||
## Keyboard Bindings
|
||||
|
||||
|
@ -74,12 +65,6 @@ Paste clipboard
|
|||
|
||||
**Default**: Control+v,Insert
|
||||
|
||||
### **kb-secondary-copy**
|
||||
|
||||
Copy current selection to clipboard
|
||||
|
||||
**Default**: Control+c
|
||||
|
||||
### **kb-clear-line**
|
||||
Clear input line
|
||||
|
||||
|
@ -151,12 +136,12 @@ Accept entry
|
|||
**Default**: Control+j,Control+m,Return,KP_Enter
|
||||
|
||||
### **kb-accept-custom**
|
||||
Use entered text as command (in ssh/run modes)
|
||||
Use entered text as command (in ssh/run modi)
|
||||
|
||||
**Default**: Control+Return
|
||||
|
||||
### **kb-accept-custom-alt**
|
||||
Use entered text as command (in ssh/run modes)
|
||||
Use entered text as command (in ssh/run modi)
|
||||
|
||||
**Default**: Control+Shift+Return
|
||||
|
||||
|
@ -198,7 +183,7 @@ Go to the next column
|
|||
### **kb-row-up**
|
||||
Select previous entry
|
||||
|
||||
**Default**: Up,Control+p
|
||||
**Default**: Up,Control+p,ISO_Left_Tab
|
||||
|
||||
### **kb-row-down**
|
||||
Select next entry
|
||||
|
@ -208,17 +193,7 @@ Select next entry
|
|||
### **kb-row-tab**
|
||||
Go to next row, if one left, accept it, if no left next mode.
|
||||
|
||||
**Default**:
|
||||
|
||||
### **kb-element-next**
|
||||
Go to next row.
|
||||
|
||||
**Default**: Tab
|
||||
|
||||
### **kb-element-prev**
|
||||
Go to previous row.
|
||||
|
||||
**Default**: ISO_Left_Tab
|
||||
**Default**: Tab
|
||||
|
||||
### **kb-page-prev**
|
||||
Go to the previous page
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
## NAME
|
||||
|
||||
**rofi script mode** - Rofi format for scriptable mode.
|
||||
**rofi script mode** - Rofi format for scriptable modi.
|
||||
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
**rofi** supports modes that use simple scripts in the background to generate a
|
||||
list and process the result from user actions. This provide a simple interface
|
||||
to make simple extensions to rofi.
|
||||
**rofi** supports modes that use simple scripts in the background to generate a list and process the result from user
|
||||
actions. This provide a simple interface to make simple extensions to rofi.
|
||||
|
||||
|
||||
## USAGE
|
||||
|
@ -19,18 +18,17 @@ To specify a script mode, set a mode with the following syntax: "{name}:{executa
|
|||
For example:
|
||||
|
||||
```
|
||||
rofi -show fb -modes "fb:file_browser.sh"
|
||||
rofi -show fb -modi "fb:file_browser.sh"
|
||||
```
|
||||
|
||||
The name should be unique.
|
||||
|
||||
## API
|
||||
|
||||
Rofi calls the executable without arguments on startup. This should generate a
|
||||
list of options, separated by a newline (`\n`) (This can be changed by the
|
||||
script). If the user selects an option, rofi calls the executable with the text
|
||||
of that option as the first argument. If the script returns no entries, rofi
|
||||
quits.
|
||||
Rofi calls the executable without arguments on startup. This should generate a list of options, separated by a newline
|
||||
(`\n`) (This can be changed by the script).
|
||||
If the user selects an option, rofi calls the executable with the text of that option as the first argument.
|
||||
If the script returns no entries, rofi quits.
|
||||
|
||||
A simple script would be:
|
||||
|
||||
|
@ -65,10 +63,6 @@ An integer number with the current state:
|
|||
|
||||
Environment get set when selected entry get set with the property value of the 'info' row option, if set.
|
||||
|
||||
### `ROFI_DATA`
|
||||
|
||||
Environment get set when script sets `data` option in header.
|
||||
|
||||
## Passing mode options
|
||||
|
||||
Extra options, like setting the prompt, can be set by the script.
|
||||
|
@ -90,10 +84,6 @@ The following extra options exists:
|
|||
* **delim**: Set the delimiter for for next rows. Default is '\n' and this option should finish with this. Only call this on first call of script, it is remembered for consecutive calls.
|
||||
* **no-custom**: If set to 'true'; only accept listed entries, ignore custom input.
|
||||
* **use-hot-keys**: If set to true, it enabled the Custom keybindings for script. Warning this breaks the normal rofi flow.
|
||||
* **keep-selection**: If set, the selection is not moved to the first entry, but the current position is maintained. The filter is cleared.
|
||||
* **new-selection**: If `keep-selection` is set, this allows you to override the selected entry (absolute position).
|
||||
* **data**: Passed data to the next execution of the script via **ROFI_DATA**.
|
||||
* **theme**: Small theme snippet to f.e. change the background color of a widget.
|
||||
|
||||
## Parsing row options
|
||||
|
||||
|
|
|
@ -4,165 +4,19 @@
|
|||
|
||||
**rofi-theme** - Rofi theme format files
|
||||
|
||||
## GETTING STARTED WITH THEMING
|
||||
|
||||
The easiest way to get started theming rofi is by modifying your existing theme.
|
||||
|
||||
Themes can be modified/tweaked by adding theming elements to the end of the
|
||||
config file. The default location of this file is `~/.config/rofi/config.rasi`,
|
||||
if the file does not exists, you can create it.
|
||||
|
||||
A basic config:
|
||||
|
||||
```css
|
||||
configuration {
|
||||
modes: [ combi ];
|
||||
combi-modes: [ window, drun, run ];
|
||||
}
|
||||
|
||||
@theme "gruvbox-light"
|
||||
|
||||
/* Insert theme modifications after this */
|
||||
```
|
||||
|
||||
|
||||
For example if we want to change the `Type to filter` text in the entry box we
|
||||
append the following:
|
||||
|
||||
```css
|
||||
entry {
|
||||
placeholder: "Type here";
|
||||
}
|
||||
```
|
||||
|
||||
In the above section, `entry` indicates the widget, `placeholder` is the
|
||||
property we want to modify and we set it to the string `"Type here"`.
|
||||
To find the commonly available widgets in rofi, see the 'Basic structure' section.
|
||||
|
||||
To change the mouse over cursor to a pointer, add:
|
||||
|
||||
```css
|
||||
entry {
|
||||
placeholder: "Type here";
|
||||
cursor: pointer;
|
||||
}
|
||||
```
|
||||
|
||||
For the next modification, we want to add the icon after each text element and
|
||||
increase the size. First we start by modifying the `element` widget:
|
||||
|
||||
```css
|
||||
|
||||
element {
|
||||
orientation: horizontal;
|
||||
children: [ element-text, element-icon ];
|
||||
spacing: 5px;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Resulting in the following packing:
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ element │
|
||||
│ ┌─────────────────────────────────────────────┐ ┌─────────────────┐ │
|
||||
│ │element─text │ │ element─icon │ │
|
||||
│ └─────────────────────────────────────────────┘ └─────────────────┘ │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
The `element` (container) widget hold each entry in the `listview`, we add the
|
||||
two pre-defined children in the order we want to show. We also specify the
|
||||
packing direction (`orientation`) and the spacing between the children
|
||||
(`spacing`). We specify the space between the two children in absolute pixels
|
||||
(`px`).
|
||||
|
||||
To increase the icon-size, we need to modify the `element-icon` widget.
|
||||
|
||||
```css
|
||||
element-icon {
|
||||
size: 2.5em;
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ element │
|
||||
│ ┌─────────────────────────────────────────────┐ ┌─────────────────┐ │
|
||||
│ │element─text │ │ element │ │
|
||||
│ │ │ │ ─ │ │
|
||||
│ │ │ │ icon │ │
|
||||
│ └─────────────────────────────────────────────┘ └─────────────────┘ │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
In this example we specify the size in the [em](https://www.w3.org/Style/LieBos3e/em) unit.
|
||||
|
||||
Now lets change the text color of both the `entry` and the `element-text` widget to red and background to blue.
|
||||
|
||||
```css
|
||||
entry, element-text {
|
||||
text-color: red;
|
||||
background-color: rgb(0,0,255);
|
||||
}
|
||||
```
|
||||
|
||||
Here we use two different methods of writing down the color, for `text-color`
|
||||
we used a named color, for `background-color` we specify it in `rgb`.
|
||||
We also specify the property for multiple widgets by passing a comma separated
|
||||
list of widget names.
|
||||
|
||||
If you want to center the text relative to the icon, we can set this:
|
||||
|
||||
```css
|
||||
element-text {
|
||||
vertical-align: 0.5;
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ element │
|
||||
│ ┌─────────────────────────────────────────────┐ ┌─────────────────┐ │
|
||||
│ │ │ │ element │ │
|
||||
│ │element-text │ │ ─ │ │
|
||||
│ │ │ │ icon │ │
|
||||
│ └─────────────────────────────────────────────┘ └─────────────────┘ │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
We can also specify the color and width of the cursor. You could, for example,
|
||||
create a crimson block cursor like this:
|
||||
|
||||
```css
|
||||
entry {
|
||||
cursor-color: rgb(220,20,60);
|
||||
cursor-width: 8px;
|
||||
}
|
||||
```
|
||||
|
||||
By default, the `cursor-color` will be the same as the `text-color`. The `cursor-width` will always default to 2 pixels.
|
||||
|
||||
If you want to see the complete theme, including the modification you can run:
|
||||
|
||||
```bash
|
||||
rofi -dump-theme
|
||||
```
|
||||
|
||||
## DEFAULT THEME LOADING
|
||||
|
||||
By default, rofi loads the default theme. This theme is **always** loaded.
|
||||
The default configuration contains:
|
||||
In the default (always loaded) configuration it does:
|
||||
|
||||
```css
|
||||
@theme "default"
|
||||
```
|
||||
|
||||
To unload the default theme, and load another theme, add the `@theme` statement
|
||||
to your `config.rasi` file.
|
||||
To unload the default theme, and load another theme, add `@theme` to your
|
||||
`config.rasi` file.
|
||||
|
||||
If you have a theme loaded via `@theme` or use the default theme, you can tweak
|
||||
If you have a theme loaded by `@theme` or use the default theme, you can tweak
|
||||
it by adding overriding elements at the end of your `config.rasi` file.
|
||||
|
||||
For the difference between `@import` and `@theme` see the `Multiple file
|
||||
|
@ -185,7 +39,7 @@ user-friendly way. Therefore, a new file format has been created, replacing the
|
|||
|
||||
## Encoding
|
||||
|
||||
The encoding of the file is UTF-8. Both unix (`\n`) and windows (`\r\n`) newlines format are supported. But unix is
|
||||
The encoding of the file is utf-8. Both unix (`\n`) and windows (`\r\n`) newlines format are supported. But unix is
|
||||
preferred.
|
||||
|
||||
## Comments
|
||||
|
@ -193,7 +47,7 @@ preferred.
|
|||
C and C++ file comments are supported.
|
||||
|
||||
* Anything after `// ` and before a newline is considered a comment.
|
||||
* Everything between `/*` and `*/` is a comment, this comment can span multiple lines.
|
||||
* Everything between `/*` and `*/` is a comment.
|
||||
|
||||
Comments can be nested and the C comments can be inline.
|
||||
|
||||
|
@ -237,7 +91,7 @@ abbreviation for **r**ofi **a**dvanced **s**tyle **i**nformation.
|
|||
## Basic Structure
|
||||
|
||||
Each element has a section with defined properties. Global properties can be defined in section `* { }`.
|
||||
Sub-section names begin with an optional hash symbol `#`.
|
||||
Sub-section names begin with a hash symbol `#`.
|
||||
|
||||
It is advised to define the *global properties section* on top of the file to
|
||||
make inheritance of properties clearer.
|
||||
|
@ -277,8 +131,8 @@ A theme can have multiple element theme sections.
|
|||
|
||||
The element path can consist of multiple names separated by whitespace or dots.
|
||||
Each element may contain any number of letters, numbers and `-`'s.
|
||||
The first element in the element path can optionally start with a `#` (for
|
||||
historic reasons). Multiple elements can be specified by a `,`.
|
||||
The first element in the element path should always start with a `#`.
|
||||
Multiple elements can be specified by a `,`.
|
||||
|
||||
This is a valid element name:
|
||||
|
||||
|
@ -299,8 +153,8 @@ element normal normal, button {
|
|||
}
|
||||
```
|
||||
|
||||
Each section inherits the global properties. Properties can be explicitly
|
||||
inherited from their parent with the `inherit` keyword.
|
||||
Each section inherits the global properties. Properties can be explicitly inherited from their parent with the
|
||||
`inherit` keyword.
|
||||
In the following example:
|
||||
|
||||
```css
|
||||
|
@ -316,8 +170,7 @@ mainbox {
|
|||
}
|
||||
```
|
||||
|
||||
The element `mainbox` will have the following set of properties (if `mainbox`
|
||||
is a child of `window`):
|
||||
The element `mainbox` will have the following set of properties (if `mainbox` is a child of `window`):
|
||||
|
||||
```css
|
||||
a: 1;
|
||||
|
@ -381,15 +234,7 @@ For example:
|
|||
font: "Awasome 12";
|
||||
```
|
||||
|
||||
The string must be valid UTF-8, special characters can be escaped:
|
||||
|
||||
```css
|
||||
text {
|
||||
content: "Line one\n\tIndented line two";
|
||||
}
|
||||
```
|
||||
|
||||
The following special characters can be escaped: `\b`, `\f`, `\n`, `\r`, `\t`, `\v`, `\` and `"`.
|
||||
The string must be valid UTF-8.
|
||||
|
||||
## Integer
|
||||
|
||||
|
@ -510,18 +355,8 @@ should be applied.
|
|||
|
||||
* `bold`: make the text thicker then the surrounding text.
|
||||
* `italic`: put the highlighted text in script type (slanted).
|
||||
* `underline`: put a line under the text.
|
||||
* `strikethrough`: put a line through the text.
|
||||
|
||||
The following options are available on pango 1.50.0 and up:
|
||||
|
||||
* `uppercase`: Uppercase the text.
|
||||
* `lowercase`: Lowercase the text.
|
||||
|
||||
The following option is disabled as pango crashes on this if there is eel
|
||||
upsizing or wrapping. This will be re-enabled once fixed:
|
||||
|
||||
* `capitalize`: Capitalize the text.
|
||||
* `underline`: put a line under the highlighted text.
|
||||
* `strikethrough`: put a line through the highlighted text.
|
||||
|
||||
## Line style
|
||||
|
||||
|
@ -566,21 +401,17 @@ Rofi supports some maths in calculating sizes. For this it uses the CSS syntax:
|
|||
width: calc( 100% - 37px );
|
||||
```
|
||||
|
||||
```css
|
||||
width: calc( 20% min 512 );
|
||||
```
|
||||
|
||||
It supports the following operations:
|
||||
|
||||
* `+` : Add
|
||||
* `-` : Subtract
|
||||
* `/` : Divide
|
||||
* `*` : Multiply
|
||||
* `%` : Modulo
|
||||
* `min` : Minimum of lvalue or rvalue;
|
||||
* `max` : Maximum of lvalue or rvalue;
|
||||
* `+` : Add
|
||||
* `-` : Subtract
|
||||
* `/` : Divide
|
||||
* `*` : Multiply
|
||||
* `%` : Multiply
|
||||
* `min` : Minimum of l or rvalue;
|
||||
* `max` : Maximum of l or rvalue;
|
||||
* `floor` : Round down lvalue to the next multiple of rvalue
|
||||
* `ceil` : Round up lvalue to the next multiple of rvalue
|
||||
* `ceil` : Round up lvalue to the next multiple of rvalue
|
||||
* `round` : Round lvalue to the next multiple of rvalue
|
||||
|
||||
It uses the C precedence ordering.
|
||||
|
@ -625,28 +456,24 @@ style property.
|
|||
|
||||
Indicate a place on the window/monitor.
|
||||
|
||||
```
|
||||
┌─────────────┬─────────────┬─────────────┐
|
||||
│ north west │ north │ north east │
|
||||
├─────────────┼─────────────┼─────────────┤
|
||||
│ west │ center │ east │
|
||||
├─────────────┼─────────────┼─────────────┤
|
||||
│ south west │ south │ south east │
|
||||
└─────────────┴─────────────┴─────────────┘
|
||||
* Format: `(center|east|north|west|south|north east|north west|south west|south east)`
|
||||
|
||||
```
|
||||
|
||||
* Format: `(center|east|north|west|south|north east|north west|south west|south east)`
|
||||
north west | north | north east
|
||||
-------------|-------------|------------
|
||||
west | center | east
|
||||
-------------|-------------|------------
|
||||
south west | south | south east
|
||||
```
|
||||
|
||||
## Visibility
|
||||
|
||||
It is possible to hide widgets:
|
||||
|
||||
```css
|
||||
inputbar {
|
||||
enabled: false;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Reference
|
||||
|
||||
|
@ -795,8 +622,6 @@ The current widgets available in **rofi**:
|
|||
* `entry`: the main entry @textbox
|
||||
* `num-rows`: Shows the total number of rows.
|
||||
* `num-filtered-rows`: Shows the total number of rows after filtering.
|
||||
* `textbox-current-entry`: Shows the text of the currently selected entry.
|
||||
* `icon-current-entry`: Shows the icon of the currently selected entry.
|
||||
* `listview`: The listview.
|
||||
* `scrollbar`: the listview scrollbar
|
||||
* `element`: a box in the listview holding the entries
|
||||
|
@ -868,22 +693,22 @@ The following properties are currently supported:
|
|||
|
||||
### all widgets:
|
||||
|
||||
* **enabled**: enable/disable rendering of the widget
|
||||
* **padding**: padding
|
||||
* **enabled**: enable/disable the widget
|
||||
* **padding**: padding
|
||||
Padding on the inside of the widget
|
||||
* **margin**: padding
|
||||
* **margin**: padding
|
||||
Margin on the outside of the widget
|
||||
* **border**: border
|
||||
* **border**: border
|
||||
Border around the widget (between padding and margin)/
|
||||
* **border-radius**: padding
|
||||
* **border-radius**: padding
|
||||
Sets a radius on the corners of the borders.
|
||||
* **background-color**: color
|
||||
* **background-color**: color
|
||||
Background color
|
||||
* **background-image**: image
|
||||
* **background-image**: image
|
||||
Background image
|
||||
* **border-color**: color
|
||||
Color of the border
|
||||
* **cursor**: cursor
|
||||
* **cursor**: cursor
|
||||
Type of mouse cursor that is set when the mouse pointer is hovered over the widget.
|
||||
|
||||
### window:
|
||||
|
@ -906,8 +731,8 @@ The following properties are currently supported:
|
|||
Window is fullscreen.
|
||||
* **width**: distance
|
||||
The width of the window
|
||||
* **x-offset**: distance
|
||||
* **y-offset**: distance
|
||||
* **x-offset**: distance
|
||||
* **y-offset**: distance
|
||||
The offset of the window to the anchor point, allowing you to push the window left/right/up/down
|
||||
|
||||
|
||||
|
@ -922,7 +747,7 @@ The following properties are currently supported:
|
|||
|
||||
* **orientation**: orientation
|
||||
Set the direction the elements are packed.
|
||||
* **spacing**: distance
|
||||
* **spacing**: distance
|
||||
Distance between the packed elements.
|
||||
|
||||
### textbox:
|
||||
|
@ -930,18 +755,16 @@ The following properties are currently supported:
|
|||
* **background-color**: color
|
||||
* **border-color**: the color used for the border around the widget.
|
||||
* **font**: the font used by this textbox (string).
|
||||
* **str**/**content**: the string to display by this textbox (string).
|
||||
* **str**: the string to display by this textbox (string).
|
||||
* **vertical-align**: Vertical alignment of the text. A number between 0 (top) and 1 (bottom).
|
||||
* **horizontal-align**: Horizontal alignment of the text. A number between 0 (left) and 1 (right).
|
||||
* **text-color**: the text color to use.
|
||||
* **text-transform**: text style {color} for the whole text.
|
||||
* **highlight**: text style {color}.
|
||||
color is optional, multiple highlight styles can be added like: bold underline italic #000000;
|
||||
This option is only available on the `element-text` widget.
|
||||
* **width**: override the desired width for the textbox.
|
||||
* **content**: Set the displayed text (String).
|
||||
* **placeholder**: Set the displayed text (String) when nothing is entered.
|
||||
* **placeholder-markup**: If true, placeholder text supports pango markup for stylizing.
|
||||
* **placeholder-color**: Color of the placeholder text.
|
||||
* **blink**: Enable/Disable blinking on an input textbox (Boolean).
|
||||
* **markup**: Force markup on, beware that only valid pango markup strings are shown.
|
||||
|
@ -949,14 +772,6 @@ The following properties are currently supported:
|
|||
Set the location of tab stops by their distance from the beginning of the line.
|
||||
Each distance should be greater than the previous one.
|
||||
The text appears to the right of the tab stop position (other alignments are not supported yet).
|
||||
* **cursor-width**: The width of the cursor.
|
||||
* **cursor-color**: The color used to draw the cursor.
|
||||
* **cursor-outline**: Enable a border (outline) around the cursor. (Boolean)
|
||||
* **cursor-outline-width**: The width of the border around the cursor. (Double)
|
||||
* **cursor-outline-color**: The color to use for the cursor outline. (Color)
|
||||
* **text-outline**: Enable a border (outline) around the text. (Boolean)
|
||||
* **text-outline-width**: The width of the border around the text. (Double)
|
||||
* **text-outline-color**: The color to use for the text outline. (Color)
|
||||
|
||||
### listview:
|
||||
* **columns**: integer
|
||||
|
@ -979,13 +794,8 @@ The following properties are currently supported:
|
|||
Indicate how elements are stacked. Horizontal implements the dmenu style.
|
||||
* **reverse**: boolean
|
||||
Reverse the ordering (top down to bottom up).
|
||||
* **flow**: orientation
|
||||
The order the elements are layed out. Vertical is the original 'column' view.
|
||||
* **fixed-columns**: boolean
|
||||
Do not reduce the number of columns shown when number of visible elements is not enough to fill them all.
|
||||
* **require-input**: boolean
|
||||
Listview requires user input to be unhidden. The list is still present and
|
||||
hitting accept will activate the first entry.
|
||||
|
||||
Each element is a `box` called `element`. Each `element` can contain an `element-icon` and `element-text`.
|
||||
|
||||
|
@ -1026,42 +836,42 @@ The box can be vertical or horizontal. This is loosely inspired by [GTK](http://
|
|||
The current layout of **rofi** is structured as follows:
|
||||
|
||||
```
|
||||
┌────────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ window {BOX:vertical} │
|
||||
│ ┌───────────────────────────────────────────────────────────────────────────────┐ │
|
||||
│ │ mainbox {BOX:vertical} │ │
|
||||
│ │ ┌───────────────────────────────────────────────────────────────────────────┐ │ │
|
||||
│ │ │ inputbar {BOX:horizontal} │ │ │
|
||||
│ │ │ ┌─────────┐ ┌─┐ ┌───────────────────────────────┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐ │ │ │
|
||||
│ │ │ │ prompt │ │:│ │ entry │ │#fr│ │ / │ │#ns│ │ci │ │ │ │
|
||||
│ │ │ └─────────┘ └─┘ └───────────────────────────────┘ └───┘ └───┘ └───┘ └───┘ │ │ │
|
||||
│ │ └───────────────────────────────────────────────────────────────────────────┘ │ │
|
||||
│ │ │ │
|
||||
│ │ ┌───────────────────────────────────────────────────────────────────────────┐ │ │
|
||||
│ │ │ message │ │ │
|
||||
│ │ │ ┌───────────────────────────────────────────────────────────────────────┐ │ │ │
|
||||
│ │ │ │ textbox │ │ │ │
|
||||
│ │ │ └───────────────────────────────────────────────────────────────────────┘ │ │ │
|
||||
│ │ └───────────────────────────────────────────────────────────────────────────┘ │ │
|
||||
│ │ │ │
|
||||
│ │ ┌───────────────────────────────────────────────────────────────────────────┐ │ │
|
||||
│ │ │ listview │ │ │
|
||||
│ │ │ ┌─────────────────────────────────────────────────────────────────────┐ │ │ │
|
||||
│ │ │ │ element │ │ │ │
|
||||
│ │ │ │ ┌─────────────────┐ ┌─────────────────────────────────────────────┐ │ │ │ │
|
||||
│ │ │ │ │element─icon │ │element─text │ │ │ │ │
|
||||
│ │ │ │ └─────────────────┘ └─────────────────────────────────────────────┘ │ │ │ │
|
||||
│ │ │ └─────────────────────────────────────────────────────────────────────┘ │ │ │
|
||||
│ │ └───────────────────────────────────────────────────────────────────────────┘ │ │
|
||||
│ │ │ │
|
||||
│ │ ┌───────────────────────────────────────────────────────────────────────────┐ │ │
|
||||
│ │ │ mode─switcher {BOX:horizontal} │ │ │
|
||||
│ │ │ ┌───────────────┐ ┌───────────────┐ ┌──────────────┐ ┌───────────────┐ │ │ │
|
||||
│ │ │ │ Button │ │ Button │ │ Button │ │ Button │ │ │ │
|
||||
│ │ │ └───────────────┘ └───────────────┘ └──────────────┘ └───────────────┘ │ │ │
|
||||
│ │ └───────────────────────────────────────────────────────────────────────────┘ │ │
|
||||
│ └───────────────────────────────────────────────────────────────────────────────┘ │
|
||||
└────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|------------------------------------------------------------------------------------|
|
||||
| window {BOX:vertical} |
|
||||
| |-------------------------------------------------------------------------------| |
|
||||
| | mainbox {BOX:vertical} | |
|
||||
| | |---------------------------------------------------------------------------| | |
|
||||
| | | inputbar {BOX:horizontal} | | |
|
||||
| | | |---------| |-| |---------------------------------|---| |---| |---| |---| | | |
|
||||
| | | | prompt | |:| | entry |#fr| | / | |#ns| |ci | | | |
|
||||
| | | |---------| |_| |---------------------------------|---| |---| |---| |---| | | |
|
||||
| | |---------------------------------------------------------------------------| | |
|
||||
| | | |
|
||||
| | |---------------------------------------------------------------------------| | |
|
||||
| | | message | | |
|
||||
| | | |-----------------------------------------------------------------------| | | |
|
||||
| | | | textbox | | | |
|
||||
| | | |-----------------------------------------------------------------------| | | |
|
||||
| | |---------------------------------------------------------------------------| | |
|
||||
| | | |
|
||||
| | |-----------------------------------------------------------------------------| |
|
||||
| | | listview | |
|
||||
| | | |------------------------------------------------------------------------] | |
|
||||
| | | | element | | |
|
||||
| | | | |-----------------| |------------------------------------------------] | | |
|
||||
| | | | |element-icon | |element-text | | | |
|
||||
| | | | |-----------------| |------------------------------------------------| | | |
|
||||
| | | |------------------------------------------------------------------------] | |
|
||||
| | |-----------------------------------------------------------------------------| |
|
||||
| | | |
|
||||
| | |---------------------------------------------------------------------------| | |
|
||||
| | | mode-switcher {BOX:horizontal} | | |
|
||||
| | | |---------------| |---------------| |--------------| |---------------| | | |
|
||||
| | | | Button | | Button | | Button | | Button | | | |
|
||||
| | | |---------------| |---------------| |--------------| |---------------| | | |
|
||||
| | |---------------------------------------------------------------------------| | |
|
||||
| |-------------------------------------------------------------------------------| |
|
||||
|------------------------------------------------------------------------------------|
|
||||
|
||||
|
||||
```
|
||||
|
@ -1072,15 +882,16 @@ The current layout of **rofi** is structured as follows:
|
|||
### Error message structure
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────────────────────────┐
|
||||
│ window {BOX:vertical} │
|
||||
│ ┌─────────────────────────────────────────────────────────────────────────────┐ │
|
||||
│ │ error─message {BOX:vertical} │ │
|
||||
│ │ ┌────────────────────────────────────────────────────────────────────────┐ │ │
|
||||
│ │ │ textbox │ │ │
|
||||
│ │ └────────────────────────────────────────────────────────────────────────┘ │ │
|
||||
│ └─────────────────────────────────────────────────────────────────────────────┘ │
|
||||
└──────────────────────────────────────────────────────────────────────────────────┘
|
||||
|-----------------------------------------------------------------------------------|
|
||||
| window {BOX:vertical} |
|
||||
| |------------------------------------------------------------------------------| |
|
||||
| | error-message {BOX:vertical} | |
|
||||
| | |-------------------------------------------------------------------------| | |
|
||||
| | | textbox | | |
|
||||
| | |-------------------------------------------------------------------------| | |
|
||||
| |------------------------------------------------------------------------------| |
|
||||
|-----------------------------------------------------------------------------------|
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
@ -1224,18 +1035,18 @@ element selected {
|
|||
Just like CSS, **rofi** uses the box model for each widget.
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────────┐
|
||||
│ margin │
|
||||
│ ┌────────────────────────────────────────────────────────────┐ │
|
||||
│ │ border │ │
|
||||
│ │ ┌────────────────────────────────────────────────────────┐ │ │
|
||||
│ │ │ padding │ │ │
|
||||
│ │ │ ┌────────────────────────────────────────────────────┐ │ │ │
|
||||
│ │ │ │ content │ │ │ │
|
||||
│ │ │ └────────────────────────────────────────────────────┘ │ │ │
|
||||
│ │ └────────────────────────────────────────────────────────┘ │ │
|
||||
│ └────────────────────────────────────────────────────────────┘ │
|
||||
└──────────────────────────────────────────────────────────────────┘
|
||||
|-------------------------------------------------------------------|
|
||||
| margin |
|
||||
| |-------------------------------------------------------------| |
|
||||
| | border | |
|
||||
| | |---------------------------------------------------------| | |
|
||||
| | | padding | | |
|
||||
| | | |-----------------------------------------------------| | | |
|
||||
| | | | content | | | |
|
||||
| | | |-----------------------------------------------------| | | |
|
||||
| | |---------------------------------------------------------| | |
|
||||
| |-------------------------------------------------------------| |
|
||||
|-------------------------------------------------------------------|
|
||||
```
|
||||
|
||||
Explanation of the different parts:
|
||||
|
@ -1259,15 +1070,15 @@ Widgets that can pack more then one child widget (currently box and listview) ha
|
|||
This property sets the distance between the packed widgets (both horizontally and vertically).
|
||||
|
||||
```
|
||||
┌───────────────────────────────────────┐
|
||||
│ ┌────────┐ s ┌────────┐ s ┌────────┐ │
|
||||
│ │ child │ p │ child │ p │ child │ │
|
||||
│ │ │ a │ │ a │ │ │
|
||||
│ │ │ c │ │ c │ │ │
|
||||
│ │ │ i │ │ i │ │ │
|
||||
│ │ │ n │ │ n │ │ │
|
||||
│ └────────┘ g └────────┘ g └────────┘ │
|
||||
└───────────────────────────────────────┘
|
||||
|---------------------------------------|
|
||||
| |--------| s |--------| s |-------| |
|
||||
| | child | p | child | p | child | |
|
||||
| | | a | | a | | |
|
||||
| | | c | | c | | |
|
||||
| | | i | | i | | |
|
||||
| | | n | | n | | |
|
||||
| |--------| g |--------| g |-------| |
|
||||
|---------------------------------------|
|
||||
```
|
||||
|
||||
### Advanced box packing
|
||||
|
@ -1275,15 +1086,15 @@ This property sets the distance between the packed widgets (both horizontally an
|
|||
More dynamic spacing can be achieved by adding dummy widgets, for example to make one widget centered:
|
||||
|
||||
```
|
||||
┌────────────────────────────────────────────────────┐
|
||||
│ ┌───────────────┐ ┌────────┐ ┌───────────────┐ │
|
||||
│ │ dummy │ │ child │ │ dummy │ │
|
||||
│ │ expand: true; │ │ │ │ expand: true; │ │
|
||||
│ │ │ │ │ │ │ │
|
||||
│ │ │ │ │ │ │ │
|
||||
│ │ │ │ │ │ │ │
|
||||
│ └───────────────┘ └────────┘ └───────────────┘ │
|
||||
└────────────────────────────────────────────────────┘
|
||||
|----------------------------------------------------|
|
||||
| |---------------| |--------| |---------------| |
|
||||
| | dummy | | child | | dummy | |
|
||||
| | expand: true; | | | | expand: true; | |
|
||||
| | | | | | | |
|
||||
| | | | | | | |
|
||||
| | | | | | | |
|
||||
| |---------------| |--------| |---------------| |
|
||||
|----------------------------------------------------|
|
||||
```
|
||||
|
||||
If both dummy widgets are set to expand, `child` will be centered. Depending on the `expand` flag of child the
|
||||
|
@ -1343,7 +1154,6 @@ It supports the following keys as constraint:
|
|||
* `min-aspect-ratio` load when aspect ratio is over value.
|
||||
* `max-aspect-ratio`: load when aspect ratio is under value.
|
||||
* `monitor-id`: The monitor id, see rofi -help for id's.
|
||||
* `enabled`: Boolean option to enable. Supports environment variable.
|
||||
|
||||
@media takes an integer number or a fraction, for integer number `px` can be added.
|
||||
|
||||
|
@ -1354,12 +1164,6 @@ It supports the following keys as constraint:
|
|||
}
|
||||
```
|
||||
|
||||
```
|
||||
@media ( enabled: env(DO_LIGHT, false ) {
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Font Parsing
|
||||
|
||||
|
@ -1377,34 +1181,6 @@ Or
|
|||
FontAwesome 22
|
||||
```
|
||||
|
||||
## Icon Handling
|
||||
|
||||
Rofi supports 3 ways of specifying an icon:
|
||||
|
||||
* Filename
|
||||
* icon-name, this is looked up via the icon-theme.
|
||||
* Markup String. It renders a string as an icon.
|
||||
|
||||
|
||||
For the first two options, GdkPixbuf is used to open and render the icons.
|
||||
This in general gives support for most required image formats.
|
||||
For the string option it uses Pango to render the string. The string needs to
|
||||
start with a `<span` tag, that allows you to set color and font.
|
||||
|
||||
Markup string:
|
||||
|
||||
```bash
|
||||
echo -en "testing\0icon\x1f<span color='red'>⏻</span>" | ./rofi -dmenu
|
||||
```
|
||||
|
||||
Getting supported icon formats:
|
||||
|
||||
```bash
|
||||
G_MESSAGES_DEBUG=Helpers.IconFetcher rofi
|
||||
```
|
||||
This uses the debug framework and prints out a list of supported image file
|
||||
extensions.
|
||||
|
||||
## Multiple file handling
|
||||
|
||||
The rasi file format offers two methods of including other files.
|
||||
|
|
|
@ -11,45 +11,30 @@
|
|||
|
||||
## DESCRIPTION
|
||||
|
||||
**rofi** is an X11 pop-up window switcher, run dialog, dmenu replacement, and
|
||||
more. It focuses on being fast to use and have minimal distraction. It supports
|
||||
keyboard and mouse navigation, type to filter, tokenized search and more.
|
||||
**rofi** is an X11 pop-up window switcher, run dialog, dmenu replacement, and more. It focuses on
|
||||
being fast to use and have minimal distraction. It supports keyboard and mouse navigation, type to
|
||||
filter, tokenized search and more.
|
||||
|
||||
|
||||
## USAGE
|
||||
|
||||
**rofi**'s main functionality is to assist in your workflow, allowing you to
|
||||
quickly switch between windows, start applications or log into a remote machine
|
||||
via `ssh`. There are different *modes* for different types of actions. **rofi**
|
||||
is a standalone application and should not be integrated into scripts. For
|
||||
integration into scripts it has a special mode that functions as a (drop-in)
|
||||
replacement for **dmenu(1)**. See emulating dmenu below.
|
||||
**rofi**'s main functionality is to assist in your workflow, allowing you to quickly switch
|
||||
between windows, start applications or log into a remote machine via `ssh`.
|
||||
There are different *modi* for different types of actions.
|
||||
**rofi** is a standalone application and should not be integrated into scripts.
|
||||
For integration into scripts it has a special mode that functions as a
|
||||
(drop-in) replacement for **dmenu(1)**. See emulating dmenu below.
|
||||
|
||||
### Running rofi
|
||||
|
||||
To launch **rofi** directly in a certain mode, specify a mode with `rofi -show <mode>`.
|
||||
To show the `drun` dialog:
|
||||
|
||||
```bash
|
||||
rofi -show drun
|
||||
```
|
||||
|
||||
A very useful setup in minimalistic window managers is to combine `drun`, `run`
|
||||
with `window` mode:
|
||||
|
||||
```bash
|
||||
rofi -show combi -modes combi -combi-modes "window,drun,run"
|
||||
```
|
||||
|
||||
In this setup it first list all open applications, then all installed
|
||||
applications. So if you type firefox and hit return, it will switch to the
|
||||
running firefox, or launch it when it is not running.
|
||||
To show the `run` dialog:
|
||||
|
||||
rofi -show run
|
||||
|
||||
### Emulating dmenu
|
||||
|
||||
**rofi** can emulate **dmenu(1)** (a dynamic menu for X11) when launched with
|
||||
the `-dmenu` flag.
|
||||
**rofi** can emulate **dmenu(1)** (a dynamic menu for X11) when launched with the `-dmenu` flag.
|
||||
|
||||
For more information see **rofi-dmenu(5)**.
|
||||
|
||||
|
@ -75,29 +60,6 @@ To get a template config file, run: `rofi -dump-config > config.rasi`
|
|||
|
||||
This will contain (commented) all current configuration options, modified options are uncommented.
|
||||
|
||||
To get a template config file that sets the icon-theme run: `rofi -icon-theme hicolor -dump-config`.
|
||||
|
||||
It is **strongly** recommended to use this as a starting point for your configuration.
|
||||
|
||||
An empty configuration section in the config file looks like:
|
||||
|
||||
```css
|
||||
configuration {
|
||||
// set config options here
|
||||
}
|
||||
```
|
||||
|
||||
Most of the configuration options mentioned below (beside options like `-show`,
|
||||
`-dump-config` that apply to a single run) can be set here.
|
||||
|
||||
For example to set the dpi value to 72:
|
||||
|
||||
```css
|
||||
configuration {
|
||||
dpi: 72;
|
||||
}
|
||||
```
|
||||
|
||||
The configuration system supports the following types:
|
||||
|
||||
* string
|
||||
|
@ -123,8 +85,8 @@ Below is a list of the most important options:
|
|||
|
||||
`-help`
|
||||
|
||||
The help option shows the full list of command-line options and the current set
|
||||
values. These include dynamic (run-time generated) options.
|
||||
The help option shows the full list of command-line options and the current set values.
|
||||
These include dynamic (run-time generated) options.
|
||||
|
||||
`-version`
|
||||
|
||||
|
@ -143,11 +105,6 @@ Dump the current active theme, in rasi format, to stdout and exit.
|
|||
|
||||
Try to parse the file and return 0 when successful, non-zero when failed.
|
||||
|
||||
`-list-keybindings`
|
||||
|
||||
List all known keybindings without trying to parse them. This can be used to
|
||||
look for duplicate bindings.
|
||||
|
||||
`-threads` *num*
|
||||
|
||||
Specify the number of threads **rofi** should use:
|
||||
|
@ -174,45 +131,41 @@ Or get the options from a script:
|
|||
|
||||
~/my_script.sh | rofi -dmenu
|
||||
|
||||
See the **rofi-dmenu(5)** manpage for more information.
|
||||
|
||||
`-show` *mode*
|
||||
|
||||
Open **rofi** in a certain mode. Available modes are `window`, `run`, `drun`,
|
||||
`ssh`, `combi`. The special argument `keys` can be used to open a searchable
|
||||
list of supported key bindings
|
||||
(see the **rofi-keys(5)** manpage)
|
||||
Open **rofi** in a certain mode. Available modes are `window`, `run`, `drun`, `ssh`, `combi`.
|
||||
The special argument `keys` can be used to open a searchable list of supported key bindings
|
||||
(see *KEY BINDINGS*)
|
||||
|
||||
To show the run-dialog:
|
||||
|
||||
rofi -show run
|
||||
|
||||
If `-show` is the last option passed to rofi, the first enabled modes is shown.
|
||||
If `-show` is the last option passed to rofi, the first enabled modi is shown.
|
||||
|
||||
`-modes` *mode1,mode2*
|
||||
`-modi` *mode1,mode2*
|
||||
|
||||
Specify an ordered, comma-separated list of modes to enable.
|
||||
Enabled modes can be changed at runtime. Default key is `Ctrl+Tab`.
|
||||
If no modes are specified, all configured modes will be enabled.
|
||||
To only show the `run` and `ssh` launcher:
|
||||
|
||||
rofi -modes "run,ssh" -show run
|
||||
rofi -modi "run,ssh" -show run
|
||||
|
||||
Custom modes can be added using the internal `script` mode. Each such mode has
|
||||
two parameters:
|
||||
Custom modes can be added using the internal `script` mode. Each such mode has two parameters:
|
||||
|
||||
<name>:<script>
|
||||
|
||||
Example: Have a mode called 'Workspaces' using the `i3_switch_workspaces.sh` script:
|
||||
|
||||
rofi -modes "window,run,ssh,Workspaces:i3_switch_workspaces.sh" -show Workspaces
|
||||
rofi -modi "window,run,ssh,Workspaces:i3_switch_workspaces.sh" -show Workspaces
|
||||
|
||||
Notes: The i3 window manager dislikes commas in the command when specifying an
|
||||
exec command. For that case, `#` can be used as a separator.
|
||||
Notes: The i3 window manager dislikes commas in the command when specifying an exec command.
|
||||
For that case, `#` can be used as a separator.
|
||||
|
||||
**TIP**: The name is allowed to contain spaces:
|
||||
|
||||
rofi -modes "My File Browser:fb.sh" -show "My File Browser"
|
||||
rofi -modi "My File Browser:fb.sh" -show "My File Browser"
|
||||
|
||||
`-case-sensitive`
|
||||
|
||||
|
@ -266,6 +219,10 @@ Specify icon theme to be used.
|
|||
If not specified default theme from DE is used, *Adwaita* and *gnome* themes act as
|
||||
fallback themes.
|
||||
|
||||
`-application-fallback-icon`
|
||||
|
||||
Specify an icon to be used when the application icon in run/drun are not yet loaded or is not available.
|
||||
|
||||
`-markup`
|
||||
|
||||
Use Pango markup to format output wherever possible.
|
||||
|
@ -278,33 +235,6 @@ Make **rofi** react like a normal application window. Useful for scripts like Cl
|
|||
|
||||
Make rofi steal focus on launch and restore close to window that held it when launched.
|
||||
|
||||
`-refilter-timeout-limit`
|
||||
|
||||
The time (in ms) boundary filter may take before switch from instant to delayed filter mode.
|
||||
|
||||
Default: 300
|
||||
|
||||
A fallback icon can be specified for each mode:
|
||||
|
||||
```css
|
||||
configuration {
|
||||
<mode>{
|
||||
fallback-icon: "<icon name>";
|
||||
}
|
||||
}
|
||||
```
|
||||
Example
|
||||
|
||||
```css
|
||||
configuration {
|
||||
run,drun {
|
||||
fallback-icon: "application-x-addon";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Matching
|
||||
|
||||
`-matching` *method*
|
||||
|
@ -417,7 +347,7 @@ Keep a fixed number of visible lines.
|
|||
`-sidebar-mode`
|
||||
|
||||
Open in sidebar-mode. In this mode, a list of all enabled modes is shown at the bottom.
|
||||
(See `-modes` option)
|
||||
(See `-modi` option)
|
||||
To show sidebar, use:
|
||||
|
||||
rofi -show run -sidebar-mode
|
||||
|
@ -543,12 +473,6 @@ See *PATTERN*.
|
|||
|
||||
Default: *{cmd}*
|
||||
|
||||
Example to run applications in a dedicated cgroup with systemd. Requires a shell to escape and interpolate the unit name correctly.
|
||||
|
||||
```
|
||||
"bash -c 'systemd-run --user --unit=app-rofi-\$(systemd-escape {cmd})-\$RANDOM {cmd}'"
|
||||
```
|
||||
|
||||
`-run-shell-command` *cmd*
|
||||
|
||||
Set command to execute when running an application in a shell.
|
||||
|
@ -578,7 +502,7 @@ Format what is being displayed for windows.
|
|||
* **r**: role
|
||||
* **c**: class
|
||||
|
||||
*len*: maximum field length (0 for auto-size). If length is negative, the entry will be unchanged.
|
||||
*len*: maximum field length (0 for auto-size). If length and window *width* are negative, field length is *width - len*.
|
||||
If length is positive, the entry will be truncated or padded to fill that length.
|
||||
|
||||
|
||||
|
@ -606,39 +530,16 @@ configuration {
|
|||
}
|
||||
}
|
||||
```
|
||||
You can hide the currently active window with the 'hide-active-window' setting:
|
||||
|
||||
```css
|
||||
configuration {
|
||||
window {
|
||||
hide-active-window: true;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
or pass `-window-hide-active-window true` on command line.
|
||||
|
||||
You can prefer the icon theme above the window set icon with the 'prefer-icon-theme' setting:
|
||||
|
||||
```css
|
||||
configuration {
|
||||
window {
|
||||
prefer-icon-theme: true;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
or pass `-window-prefer-icon-theme true` on command line.
|
||||
|
||||
### Combi settings
|
||||
|
||||
`-combi-modes ` *mode1*,*mode2*
|
||||
`-combi-modi` *mode1*,*mode2*
|
||||
|
||||
The modes to combine in combi mode.
|
||||
For syntax to `-combi-modes`, see `-modes`.
|
||||
The modi to combine in combi mode.
|
||||
For syntax to `-combi-modi`, see `-modi`.
|
||||
To get one merge view, of `window`,`run`, and `ssh`:
|
||||
|
||||
rofi -show combi -combi-modes "window,run,ssh" -modes combi
|
||||
rofi -show combi -combi-modi "window,run,ssh" -modi combi
|
||||
|
||||
**NOTE**: The i3 window manager dislikes commas in the command when specifying an exec command.
|
||||
For that case, `#` can be used as a separator.
|
||||
|
@ -654,7 +555,7 @@ Pango markup can be used to formatting the output.
|
|||
|
||||
Default: {mode} {text}
|
||||
|
||||
Note: This setting is ignored if `combi-hide-mode-prefix` is enabled.
|
||||
Note: This setting is ignored if `combi-hide-mode-prefix` is eanbled.
|
||||
|
||||
|
||||
### History and Sorting
|
||||
|
@ -708,14 +609,10 @@ configuration {
|
|||
sorting-method: "name";
|
||||
/** Group directories before files. */
|
||||
directories-first: true;
|
||||
/** Show hidden files. */
|
||||
show-hidden: false;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `show-hidden` can also be triggered with the `kb-delete-entry` keybinding.
|
||||
|
||||
### Other
|
||||
|
||||
`-drun-use-desktop-cache`
|
||||
|
@ -760,12 +657,6 @@ Click the mouse outside the **rofi** window to exit.
|
|||
|
||||
Default: *enabled*
|
||||
|
||||
`-xserver-i300-workaround`
|
||||
|
||||
Workaround for bug in Xserver. See issue #611 and #1642 on the rofi issue tracker.
|
||||
|
||||
Default: *disabled*
|
||||
|
||||
## PATTERN
|
||||
|
||||
To launch commands (for example, when using the ssh launcher), the user can enter the used command-line. The following keys can be used that will be replaced at runtime:
|
||||
|
@ -783,10 +674,54 @@ Please see **rofi-theme(5)** manpage for more information on theming.
|
|||
|
||||
## KEY BINDINGS
|
||||
|
||||
Please see the **rofi-keys(5)** manpage for the keybindings and how to set them up.
|
||||
**rofi** has the following key bindings:
|
||||
|
||||
The keybinding can also be used for actions, when the action is executed the
|
||||
mentioned keystroke is inserted:
|
||||
* `Control-v, Insert`: Paste from clipboard
|
||||
* `Control-Shift-v, Shift-Insert`: Paste primary selection
|
||||
* `Control-u`: Clear the line
|
||||
* `Control-a`: Beginning of line
|
||||
* `Control-e`: End of line
|
||||
* `Control-f, Right`: Forward one character
|
||||
* `Alt-f, Control-Right`: Forward one word
|
||||
* `Control-b, Left`: Back one character
|
||||
* `Alt-b, Control-Left`: Back one word
|
||||
* `Control-d, Delete`: Delete character
|
||||
* `Control-Alt-d`: Delete word
|
||||
* `Control-h, Backspace, Shift-Backspace`: Backspace (delete previous character)
|
||||
* `Control-Alt-h`: Delete previous word
|
||||
* `Control-j,Control-m,Enter`: Accept entry
|
||||
* `Control-n,Down`: Select next entry
|
||||
* `Control-p,Up`: Select previous entry
|
||||
* `Page Up`: Go to previous page
|
||||
* `Page Down`: Go to next page
|
||||
* `Control-Page Up`: Go to previous column
|
||||
* `Control-Page Down`: Go to next column
|
||||
* `Control-Enter`: Use entered text as a command (in `ssh/run modi`)
|
||||
* `Shift-Enter`: Launch the application in a terminal (in run mode)
|
||||
* `Control-Shift-Enter`: As Control-Enter and run the command in terminal (in run mode)
|
||||
* `Shift-Enter`: Return the selected entry and move to the next item while keeping **rofi** open. (in dmenu)
|
||||
* `Shift-Right`: Switch to the next mode. The list can be customized with the `-modi` argument.
|
||||
* `Shift-Left`: Switch to the previous mode. The list can be customized with the `-modi` argument.
|
||||
* `Control-Tab`: Switch to the next mode. The list can be customized with the `-modi` argument.
|
||||
* `Control-Shift-Tab`: Switch to the previous mode. The list can be customized with the `-modi` argument.
|
||||
* `Control-space`: Set selected item as input text.
|
||||
* `Shift-Del`: Delete entry from history.
|
||||
* `grave`: Toggle case sensitivity.
|
||||
* `Alt-grave`: Toggle sorting.
|
||||
* `Alt-Shift-S`: Take a screenshot and store it in the Pictures directory.
|
||||
* `Control-l`: File complete for run dialog.
|
||||
|
||||
This list might not be complete, to get a full list of all key bindings
|
||||
supported in your rofi, see `rofi -h`. The options starting with `-kb` are keybindings.
|
||||
|
||||
Key bindings can be modified using the configuration systems. Multiple keys can be bound
|
||||
to one action by comma separating them. For example `-kb-primary-paste "Conctrol+v,Insert"`
|
||||
|
||||
To get a searchable list of key bindings, run `rofi -show keys`.
|
||||
|
||||
A key binding starting with `!` will act when all keys have been released.
|
||||
|
||||
You can bind certain events to key-actions:
|
||||
|
||||
### Timeout
|
||||
|
||||
|
@ -815,7 +750,9 @@ configuration {
|
|||
}
|
||||
```
|
||||
|
||||
## Available Modes
|
||||
For a full list of bindings, see the **rofi-keys(5)** manpage.
|
||||
|
||||
## Available Modi
|
||||
|
||||
### window
|
||||
|
||||
|
@ -888,25 +825,25 @@ Shows a searchable list of key bindings.
|
|||
|
||||
### script
|
||||
|
||||
Allows custom scripted Modes to be added, see the **rofi-script(5)** manpage for more information.
|
||||
Allows custom scripted Modi to be added, see the **rofi-script(5)** manpage for more information.
|
||||
|
||||
### combi
|
||||
|
||||
Combines multiple modes in one list. Specify which modes are included with the `-combi-modes` option.
|
||||
Combines multiple modi in one list. Specify which modi are included with the `-combi-modi` option.
|
||||
|
||||
When using the combi mode, a *!bang* can be used to filter the results by modes.
|
||||
All modes that match the bang as a prefix are included.
|
||||
For example, say you have specified `-combi-modes run,window,windowcd`. If your
|
||||
When using the combi mode, a *!bang* can be used to filter the results by modi.
|
||||
All modi that match the bang as a prefix are included.
|
||||
For example, say you have specified `-combi-modi run,window,windowcd`. If your
|
||||
query begins with the bang `!w`, only results from the `window` and `windowcd`
|
||||
modes are shown, even if the rest of the input text would match results from `run`.
|
||||
modi are shown, even if the rest of the input text would match results from `run`.
|
||||
|
||||
If no match, the input is handled by the first combined modes.
|
||||
If no match, the input is handled by the first combined modi.
|
||||
|
||||
## FAQ
|
||||
|
||||
### The text in the window switcher is not nicely aligned.
|
||||
|
||||
Try using a mono-space font or tabs + the tab-stops setting..
|
||||
Try using a mono-space font.
|
||||
|
||||
### The window is completely black.
|
||||
|
||||
|
@ -936,19 +873,19 @@ Some basic usage examples of **rofi**:
|
|||
|
||||
Show the run dialog:
|
||||
|
||||
rofi -modes run -show run
|
||||
rofi -modi run -show run
|
||||
|
||||
Show the run dialog, and allow switching to Desktop File run dialog (`drun`):
|
||||
|
||||
rofi -modes run,drun -show run
|
||||
rofi -modi run,drun -show run
|
||||
|
||||
Combine the run and Desktop File run dialog (`drun`):
|
||||
|
||||
rofi -modes combi -show combi -combi-modes run,drun
|
||||
rofi -modi combi -show combi -combi-modi run,drun
|
||||
|
||||
Combine the run and Desktop File run dialog (`drun`), and allow switching to window switcher:
|
||||
|
||||
rofi -modes combi,window -show combi -combi-modes run,drun
|
||||
rofi -modi combi,window -show combi -combi-modi run,drun
|
||||
|
||||
Pop up a text message claiming that this is the end:
|
||||
|
||||
|
@ -962,6 +899,10 @@ Show all key bindings:
|
|||
|
||||
rofi -show keys
|
||||
|
||||
Use `qalc` to get a simple calculator in **rofi**:
|
||||
|
||||
rofi -show calc -modi "calc:qalc +u8 -nocurrencies"
|
||||
|
||||
## i3
|
||||
|
||||
In [i3](http://i3wm.org/) you want to bind **rofi** to be launched on key release. Otherwise, it cannot grab the keyboard.
|
||||
|
@ -996,28 +937,66 @@ been released.
|
|||
|
||||
## WEBSITE
|
||||
|
||||
**rofi** website can be found [here](https://github.com/davatorium/rofi/)
|
||||
**rofi** website can be found [here](https://davedavenport.github.io/rofi/)
|
||||
|
||||
## SUPPORT
|
||||
|
||||
**rofi** support can be obtained:
|
||||
* [GitHub Discussions](https://github.com/davatorium/rofi/discussions)
|
||||
* [Forum (Reddit)](https://reddit.com/r/qtools//)
|
||||
* [IRC](irc://irc.libera.chat:6697/#rofi) (#rofi on irc.libera.chat),
|
||||
|
||||
## DEBUGGING
|
||||
|
||||
For more information see **rofi-debugging(5)** manpage.
|
||||
To debug, it is smart to first try disabling your custom configuration:
|
||||
`-no-config`
|
||||
|
||||
Disable parsing of configuration. This runs rofi in *stock* mode.
|
||||
|
||||
If you run custom C plugins, you can disable them using:
|
||||
|
||||
`-no-plugins`
|
||||
|
||||
Disables the loading of plugins.
|
||||
|
||||
To further debug the plugin, you can get a trace with (lots of) debug information. This debug output can be enabled for
|
||||
multiple parts in rofi using the glib debug framework. Debug domains can be enabled by setting the G_MESSAGES_DEBUG
|
||||
environment variable. At the time of creation of this page, the following debug domains exist:
|
||||
|
||||
* all: Show debug information from all domains.
|
||||
* X11Helper: The X11 Helper functions.
|
||||
* View: The main window view functions.
|
||||
* Widgets.Box: The Box widget.
|
||||
* Dialogs.DMenu: The dmenu mode.
|
||||
* Dialogs.Run: The run mode.
|
||||
* Dialogs.DRun: The desktop file run mode.
|
||||
* Dialogs.Window: The window mode.
|
||||
* Dialogs.Script: The script mode.
|
||||
* Dialogs.Combi: The script mode.
|
||||
* Dialogs.Ssh: The ssh mode.
|
||||
* Rofi: The main application.
|
||||
* Timings: Get timing output.
|
||||
* Theme: Theme engine debug output. (warning lots of output).
|
||||
* Widgets.Icon: The Icon widget.
|
||||
* Widgets.Box: The box widget.
|
||||
* Widgets.Container: The container widget.
|
||||
* Widgets.Window: The window widget.
|
||||
* Helpers.IconFetcher: Information about icon lookup.
|
||||
|
||||
The output of this can provide useful information when writing an issue.
|
||||
|
||||
More information (possibly outdated) see [this](https://github.com/DaveDavenport/rofi/wiki/Debugging%20Rofi) wiki entry.
|
||||
|
||||
## ISSUE TRACKER
|
||||
|
||||
The **rofi** issue tracker can be found [here](https://github.com/davatorium/rofi/issues)
|
||||
Before creating an issue, consider posting a question on the [discussion forum](https://github.com/davatorium/rofi/discussions) first.
|
||||
When creating an issue, please read [this](https://github.com/davatorium/rofi/blob/master/.github/CONTRIBUTING.md)
|
||||
The **rofi** issue tracker can be found [here](https://github.com/DaveDavenport/rofi/issues)
|
||||
|
||||
When creating an issue, please read [this](https://github.com/DaveDavenport/rofi/blob/master/.github/CONTRIBUTING.md)
|
||||
first.
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
**rofi-sensible-terminal(1)**, **dmenu(1)**, **rofi-debugging(5)**, **rofi-theme(5)**, **rofi-script(5)**, **rofi-keys(5)**,**rofi-theme-selector(1)**,**rofi-dmenu(5)**
|
||||
**rofi-sensible-terminal(1)**, **dmenu(1)**, **rofi-theme(5)**, **rofi-script(5)**, **rofi-keys(5)**,**rofi-theme-selector(1)**
|
||||
|
||||
## AUTHOR
|
||||
|
||||
|
|
|
@ -577,14 +577,13 @@ static int dmenu_mode_init(Mode *sw) {
|
|||
Property *p = rofi_theme_property_create(P_INTEGER);
|
||||
p->name = g_strdup("lines");
|
||||
p->value.i = lines;
|
||||
ThemeWidget *widget =
|
||||
rofi_theme_find_or_create_name(rofi_theme, "listview");
|
||||
ThemeWidget *wid = rofi_theme_find_or_create_name(rofi_theme, "listview");
|
||||
GHashTable *table =
|
||||
g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
|
||||
(GDestroyNotify)rofi_theme_property_free);
|
||||
|
||||
g_hash_table_replace(table, p->name, p);
|
||||
rofi_theme_widget_add_properties(widget, table);
|
||||
rofi_theme_widget_add_properties(wid, table);
|
||||
g_hash_table_destroy(table);
|
||||
}
|
||||
|
||||
|
@ -725,10 +724,6 @@ static cairo_surface_t *dmenu_get_icon(const Mode *sw,
|
|||
if (dr->icon_name == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height &&
|
||||
dr->icon_fetch_scale == scale) {
|
||||
return rofi_icon_fetcher_get(dr->icon_fetch_uid);
|
||||
}
|
||||
uint32_t uid = dr->icon_fetch_uid =
|
||||
rofi_icon_fetcher_query(dr->icon_name, height);
|
||||
dr->icon_fetch_size = height;
|
||||
|
|
|
@ -609,12 +609,12 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
|
|||
const guint scale = display_scale();
|
||||
g_return_val_if_fail(pd->array != NULL, NULL);
|
||||
FBFile *dr = &(pd->array[selected_line]);
|
||||
if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height &&
|
||||
dr->icon_fetch_scale == scale) {
|
||||
return rofi_icon_fetcher_get(dr->icon_fetch_uid);
|
||||
}
|
||||
if (rofi_icon_fetcher_file_is_image(dr->path)) {
|
||||
dr->icon_fetch_uid = rofi_icon_fetcher_query(dr->path, height);
|
||||
} else if (dr->type == RFILE) {
|
||||
gchar* _path = g_strconcat("thumbnail://", dr->path, NULL);
|
||||
dr->icon_fetch_uid = rofi_icon_fetcher_query(_path, height);
|
||||
g_free(_path);
|
||||
} else {
|
||||
dr->icon_fetch_uid = rofi_icon_fetcher_query(icon_name[dr->type], height);
|
||||
}
|
||||
|
|
|
@ -180,83 +180,137 @@ static void recursive_browser_mode_init_current_dir(Mode *sw) {
|
|||
}
|
||||
|
||||
static void scan_dir(FileBrowserModePrivateData *pd, GFile *path) {
|
||||
char *cdir = g_file_get_path(path);
|
||||
DIR *dir = opendir(cdir);
|
||||
if (dir) {
|
||||
struct dirent *rd = NULL;
|
||||
while (pd->end_thread == FALSE && (rd = readdir(dir)) != NULL) {
|
||||
if (g_strcmp0(rd->d_name, "..") == 0) {
|
||||
continue;
|
||||
}
|
||||
if (g_strcmp0(rd->d_name, ".") == 0) {
|
||||
continue;
|
||||
}
|
||||
if (pd->filter_regex &&
|
||||
g_regex_match(pd->filter_regex, rd->d_name, 0, NULL)) {
|
||||
continue;
|
||||
}
|
||||
switch (rd->d_type) {
|
||||
case DT_BLK:
|
||||
case DT_CHR:
|
||||
case DT_FIFO:
|
||||
case DT_UNKNOWN:
|
||||
case DT_SOCK:
|
||||
default:
|
||||
break;
|
||||
case DT_REG: {
|
||||
FBFile *f = g_malloc0(sizeof(FBFile));
|
||||
// Rofi expects utf-8, so lets convert the filename.
|
||||
f->path = g_build_filename(cdir, rd->d_name, NULL);
|
||||
f->name = g_filename_to_utf8(f->path, -1, NULL, NULL, NULL);
|
||||
if (f->name == NULL) {
|
||||
f->name = rofi_force_utf8(rd->d_name, -1);
|
||||
GQueue *dirs_to_scan = g_queue_new();
|
||||
g_queue_push_tail(dirs_to_scan, g_object_ref(path));
|
||||
GFile *dir_to_scan = NULL;
|
||||
while ((dir_to_scan = g_queue_pop_head(dirs_to_scan)) != NULL) {
|
||||
char *cdir = g_file_get_path(dir_to_scan);
|
||||
DIR *dir = opendir(cdir);
|
||||
g_object_unref(dir_to_scan);
|
||||
if (dir) {
|
||||
struct dirent *rd = NULL;
|
||||
while (pd->end_thread == FALSE && (rd = readdir(dir)) != NULL) {
|
||||
if (g_strcmp0(rd->d_name, "..") == 0) {
|
||||
continue;
|
||||
}
|
||||
f->type = (rd->d_type == DT_DIR) ? DIRECTORY : RFILE;
|
||||
f->icon_fetch_uid = 0;
|
||||
f->icon_fetch_size = 0;
|
||||
f->icon_fetch_scale = 0;
|
||||
f->link = FALSE;
|
||||
if (g_strcmp0(rd->d_name, ".") == 0) {
|
||||
continue;
|
||||
}
|
||||
if (pd->filter_regex &&
|
||||
g_regex_match(pd->filter_regex, rd->d_name, 0, NULL)) {
|
||||
continue;
|
||||
}
|
||||
switch (rd->d_type) {
|
||||
case DT_BLK:
|
||||
case DT_CHR:
|
||||
case DT_FIFO:
|
||||
case DT_SOCK:
|
||||
default:
|
||||
break;
|
||||
case DT_REG: {
|
||||
FBFile *f = g_malloc0(sizeof(FBFile));
|
||||
// Rofi expects utf-8, so lets convert the filename.
|
||||
f->path = g_build_filename(cdir, rd->d_name, NULL);
|
||||
f->name = g_filename_to_utf8(f->path, -1, NULL, NULL, NULL);
|
||||
if (f->name == NULL) {
|
||||
f->name = rofi_force_utf8(rd->d_name, -1);
|
||||
}
|
||||
if (f->name == NULL) {
|
||||
f->name = g_strdup("n/a");
|
||||
}
|
||||
f->type = (rd->d_type == DT_DIR) ? DIRECTORY : RFILE;
|
||||
f->icon_fetch_uid = 0;
|
||||
f->icon_fetch_size = 0;
|
||||
f->icon_fetch_scale = 0;
|
||||
f->link = FALSE;
|
||||
|
||||
g_async_queue_push(pd->async_queue, f);
|
||||
if (g_async_queue_length(pd->async_queue) > 10000) {
|
||||
write(pd->pipefd2[1], "r", 1);
|
||||
g_async_queue_push(pd->async_queue, f);
|
||||
if (g_async_queue_length(pd->async_queue) > 10000) {
|
||||
write(pd->pipefd2[1], "r", 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DT_DIR: {
|
||||
char *d = g_build_filename(cdir, rd->d_name, NULL);
|
||||
GFile *dirp = g_file_new_for_path(d);
|
||||
scan_dir(pd, dirp);
|
||||
g_object_unref(dirp);
|
||||
g_free(d);
|
||||
break;
|
||||
}
|
||||
case DT_LNK: {
|
||||
FBFile *f = g_malloc0(sizeof(FBFile));
|
||||
// Rofi expects utf-8, so lets convert the filename.
|
||||
f->path = g_build_filename(cdir, rd->d_name, NULL);
|
||||
f->name = g_filename_to_utf8(f->path, -1, NULL, NULL, NULL);
|
||||
if (f->name == NULL) {
|
||||
f->name = rofi_force_utf8(rd->d_name, -1);
|
||||
case DT_DIR: {
|
||||
char *d = g_build_filename(cdir, rd->d_name, NULL);
|
||||
GFile *dirp = g_file_new_for_path(d);
|
||||
g_queue_push_tail(dirs_to_scan, dirp);
|
||||
g_free(d);
|
||||
break;
|
||||
}
|
||||
case DT_UNKNOWN:
|
||||
case DT_LNK: {
|
||||
FBFile *f = g_malloc0(sizeof(FBFile));
|
||||
// Rofi expects utf-8, so lets convert the filename.
|
||||
f->path = g_build_filename(cdir, rd->d_name, NULL);
|
||||
f->name = g_filename_to_utf8(f->path, -1, NULL, NULL, NULL);
|
||||
if (f->name == NULL) {
|
||||
f->name = rofi_force_utf8(rd->d_name, -1);
|
||||
}
|
||||
if (f->name == NULL) {
|
||||
f->name = g_strdup("n/a");
|
||||
}
|
||||
f->icon_fetch_uid = 0;
|
||||
f->icon_fetch_size = 0;
|
||||
f->icon_fetch_scale = 0;
|
||||
// Default to file.
|
||||
f->type = RFILE;
|
||||
if (rd->d_type == DT_LNK) {
|
||||
f->link = TRUE;
|
||||
} else {
|
||||
f->link = FALSE;
|
||||
}
|
||||
{
|
||||
// If we have link, use a stat to fine out what it is, if we fail,
|
||||
// we mark it as file.
|
||||
// TODO have a 'broken link' mode?
|
||||
// Convert full path to right encoding.
|
||||
// DD: Path should be in file encoding, not utf-8
|
||||
// char *file =
|
||||
// g_filename_from_utf8(pd->array[pd->array_length].path,
|
||||
// -1, NULL, NULL, NULL);
|
||||
// TODO: How to handle loops in links.
|
||||
if (f->path) {
|
||||
GStatBuf statbuf;
|
||||
if (g_stat(f->path, &statbuf) == 0) {
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
char *new_full_path =
|
||||
g_build_filename(cdir, rd->d_name, NULL);
|
||||
g_free(f->path);
|
||||
g_free(f->name);
|
||||
g_free(f);
|
||||
f = NULL;
|
||||
GFile *dirp = g_file_new_for_path(new_full_path);
|
||||
g_queue_push_tail(dirs_to_scan, dirp);
|
||||
g_free(new_full_path);
|
||||
break;
|
||||
} else if (S_ISREG(statbuf.st_mode)) {
|
||||
f->type = RFILE;
|
||||
}
|
||||
|
||||
} else {
|
||||
g_warning("Failed to stat file: %s, %s", f->path,
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
// g_free(file);
|
||||
}
|
||||
}
|
||||
if (f != NULL) {
|
||||
g_async_queue_push(pd->async_queue, f);
|
||||
if (g_async_queue_length(pd->async_queue) > 10000) {
|
||||
write(pd->pipefd2[1], "r", 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
f->icon_fetch_uid = 0;
|
||||
f->icon_fetch_size = 0;
|
||||
f->icon_fetch_scale = 0;
|
||||
f->link = TRUE;
|
||||
// Default to file.
|
||||
f->type = RFILE;
|
||||
g_async_queue_push(pd->async_queue, f);
|
||||
if (g_async_queue_length(pd->async_queue) > 10000) {
|
||||
write(pd->pipefd2[1], "r", 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
closedir(dir);
|
||||
g_free(cdir);
|
||||
}
|
||||
|
||||
g_free(cdir);
|
||||
g_queue_free(dirs_to_scan);
|
||||
}
|
||||
static gpointer recursive_browser_input_thread(gpointer userdata) {
|
||||
FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *)userdata;
|
||||
|
@ -339,7 +393,8 @@ static unsigned int recursive_browser_mode_get_num_entries(const Mode *sw) {
|
|||
return pd->array_length;
|
||||
}
|
||||
|
||||
static ModeMode recursive_browser_mode_result(Mode *sw, int mretv, G_GNUC_UNUSED char **input,
|
||||
static ModeMode recursive_browser_mode_result(Mode *sw, int mretv,
|
||||
G_GNUC_UNUSED char **input,
|
||||
unsigned int selected_line) {
|
||||
ModeMode retv = MODE_EXIT;
|
||||
FileBrowserModePrivateData *pd =
|
||||
|
@ -444,12 +499,12 @@ static cairo_surface_t *_get_icon(const Mode *sw, unsigned int selected_line,
|
|||
const guint scale = display_scale();
|
||||
g_return_val_if_fail(pd->array != NULL, NULL);
|
||||
FBFile *dr = &(pd->array[selected_line]);
|
||||
if (dr->icon_fetch_uid > 0 && dr->icon_fetch_size == height &&
|
||||
dr->icon_fetch_scale == scale) {
|
||||
return rofi_icon_fetcher_get(dr->icon_fetch_uid);
|
||||
}
|
||||
if (rofi_icon_fetcher_file_is_image(dr->path)) {
|
||||
dr->icon_fetch_uid = rofi_icon_fetcher_query(dr->path, height);
|
||||
} else if (dr->type == RFILE) {
|
||||
gchar *_path = g_strconcat("thumbnail://", dr->path, NULL);
|
||||
dr->icon_fetch_uid = rofi_icon_fetcher_query(_path, height);
|
||||
g_free(_path);
|
||||
} else {
|
||||
dr->icon_fetch_uid =
|
||||
rofi_icon_fetcher_query(rb_icon_name[dr->type], height);
|
||||
|
|
|
@ -73,6 +73,8 @@ typedef struct {
|
|||
char delim;
|
||||
/** no custom */
|
||||
gboolean no_custom;
|
||||
/** keep filter */
|
||||
gboolean keep_filter;
|
||||
|
||||
gboolean use_hot_keys;
|
||||
} ScriptModePrivateData;
|
||||
|
@ -158,6 +160,8 @@ static void parse_header_entry(Mode *sw, char *line, ssize_t length) {
|
|||
pd->use_hot_keys = (strcasecmp(value, "true") == 0);
|
||||
} else if (strcasecmp(line, "keep-selection") == 0) {
|
||||
pd->keep_selection = (strcasecmp(value, "true") == 0);
|
||||
} else if (strcasecmp(line, "keep-filter") == 0) {
|
||||
pd->keep_filter = (strcasecmp(value, "true") == 0);
|
||||
} else if (strcasecmp(line, "new-selection") == 0) {
|
||||
pd->new_selection = (int64_t)g_ascii_strtoll(value, NULL, 0);
|
||||
} else if (strcasecmp(line, "data") == 0) {
|
||||
|
@ -185,6 +189,7 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg,
|
|||
// Reset these between runs.
|
||||
pd->new_selection = -1;
|
||||
pd->keep_selection = 0;
|
||||
pd->keep_filter = 0;
|
||||
// Environment
|
||||
char **env = g_get_environ();
|
||||
|
||||
|
@ -322,6 +327,9 @@ static ModeMode script_mode_result(Mode *sw, int mretv, char **input,
|
|||
ModeMode retv = MODE_EXIT;
|
||||
DmenuScriptEntry *new_list = NULL;
|
||||
unsigned int new_length = 0;
|
||||
// store them as they might be different on next executor and reset.
|
||||
gboolean keep_filter = rmpd->keep_filter;
|
||||
gboolean keep_selection = rmpd->keep_selection;
|
||||
|
||||
if ((mretv & MENU_CUSTOM_COMMAND)) {
|
||||
if (rmpd->use_hot_keys) {
|
||||
|
@ -372,7 +380,7 @@ static ModeMode script_mode_result(Mode *sw, int mretv, char **input,
|
|||
|
||||
rmpd->cmd_list = new_list;
|
||||
rmpd->cmd_list_length = new_length;
|
||||
if (rmpd->keep_selection) {
|
||||
if (keep_selection) {
|
||||
if (rmpd->new_selection >= 0 &&
|
||||
rmpd->new_selection < rmpd->cmd_list_length) {
|
||||
rofi_view_set_selected_line(rofi_view_get_active(),
|
||||
|
@ -380,12 +388,14 @@ static ModeMode script_mode_result(Mode *sw, int mretv, char **input,
|
|||
} else {
|
||||
rofi_view_set_selected_line(rofi_view_get_active(), selected_line);
|
||||
}
|
||||
} else {
|
||||
rofi_view_set_selected_line(rofi_view_get_active(), 0);
|
||||
}
|
||||
if (keep_filter == FALSE) {
|
||||
g_free(*input);
|
||||
*input = NULL;
|
||||
retv = RELOAD_DIALOG;
|
||||
} else {
|
||||
retv = RESET_DIALOG;
|
||||
}
|
||||
retv = RELOAD_DIALOG;
|
||||
}
|
||||
return retv;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,10 @@
|
|||
#include "helper.h"
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
// thumbnailers key file's group and file extension
|
||||
#define THUMBNAILER_ENTRY_GROUP "Thumbnailer Entry"
|
||||
#define THUMBNAILER_EXTENSION ".thumbnailer"
|
||||
|
||||
typedef struct {
|
||||
// Context for icon-themes.
|
||||
NkXdgThemeContext *xdg_context;
|
||||
|
@ -62,6 +66,9 @@ typedef struct {
|
|||
// list extensions
|
||||
GList *supported_extensions;
|
||||
uint32_t last_uid;
|
||||
|
||||
// thumbnailers per mime-types hashmap
|
||||
GHashTable *thumbnailers;
|
||||
} IconFetcher;
|
||||
|
||||
typedef struct {
|
||||
|
@ -82,6 +89,7 @@ typedef struct {
|
|||
guint scale;
|
||||
cairo_surface_t *surface;
|
||||
gboolean query_done;
|
||||
gboolean query_started;
|
||||
|
||||
IconFetcherNameEntry *entry;
|
||||
} IconFetcherEntry;
|
||||
|
@ -93,10 +101,156 @@ static void rofi_icon_fetch_entry_free(gpointer data);
|
|||
*/
|
||||
IconFetcher *rofi_icon_fetcher_data = NULL;
|
||||
|
||||
static void rofi_icon_fetcher_load_thumbnailers(const gchar *path) {
|
||||
gchar *thumb_path = g_build_filename(path, "thumbnailers", NULL);
|
||||
|
||||
GDir *dir = g_dir_open(thumb_path, 0, NULL);
|
||||
|
||||
if (!dir) {
|
||||
g_free(thumb_path);
|
||||
return;
|
||||
}
|
||||
|
||||
const gchar *dirent;
|
||||
|
||||
while ((dirent = g_dir_read_name(dir))) {
|
||||
if (!g_str_has_suffix(dirent, THUMBNAILER_EXTENSION))
|
||||
continue;
|
||||
|
||||
gchar *filename = g_build_filename(thumb_path, dirent, NULL);
|
||||
GKeyFile *key_file = g_key_file_new();
|
||||
GError *error = NULL;
|
||||
|
||||
if (!g_key_file_load_from_file(key_file, filename, 0, &error)) {
|
||||
g_warning("Error loading thumbnailer %s: %s", filename, error->message);
|
||||
g_error_free(error);
|
||||
} else {
|
||||
gchar *command = g_key_file_get_string(
|
||||
key_file, THUMBNAILER_ENTRY_GROUP, "Exec", NULL);
|
||||
gchar **mime_types = g_key_file_get_string_list(
|
||||
key_file, THUMBNAILER_ENTRY_GROUP, "MimeType", NULL, NULL);
|
||||
|
||||
if (mime_types && command) {
|
||||
guint i;
|
||||
for (i = 0; mime_types[i] != NULL; i++) {
|
||||
if (!g_hash_table_lookup(
|
||||
rofi_icon_fetcher_data->thumbnailers, mime_types[i])) {
|
||||
g_info("Loading thumbnailer %s for mimetype %s", filename, mime_types[i]);
|
||||
g_hash_table_insert(
|
||||
rofi_icon_fetcher_data->thumbnailers,
|
||||
g_strdup(mime_types[i]),
|
||||
g_strdup(command)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mime_types) g_strfreev(mime_types);
|
||||
if (command) g_free(command);
|
||||
}
|
||||
|
||||
g_key_file_free(key_file);
|
||||
g_free(filename);
|
||||
}
|
||||
|
||||
g_dir_close(dir);
|
||||
g_free(thumb_path);
|
||||
}
|
||||
|
||||
static gchar** setup_thumbnailer_command(const gchar *command,
|
||||
const gchar *filename,
|
||||
const gchar *encoded_uri,
|
||||
const gchar *output_path,
|
||||
int size) {
|
||||
gchar **command_parts = g_strsplit(command, " ", 0);
|
||||
guint command_parts_count = g_strv_length(command_parts);
|
||||
|
||||
gchar **command_args = NULL;
|
||||
|
||||
if (command_parts) {
|
||||
command_args = g_malloc0(sizeof(gchar*) * (command_parts_count + 3 + 1));
|
||||
|
||||
// set process niceness value to 19 (low priority)
|
||||
guint current_index = 0;
|
||||
|
||||
command_args[current_index++] = g_strdup("nice");
|
||||
command_args[current_index++] = g_strdup("-n");
|
||||
command_args[current_index++] = g_strdup("19");
|
||||
|
||||
// add executable and arguments of the thumbnailer to the list
|
||||
guint i;
|
||||
for (i = 0; command_parts[i] != NULL; i++) {
|
||||
if (strcmp(command_parts[i], "%i") == 0) {
|
||||
command_args[current_index++] = g_strdup(filename);
|
||||
} else if (strcmp(command_parts[i], "%u") == 0) {
|
||||
command_args[current_index++] = g_strdup(encoded_uri);
|
||||
} else if (strcmp(command_parts[i], "%o") == 0) {
|
||||
command_args[current_index++] = g_strdup(output_path);
|
||||
} else if (strcmp(command_parts[i], "%s") == 0) {
|
||||
command_args[current_index++] = g_strdup_printf("%d", size);
|
||||
} else {
|
||||
command_args[current_index++] = g_strdup(command_parts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
command_args[current_index++] = NULL;
|
||||
|
||||
g_strfreev(command_parts);
|
||||
}
|
||||
|
||||
return command_args;
|
||||
}
|
||||
|
||||
static gboolean exec_thumbnailer_command(gchar **command_args) {
|
||||
// launch and wait thumbnailers process
|
||||
gint wait_status;
|
||||
GError *error = NULL;
|
||||
|
||||
gboolean spawned = g_spawn_sync(NULL, command_args,
|
||||
NULL, G_SPAWN_DEFAULT | G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, &wait_status, &error);
|
||||
|
||||
if (spawned) {
|
||||
return g_spawn_check_wait_status(wait_status, NULL);
|
||||
} else {
|
||||
g_warning("Error calling thumbnailer: %s", error->message);
|
||||
g_error_free(error);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean rofi_icon_fetcher_create_thumbnail(const gchar *mime_type,
|
||||
const gchar *filename,
|
||||
const gchar *encoded_uri,
|
||||
const gchar *output_path,
|
||||
int size) {
|
||||
gboolean thumbnail_created = FALSE;
|
||||
|
||||
gchar *command = g_hash_table_lookup(
|
||||
rofi_icon_fetcher_data->thumbnailers, mime_type);
|
||||
|
||||
if (!command) {
|
||||
return thumbnail_created;
|
||||
}
|
||||
|
||||
// split command string to isolate arguments and expand them in a list
|
||||
gchar **command_args = setup_thumbnailer_command(
|
||||
command, filename, encoded_uri, output_path, size);
|
||||
|
||||
if (command_args) {
|
||||
thumbnail_created = exec_thumbnailer_command(command_args);
|
||||
g_strfreev(command_args);
|
||||
}
|
||||
|
||||
return thumbnail_created;
|
||||
}
|
||||
|
||||
static void rofi_icon_fetch_thread_pool_entry_remove(gpointer data) {
|
||||
IconFetcherEntry *entry = (IconFetcherEntry *)data;
|
||||
// Mark it in a way it should be re-fetched on next query?
|
||||
entry->query_started = FALSE;
|
||||
}
|
||||
|
||||
static void rofi_icon_fetch_entry_free(gpointer data) {
|
||||
IconFetcherNameEntry *entry = (IconFetcherNameEntry *)data;
|
||||
|
||||
|
@ -147,6 +301,20 @@ void rofi_icon_fetcher_init(void) {
|
|||
g_free(exts);
|
||||
}
|
||||
g_slist_free(l);
|
||||
|
||||
// load available thumbnailers from system dirs and user dir
|
||||
rofi_icon_fetcher_data->thumbnailers = g_hash_table_new_full(
|
||||
g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)g_free);
|
||||
|
||||
const gchar * const *system_data_dirs = g_get_system_data_dirs();
|
||||
const gchar *user_data_dir = g_get_user_data_dir();
|
||||
|
||||
rofi_icon_fetcher_load_thumbnailers(user_data_dir);
|
||||
|
||||
guint i;
|
||||
for (i = 0; system_data_dirs[i] != NULL; i++) {
|
||||
rofi_icon_fetcher_load_thumbnailers(system_data_dirs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void free_wrapper(gpointer data, G_GNUC_UNUSED gpointer user_data) {
|
||||
|
@ -157,6 +325,8 @@ void rofi_icon_fetcher_destroy(void) {
|
|||
if (rofi_icon_fetcher_data == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_hash_table_unref(rofi_icon_fetcher_data->thumbnailers);
|
||||
|
||||
nk_xdg_theme_context_free(rofi_icon_fetcher_data->xdg_context);
|
||||
|
||||
|
@ -288,6 +458,73 @@ gboolean rofi_icon_fetcher_file_is_image(const char *const path) {
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
// build thumbnail's path using md5 hash of an entry name
|
||||
static gchar* rofi_icon_fetcher_get_thumbnail(gchar* name,
|
||||
int requested_size,
|
||||
int *thumb_size) {
|
||||
// calc entry_name md5 hash
|
||||
GChecksum* checksum = g_checksum_new(G_CHECKSUM_MD5);
|
||||
g_checksum_update(checksum, (guchar*)name, -1);
|
||||
const gchar *md5_hex = g_checksum_get_string(checksum);
|
||||
|
||||
// determine thumbnail folder based on the request size
|
||||
const gchar* cache_dir = g_get_user_cache_dir();
|
||||
gchar* thumb_dir;
|
||||
gchar* thumb_path;
|
||||
|
||||
if (requested_size <= 128) {
|
||||
*thumb_size = 128;
|
||||
thumb_dir = g_strconcat(cache_dir, "/thumbnails/normal/", NULL);
|
||||
thumb_path = g_strconcat(cache_dir, "/thumbnails/normal/",
|
||||
md5_hex, ".png", NULL);
|
||||
} else if (requested_size <= 256) {
|
||||
*thumb_size = 256;
|
||||
thumb_dir = g_strconcat(cache_dir, "/thumbnails/large/", NULL);
|
||||
thumb_path = g_strconcat(cache_dir, "/thumbnails/large/",
|
||||
md5_hex, ".png", NULL);
|
||||
} else if (requested_size <= 512) {
|
||||
*thumb_size = 512;
|
||||
thumb_dir = g_strconcat(cache_dir, "/thumbnails/x-large/", NULL);
|
||||
thumb_path = g_strconcat(cache_dir, "/thumbnails/x-large/",
|
||||
md5_hex, ".png", NULL);
|
||||
} else {
|
||||
*thumb_size = 1024;
|
||||
thumb_dir = g_strconcat(cache_dir, "/thumbnails/xx-large/", NULL);
|
||||
thumb_path = g_strconcat(cache_dir, "/thumbnails/xx-large/",
|
||||
md5_hex, ".png", NULL);
|
||||
}
|
||||
|
||||
// create thumbnail directory if it does not exist
|
||||
g_mkdir_with_parents(thumb_dir, 0700);
|
||||
|
||||
g_free(thumb_dir);
|
||||
g_checksum_free(checksum);
|
||||
|
||||
return thumb_path;
|
||||
}
|
||||
|
||||
// retrieves icon key from a .desktop file
|
||||
static gchar* rofi_icon_fetcher_get_desktop_icon(const gchar* file_path) {
|
||||
GKeyFile *kf = g_key_file_new();
|
||||
GError *key_error = NULL;
|
||||
gchar *icon_key = NULL;
|
||||
|
||||
gboolean res = g_key_file_load_from_file(kf, file_path, 0, &key_error);
|
||||
|
||||
if (res) {
|
||||
icon_key = g_key_file_get_string(kf, "Desktop Entry", "Icon", NULL);
|
||||
} else {
|
||||
g_debug("Failed to parse desktop file %s because: %s.",
|
||||
file_path, key_error->message);
|
||||
|
||||
g_error_free(key_error);
|
||||
}
|
||||
|
||||
g_key_file_free(kf);
|
||||
|
||||
return icon_key;
|
||||
}
|
||||
|
||||
static void rofi_icon_fetcher_worker(thread_state *sdata,
|
||||
G_GNUC_UNUSED gpointer user_data) {
|
||||
g_debug("starting up icon fetching thread.");
|
||||
|
@ -299,7 +536,118 @@ static void rofi_icon_fetcher_worker(thread_state *sdata,
|
|||
const gchar *icon_path;
|
||||
gchar *icon_path_ = NULL;
|
||||
|
||||
if (g_path_is_absolute(sentry->entry->name)) {
|
||||
if (g_str_has_prefix(sentry->entry->name, "thumbnail://")) {
|
||||
// remove uri thumbnail prefix from entry name
|
||||
gchar *entry_name = &sentry->entry->name[12];
|
||||
|
||||
if (strcmp(entry_name, "") == 0) {
|
||||
sentry->query_done = TRUE;
|
||||
rofi_view_reload();
|
||||
return;
|
||||
}
|
||||
|
||||
// use custom user command to generate the thumbnail
|
||||
if (config.preview_cmd != NULL) {
|
||||
int requested_size = MAX(sentry->wsize, sentry->hsize);
|
||||
int thumb_size;
|
||||
|
||||
icon_path = icon_path_ = rofi_icon_fetcher_get_thumbnail(
|
||||
entry_name, requested_size, &thumb_size);
|
||||
|
||||
if (!g_file_test(icon_path, G_FILE_TEST_EXISTS)) {
|
||||
char **command_args = NULL;
|
||||
int argsv = 0;
|
||||
gchar *size_str = g_strdup_printf("%d", thumb_size);
|
||||
|
||||
helper_parse_setup(
|
||||
config.preview_cmd, &command_args, &argsv,
|
||||
"{input}", entry_name,
|
||||
"{output}", icon_path_, "{size}", size_str, NULL);
|
||||
|
||||
g_free(size_str);
|
||||
|
||||
if (command_args) {
|
||||
exec_thumbnailer_command(command_args);
|
||||
g_strfreev(command_args);
|
||||
}
|
||||
}
|
||||
} else if (g_path_is_absolute(entry_name)) {
|
||||
// if the entry name is an absolute path try to fetch its thumbnail
|
||||
if (g_str_has_suffix(entry_name, ".desktop")) {
|
||||
// if the entry is a .desktop file try to read its icon key
|
||||
gchar *icon_key = rofi_icon_fetcher_get_desktop_icon(entry_name);
|
||||
|
||||
if (icon_key == NULL || strlen(icon_key) == 0) {
|
||||
// no icon in .desktop file, fallback on mimetype icon (text/plain)
|
||||
icon_path = icon_path_ = nk_xdg_theme_get_icon(
|
||||
rofi_icon_fetcher_data->xdg_context, themes, NULL, "text-plain",
|
||||
MIN(sentry->wsize, sentry->hsize), 1, TRUE);
|
||||
|
||||
g_free(icon_key);
|
||||
} else if (g_path_is_absolute(icon_key)) {
|
||||
// icon in .desktop file is an absolute path to an image
|
||||
icon_path = icon_path_ = icon_key;
|
||||
} else {
|
||||
// icon in .desktop file is a standard icon name
|
||||
icon_path = icon_path_ = nk_xdg_theme_get_icon(
|
||||
rofi_icon_fetcher_data->xdg_context, themes, NULL, icon_key,
|
||||
MIN(sentry->wsize, sentry->hsize), 1, TRUE);
|
||||
|
||||
g_free(icon_key);
|
||||
}
|
||||
} else {
|
||||
// build encoded uri string from absolute file path
|
||||
gchar *encoded_uri = g_filename_to_uri(entry_name, NULL, NULL);
|
||||
int requested_size = MAX(sentry->wsize, sentry->hsize);
|
||||
int thumb_size;
|
||||
|
||||
// look for file thumbnail in appropriate folder based on requested size
|
||||
icon_path = icon_path_ = rofi_icon_fetcher_get_thumbnail(
|
||||
encoded_uri, requested_size, &thumb_size);
|
||||
|
||||
if (!g_file_test(icon_path, G_FILE_TEST_EXISTS)) {
|
||||
// try to generate thumbnail
|
||||
char *content_type = g_content_type_guess(entry_name, NULL, 0, NULL);
|
||||
char *mime_type = g_content_type_get_mime_type(content_type);
|
||||
|
||||
if (mime_type) {
|
||||
gboolean created = rofi_icon_fetcher_create_thumbnail(
|
||||
mime_type, entry_name, encoded_uri, icon_path_, thumb_size);
|
||||
|
||||
if (!created) {
|
||||
// replace forward slashes with minus sign to get the icon's name
|
||||
int index = 0;
|
||||
|
||||
while(mime_type[index]) {
|
||||
if(mime_type[index] == '/')
|
||||
mime_type[index] = '-';
|
||||
index++;
|
||||
}
|
||||
|
||||
g_free(icon_path_);
|
||||
|
||||
// try to fetch the mime-type icon
|
||||
icon_path = icon_path_ = nk_xdg_theme_get_icon(
|
||||
rofi_icon_fetcher_data->xdg_context, themes, NULL, mime_type,
|
||||
MIN(sentry->wsize, sentry->hsize), 1, TRUE);
|
||||
}
|
||||
|
||||
g_free(mime_type);
|
||||
g_free(content_type);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(encoded_uri);
|
||||
}
|
||||
}
|
||||
|
||||
// no suitable icon or thumbnail was found
|
||||
if (icon_path_ == NULL || !g_file_test(icon_path, G_FILE_TEST_EXISTS)) {
|
||||
sentry->query_done = TRUE;
|
||||
rofi_view_reload();
|
||||
return;
|
||||
}
|
||||
} else if (g_path_is_absolute(sentry->entry->name)) {
|
||||
icon_path = sentry->entry->name;
|
||||
} else if (g_str_has_prefix(sentry->entry->name, "<span")) {
|
||||
cairo_surface_t *surface = cairo_image_surface_create(
|
||||
|
@ -419,6 +767,9 @@ uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize,
|
|||
sentry = iter->data;
|
||||
if (sentry->wsize == wsize && sentry->hsize == hsize &&
|
||||
sentry->scale == scale) {
|
||||
if (!sentry->query_started) {
|
||||
g_thread_pool_push(tpool, sentry, NULL);
|
||||
}
|
||||
return sentry->uid;
|
||||
}
|
||||
}
|
||||
|
@ -431,6 +782,7 @@ uint32_t rofi_icon_fetcher_query_advanced(const char *name, const int wsize,
|
|||
sentry->scale = scale;
|
||||
sentry->entry = entry;
|
||||
sentry->query_done = FALSE;
|
||||
sentry->query_started = TRUE;
|
||||
sentry->surface = NULL;
|
||||
|
||||
entry->sizes = g_list_prepend(entry->sizes, sentry);
|
||||
|
@ -461,6 +813,9 @@ uint32_t rofi_icon_fetcher_query(const char *name, const int size) {
|
|||
sentry = iter->data;
|
||||
if (sentry->wsize == size && sentry->hsize == size &&
|
||||
sentry->scale == scale) {
|
||||
if (!sentry->query_started) {
|
||||
g_thread_pool_push(tpool, sentry, NULL);
|
||||
}
|
||||
return sentry->uid;
|
||||
}
|
||||
}
|
||||
|
@ -472,6 +827,8 @@ uint32_t rofi_icon_fetcher_query(const char *name, const int size) {
|
|||
sentry->hsize = size;
|
||||
sentry->scale = scale;
|
||||
sentry->entry = entry;
|
||||
sentry->query_done = FALSE;
|
||||
sentry->query_started = TRUE;
|
||||
sentry->surface = NULL;
|
||||
|
||||
entry->sizes = g_list_prepend(entry->sizes, sentry);
|
||||
|
@ -480,6 +837,7 @@ uint32_t rofi_icon_fetcher_query(const char *name, const int size) {
|
|||
|
||||
// Push into fetching queue.
|
||||
sentry->state.callback = rofi_icon_fetcher_worker;
|
||||
sentry->state.free = rofi_icon_fetch_thread_pool_entry_remove;
|
||||
sentry->state.priority = G_PRIORITY_LOW;
|
||||
g_thread_pool_push(tpool, sentry, NULL);
|
||||
|
||||
|
|
|
@ -323,6 +323,10 @@ static void print_main_application_options(int is_term) {
|
|||
is_term);
|
||||
print_help_msg("-normal-window", "",
|
||||
"Behave as a normal window. (experimental)", NULL, is_term);
|
||||
print_help_msg("-transient-window", "",
|
||||
"Behave as a modal dialog that is transient to the currently "
|
||||
"focused window. (experimental)",
|
||||
NULL, is_term);
|
||||
print_help_msg("-show", "[mode]",
|
||||
"Show the mode 'mode' and exit. The mode has to be enabled.",
|
||||
NULL, is_term);
|
||||
|
@ -779,6 +783,9 @@ static gboolean startup(G_GNUC_UNUSED gpointer data) {
|
|||
if (find_arg("-normal-window") >= 0) {
|
||||
window_flags |= MENU_NORMAL_WINDOW;
|
||||
}
|
||||
if (find_arg("-transient-window") >= 0) {
|
||||
window_flags |= MENU_TRANSIENT_WINDOW;
|
||||
}
|
||||
TICK_N("Grab keyboard");
|
||||
__create_window(window_flags);
|
||||
TICK_N("Create Window");
|
||||
|
|
527
source/theme.c
527
source/theme.c
File diff suppressed because it is too large
Load diff
|
@ -266,9 +266,9 @@ static void rofi_view_set_user_timeout(G_GNUC_UNUSED gpointer data) {
|
|||
CacheState.user_timeout =
|
||||
g_timeout_add(delay * 1000, rofi_view_user_timeout, NULL);
|
||||
} else {
|
||||
Property *p = rofi_theme_find_property(wid, P_DOUBLE, "delay", TRUE);
|
||||
if (p != NULL && p->type == P_DOUBLE && p->value.f > 0.01) {
|
||||
double delay = p->value.f;
|
||||
Property *prop = rofi_theme_find_property(wid, P_DOUBLE, "delay", TRUE);
|
||||
if (prop != NULL && prop->type == P_DOUBLE && prop->value.f > 0.01) {
|
||||
double delay = prop->value.f;
|
||||
CacheState.user_timeout =
|
||||
g_timeout_add(delay * 1000, rofi_view_user_timeout, NULL);
|
||||
}
|
||||
|
@ -640,9 +640,9 @@ static void selection_changed_callback(G_GNUC_UNUSED listview *lv,
|
|||
int icon_height =
|
||||
widget_get_desired_height(WIDGET(state->icon_current_entry),
|
||||
WIDGET(state->icon_current_entry)->w);
|
||||
cairo_surface_t *icon =
|
||||
cairo_surface_t *surf_icon =
|
||||
mode_get_icon(state->sw, state->line_map[index], icon_height);
|
||||
icon_set_surface(state->icon_current_entry, icon);
|
||||
icon_set_surface(state->icon_current_entry, surf_icon);
|
||||
} else {
|
||||
icon_set_surface(state->icon_current_entry, NULL);
|
||||
}
|
||||
|
@ -660,9 +660,9 @@ static void update_callback(textbox *t, icon *ico, unsigned int index,
|
|||
|
||||
if (ico) {
|
||||
int icon_height = widget_get_desired_height(WIDGET(ico), WIDGET(ico)->w);
|
||||
cairo_surface_t *icon =
|
||||
cairo_surface_t *surf_icon =
|
||||
mode_get_icon(state->sw, state->line_map[index], icon_height);
|
||||
icon_set_surface(ico, icon);
|
||||
icon_set_surface(ico, surf_icon);
|
||||
}
|
||||
if (t) {
|
||||
// TODO needed for markup.
|
||||
|
@ -703,6 +703,10 @@ static void update_callback(textbox *t, icon *ico, unsigned int index,
|
|||
textbox_font(t, *type);
|
||||
}
|
||||
}
|
||||
static void page_changed_callback() {
|
||||
rofi_view_workers_finalize();
|
||||
rofi_view_workers_initialize();
|
||||
}
|
||||
|
||||
static void _rofi_view_reload_row(RofiViewState *state) {
|
||||
g_free(state->line_map);
|
||||
|
@ -1596,8 +1600,9 @@ static void rofi_view_add_widget(RofiViewState *state, widget *parent_widget,
|
|||
g_error("Listview widget can only be added once to the layout.");
|
||||
return;
|
||||
}
|
||||
state->list_view = listview_create(parent_widget, name, update_callback,
|
||||
state, config.element_height, 0);
|
||||
state->list_view =
|
||||
listview_create(parent_widget, name, update_callback,
|
||||
page_changed_callback, state, config.element_height, 0);
|
||||
listview_set_selection_changed_callback(
|
||||
state->list_view, selection_changed_callback, (void *)state);
|
||||
box_add((box *)parent_widget, WIDGET(state->list_view), TRUE);
|
||||
|
@ -1698,6 +1703,15 @@ RofiViewState *rofi_view_create(Mode *sw, const char *input,
|
|||
state->finalize = finalize;
|
||||
state->mouse_seen = FALSE;
|
||||
|
||||
// In password mode, disable the entry history.
|
||||
if ((menu_flags & MENU_PASSWORD) == MENU_PASSWORD) {
|
||||
CacheState.entry_history_enable = FALSE;
|
||||
g_debug("Disable entry history, because password setup.");
|
||||
}
|
||||
if (config.disable_history) {
|
||||
CacheState.entry_history_enable = FALSE;
|
||||
g_debug("Disable entry history, because history disable flag.");
|
||||
}
|
||||
// Request the lines to show.
|
||||
state->num_lines = mode_get_num_entries(sw);
|
||||
|
||||
|
@ -1786,14 +1800,14 @@ int rofi_view_error_dialog(const char *msg, int markup) {
|
|||
state->finalize = process_result;
|
||||
|
||||
state->main_window = box_create(NULL, "window", ROFI_ORIENTATION_VERTICAL);
|
||||
box *box = box_create(WIDGET(state->main_window), "error-message",
|
||||
ROFI_ORIENTATION_VERTICAL);
|
||||
box_add(state->main_window, WIDGET(box), TRUE);
|
||||
box *new_box = box_create(WIDGET(state->main_window), "error-message",
|
||||
ROFI_ORIENTATION_VERTICAL);
|
||||
box_add(state->main_window, WIDGET(new_box), TRUE);
|
||||
state->text =
|
||||
textbox_create(WIDGET(box), WIDGET_TYPE_TEXTBOX_TEXT, "textbox",
|
||||
textbox_create(WIDGET(new_box), WIDGET_TYPE_TEXTBOX_TEXT, "textbox",
|
||||
(TB_AUTOHEIGHT | TB_WRAP) + ((markup) ? TB_MARKUP : 0),
|
||||
NORMAL, (msg != NULL) ? msg : "", 0, 0);
|
||||
box_add(box, WIDGET(state->text), TRUE);
|
||||
box_add(new_box, WIDGET(state->text), TRUE);
|
||||
|
||||
// Make sure we enable fixed num lines when in normal window mode.
|
||||
if ((CacheState.flags & MENU_NORMAL_WINDOW) == MENU_NORMAL_WINDOW) {
|
||||
|
@ -1884,7 +1898,8 @@ void rofi_view_workers_initialize(void) {
|
|||
}
|
||||
void rofi_view_workers_finalize(void) {
|
||||
if (tpool) {
|
||||
g_thread_pool_free(tpool, TRUE, TRUE);
|
||||
// Discard all unprocessed jobs and don't wait for current jobs in execution
|
||||
g_thread_pool_free(tpool, TRUE, FALSE);
|
||||
tpool = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -284,34 +284,34 @@ static void box_free(widget *wid) {
|
|||
g_free(b);
|
||||
}
|
||||
|
||||
void box_add(box *box, widget *child, gboolean expand) {
|
||||
if (box == NULL) {
|
||||
void box_add(box *wid, widget *child, gboolean expand) {
|
||||
if (wid == NULL) {
|
||||
return;
|
||||
}
|
||||
// Make sure box is width/heigh enough.
|
||||
if (box->type == ROFI_ORIENTATION_VERTICAL) {
|
||||
int width = box->widget.w;
|
||||
if (wid->type == ROFI_ORIENTATION_VERTICAL) {
|
||||
int width = wid->widget.w;
|
||||
width =
|
||||
MAX(width, child->w + widget_padding_get_padding_width(WIDGET(box)));
|
||||
box->widget.w = width;
|
||||
MAX(width, child->w + widget_padding_get_padding_width(WIDGET(wid)));
|
||||
wid->widget.w = width;
|
||||
} else {
|
||||
int height = box->widget.h;
|
||||
int height = wid->widget.h;
|
||||
height =
|
||||
MAX(height, child->h + widget_padding_get_padding_height(WIDGET(box)));
|
||||
box->widget.h = height;
|
||||
MAX(height, child->h + widget_padding_get_padding_height(WIDGET(wid)));
|
||||
wid->widget.h = height;
|
||||
}
|
||||
child->expand = rofi_theme_get_boolean(child, "expand", expand);
|
||||
g_assert(child->parent == WIDGET(box));
|
||||
box->children = g_list_append(box->children, (void *)child);
|
||||
widget_update(WIDGET(box));
|
||||
g_assert(child->parent == WIDGET(wid));
|
||||
wid->children = g_list_append(wid->children, (void *)child);
|
||||
widget_update(WIDGET(wid));
|
||||
}
|
||||
|
||||
static void box_resize(widget *widget, short w, short h) {
|
||||
box *b = (box *)widget;
|
||||
static void box_resize(widget *wid, short w, short h) {
|
||||
box *b = (box *)wid;
|
||||
if (b->widget.w != w || b->widget.h != h) {
|
||||
b->widget.w = w;
|
||||
b->widget.h = h;
|
||||
widget_update(widget);
|
||||
widget_update(wid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,13 +42,13 @@ struct _container {
|
|||
|
||||
static void container_update(widget *wid);
|
||||
|
||||
static int container_get_desired_height(widget *widget, const int width) {
|
||||
container *b = (container *)widget;
|
||||
static int container_get_desired_height(widget *wid, const int width) {
|
||||
container *b = (container *)wid;
|
||||
int height = 0;
|
||||
if (b->child) {
|
||||
height += widget_get_desired_height(b->child, width);
|
||||
}
|
||||
height += widget_padding_get_padding_height(widget);
|
||||
height += widget_padding_get_padding_height(wid);
|
||||
return height;
|
||||
}
|
||||
|
||||
|
@ -65,21 +65,21 @@ static void container_free(widget *wid) {
|
|||
g_free(b);
|
||||
}
|
||||
|
||||
void container_add(container *container, widget *child) {
|
||||
if (container == NULL) {
|
||||
void container_add(container *cont, widget *child) {
|
||||
if (cont == NULL) {
|
||||
return;
|
||||
}
|
||||
container->child = child;
|
||||
g_assert(child->parent == WIDGET(container));
|
||||
widget_update(WIDGET(container));
|
||||
cont->child = child;
|
||||
g_assert(child->parent == WIDGET(cont));
|
||||
widget_update(WIDGET(cont));
|
||||
}
|
||||
|
||||
static void container_resize(widget *widget, short w, short h) {
|
||||
container *b = (container *)widget;
|
||||
static void container_resize(widget *wid, short w, short h) {
|
||||
container *b = (container *)wid;
|
||||
if (b->widget.w != w || b->widget.h != h) {
|
||||
b->widget.w = w;
|
||||
b->widget.h = h;
|
||||
widget_update(widget);
|
||||
widget_update(wid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,9 +53,8 @@ struct _icon {
|
|||
cairo_surface_t *icon;
|
||||
};
|
||||
|
||||
static int icon_get_desired_height(widget *widget,
|
||||
G_GNUC_UNUSED const int width) {
|
||||
icon *b = (icon *)widget;
|
||||
static int icon_get_desired_height(widget *wid, G_GNUC_UNUSED const int width) {
|
||||
icon *b = (icon *)wid;
|
||||
int height = b->size;
|
||||
if (b->squared == FALSE) {
|
||||
if (b->icon) {
|
||||
|
@ -66,12 +65,11 @@ static int icon_get_desired_height(widget *widget,
|
|||
height = iconh * scale;
|
||||
}
|
||||
}
|
||||
height += widget_padding_get_padding_height(widget);
|
||||
height += widget_padding_get_padding_height(wid);
|
||||
return height;
|
||||
}
|
||||
static int icon_get_desired_width(widget *widget,
|
||||
G_GNUC_UNUSED const int height) {
|
||||
icon *b = (icon *)widget;
|
||||
static int icon_get_desired_width(widget *wid, G_GNUC_UNUSED const int height) {
|
||||
icon *b = (icon *)wid;
|
||||
int width = b->size;
|
||||
if (b->squared == FALSE) {
|
||||
if (b->icon) {
|
||||
|
@ -82,7 +80,7 @@ static int icon_get_desired_width(widget *widget,
|
|||
width = iconw * scale;
|
||||
}
|
||||
}
|
||||
width += widget_padding_get_padding_width(widget);
|
||||
width += widget_padding_get_padding_width(wid);
|
||||
return width;
|
||||
}
|
||||
|
||||
|
@ -129,26 +127,26 @@ static void icon_free(widget *wid) {
|
|||
g_free(b);
|
||||
}
|
||||
|
||||
static void icon_resize(widget *widget, short w, short h) {
|
||||
icon *b = (icon *)widget;
|
||||
static void icon_resize(widget *wid, short w, short h) {
|
||||
icon *b = (icon *)wid;
|
||||
if (b->widget.w != w || b->widget.h != h) {
|
||||
b->widget.w = w;
|
||||
b->widget.h = h;
|
||||
widget_update(widget);
|
||||
widget_update(wid);
|
||||
}
|
||||
}
|
||||
|
||||
void icon_set_surface(icon *icon, cairo_surface_t *surf) {
|
||||
icon->icon_fetch_id = 0;
|
||||
if (icon->icon) {
|
||||
cairo_surface_destroy(icon->icon);
|
||||
icon->icon = NULL;
|
||||
void icon_set_surface(icon *icon_widget, cairo_surface_t *surf) {
|
||||
icon_widget->icon_fetch_id = 0;
|
||||
if (icon_widget->icon) {
|
||||
cairo_surface_destroy(icon_widget->icon);
|
||||
icon_widget->icon = NULL;
|
||||
}
|
||||
if (surf) {
|
||||
cairo_surface_reference(surf);
|
||||
icon->icon = surf;
|
||||
icon_widget->icon = surf;
|
||||
}
|
||||
widget_queue_redraw(WIDGET(icon));
|
||||
widget_queue_redraw(WIDGET(icon_widget));
|
||||
}
|
||||
|
||||
icon *icon_create(widget *parent, const char *name) {
|
||||
|
|
|
@ -120,6 +120,8 @@ struct _listview {
|
|||
guint32 last_click;
|
||||
listview_mouse_activated_cb mouse_activated;
|
||||
void *mouse_activated_data;
|
||||
|
||||
listview_page_changed_cb page_callback;
|
||||
|
||||
char *listview_name;
|
||||
|
||||
|
@ -284,6 +286,10 @@ static unsigned int scroll_per_page(listview *lv) {
|
|||
(lv->max_elements > 0) ? (lv->selected / lv->max_elements) : 0;
|
||||
offset = page * lv->max_elements;
|
||||
if (page != lv->cur_page) {
|
||||
|
||||
if (lv->page_callback)
|
||||
lv->page_callback();
|
||||
|
||||
lv->cur_page = page;
|
||||
lv->rchanged = TRUE;
|
||||
}
|
||||
|
@ -293,16 +299,19 @@ static unsigned int scroll_per_page(listview *lv) {
|
|||
return offset;
|
||||
}
|
||||
|
||||
static unsigned int scroll_continious(listview *lv) {
|
||||
unsigned int middle = (lv->max_rows - ((lv->max_rows & 1) == 0)) / 2;
|
||||
// For vertical packing flow
|
||||
static unsigned int scroll_continious_elements(listview *lv) {
|
||||
unsigned int vmid = (lv->max_rows - 1) / 2;
|
||||
unsigned int hmid = (lv->menu_columns - 1) / 2;
|
||||
unsigned int middle = (lv->max_rows * hmid) + vmid;
|
||||
unsigned int offset = 0;
|
||||
if (lv->selected > middle) {
|
||||
if (lv->selected < (lv->req_elements - (lv->max_rows - middle))) {
|
||||
if (lv->selected < (lv->req_elements - (lv->max_elements - middle))) {
|
||||
offset = lv->selected - middle;
|
||||
}
|
||||
// Don't go below zero.
|
||||
else if (lv->req_elements > lv->max_rows) {
|
||||
offset = lv->req_elements - lv->max_rows;
|
||||
else if (lv->req_elements > lv->max_elements) {
|
||||
offset = lv->req_elements - lv->max_elements;
|
||||
}
|
||||
}
|
||||
if (offset != lv->cur_page) {
|
||||
|
@ -313,6 +322,31 @@ static unsigned int scroll_continious(listview *lv) {
|
|||
return offset;
|
||||
}
|
||||
|
||||
// For horizontal packing flow
|
||||
static unsigned int scroll_continious_rows(listview *lv) {
|
||||
unsigned int middle, selected, req_rows, offset;
|
||||
middle = (lv->max_rows - 1) / 2;
|
||||
selected = lv->selected / lv->menu_columns;
|
||||
req_rows = (lv->req_elements + lv->menu_columns - 1) / lv->menu_columns;
|
||||
offset = 0;
|
||||
if (selected > middle) {
|
||||
if (selected < (req_rows - (lv->max_rows - middle))) {
|
||||
offset = selected - middle;
|
||||
}
|
||||
// Don't go below zero.
|
||||
else if (req_rows > lv->max_rows) {
|
||||
offset = req_rows - lv->max_rows;
|
||||
}
|
||||
}
|
||||
offset *= lv->menu_columns;
|
||||
if (offset != lv->cur_page) {
|
||||
// scrollbar_set_handle ( lv->scrollbar, offset );
|
||||
lv->cur_page = offset;
|
||||
lv->rchanged = TRUE;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
|
||||
static void update_element(listview *lv, unsigned int tb, unsigned int index,
|
||||
gboolean full) {
|
||||
// Select drawing mode
|
||||
|
@ -417,10 +451,12 @@ static void barview_draw(widget *wid, cairo_t *draw) {
|
|||
static void listview_draw(widget *wid, cairo_t *draw) {
|
||||
unsigned int offset = 0;
|
||||
listview *lv = (listview *)wid;
|
||||
if (lv->scroll_type == LISTVIEW_SCROLL_CONTINIOUS) {
|
||||
offset = scroll_continious(lv);
|
||||
} else {
|
||||
if (lv->scroll_type == LISTVIEW_SCROLL_PER_PAGE) {
|
||||
offset = scroll_per_page(lv);
|
||||
} else if (lv->pack_direction == ROFI_ORIENTATION_VERTICAL) {
|
||||
offset = scroll_continious_elements(lv);
|
||||
} else {
|
||||
offset = scroll_continious_rows(lv);
|
||||
}
|
||||
// Set these all together to make sure they update consistently.
|
||||
scrollbar_set_max_value(lv->scrollbar, lv->req_elements);
|
||||
|
@ -745,7 +781,8 @@ static gboolean listview_element_motion_notify(widget *wid,
|
|||
}
|
||||
|
||||
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) {
|
||||
listview *lv = g_malloc0(sizeof(listview));
|
||||
widget_init(WIDGET(lv), parent, WIDGET_TYPE_LISTVIEW, name);
|
||||
|
@ -782,6 +819,8 @@ listview *listview_create(widget *parent, const char *name,
|
|||
lv->callback = cb;
|
||||
lv->udata = udata;
|
||||
|
||||
lv->page_callback = page_cb;
|
||||
|
||||
// Some settings.
|
||||
lv->spacing = rofi_theme_get_distance(WIDGET(lv), "spacing", DEFAULT_SPACING);
|
||||
lv->menu_columns =
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "helper.h"
|
||||
#include "keyb.h"
|
||||
#include "mode.h"
|
||||
#include "timings.h"
|
||||
#include "view.h"
|
||||
#include "widgets/textbox.h"
|
||||
#include <ctype.h>
|
||||
|
@ -139,6 +140,22 @@ static void textbox_initialize_font(textbox *tb) {
|
|||
PangoRectangle rect;
|
||||
pango_layout_get_pixel_extents(layout, NULL, &rect);
|
||||
tbfc->height = rect.y + rect.height;
|
||||
|
||||
// Try to find height from font. Might be slow?
|
||||
TICK_N("Get font height");
|
||||
PangoFont *context_font = pango_context_load_font(p_context, tbfc->pfd);
|
||||
if (context_font) {
|
||||
PangoFontMetrics *fm = pango_font_get_metrics(context_font, NULL);
|
||||
if (fm) {
|
||||
int h = pango_font_metrics_get_height(fm) / PANGO_SCALE;
|
||||
if (h > 0) {
|
||||
tbfc->height = h;
|
||||
}
|
||||
pango_font_metrics_unref(fm);
|
||||
}
|
||||
g_object_unref(context_font);
|
||||
}
|
||||
TICK_N("Get font height");
|
||||
g_object_unref(layout);
|
||||
|
||||
// Cast away consts. (*yuck*) because table_insert does not know it is
|
||||
|
@ -501,9 +518,10 @@ static void textbox_draw(widget *wid, cairo_t *draw) {
|
|||
// use text color as fallback for themes that don't specify the cursor color
|
||||
rofi_theme_get_color(WIDGET(tb), "text-color", draw);
|
||||
|
||||
{ int rem =
|
||||
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
|
||||
line_width - dot_offset);
|
||||
{
|
||||
int rem =
|
||||
MAX(0, tb->widget.w - widget_padding_get_padding_width(WIDGET(tb)) -
|
||||
line_width - dot_offset);
|
||||
switch (pango_layout_get_alignment(tb->layout)) {
|
||||
case PANGO_ALIGN_CENTER:
|
||||
x = rem * (tb->xalign - 0.5);
|
||||
|
@ -941,6 +959,12 @@ void textbox_set_pango_context(const char *font, PangoContext *p) {
|
|||
PangoRectangle rect;
|
||||
pango_layout_get_pixel_extents(layout, NULL, &rect);
|
||||
tbfc->height = rect.y + rect.height;
|
||||
if (tbfc->metrics) {
|
||||
int h = pango_font_metrics_get_height(tbfc->metrics) / PANGO_SCALE;
|
||||
if (h > 0) {
|
||||
tbfc->height = h;
|
||||
}
|
||||
}
|
||||
g_object_unref(layout);
|
||||
tbfc_default = tbfc;
|
||||
|
||||
|
|
|
@ -55,126 +55,125 @@ void widget_init(widget *wid, widget *parent, WidgetType type,
|
|||
wid->enabled = rofi_theme_get_boolean(wid, "enabled", TRUE);
|
||||
}
|
||||
|
||||
void widget_set_state(widget *widget, const char *state) {
|
||||
if (widget == NULL) {
|
||||
void widget_set_state(widget *wid, const char *state) {
|
||||
if (wid == NULL) {
|
||||
return;
|
||||
}
|
||||
if (g_strcmp0(widget->state, state)) {
|
||||
widget->state = state;
|
||||
if (g_strcmp0(wid->state, state)) {
|
||||
wid->state = state;
|
||||
// Update border.
|
||||
widget->border =
|
||||
rofi_theme_get_padding(widget, "border", widget->def_border);
|
||||
widget->border_radius = rofi_theme_get_padding(widget, "border-radius",
|
||||
widget->def_border_radius);
|
||||
if (widget->set_state != NULL) {
|
||||
widget->set_state(widget, state);
|
||||
wid->border = rofi_theme_get_padding(wid, "border", wid->def_border);
|
||||
wid->border_radius =
|
||||
rofi_theme_get_padding(wid, "border-radius", wid->def_border_radius);
|
||||
if (wid->set_state != NULL) {
|
||||
wid->set_state(wid, state);
|
||||
}
|
||||
widget_queue_redraw(widget);
|
||||
widget_queue_redraw(wid);
|
||||
}
|
||||
}
|
||||
|
||||
int widget_intersect(const widget *widget, int x, int y) {
|
||||
if (widget == NULL) {
|
||||
int widget_intersect(const widget *wid, int x, int y) {
|
||||
if (wid == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (x >= (widget->x) && x < (widget->x + widget->w) && y >= (widget->y) &&
|
||||
y < (widget->y + widget->h)) {
|
||||
if (x >= (wid->x) && x < (wid->x + wid->w) && y >= (wid->y) &&
|
||||
y < (wid->y + wid->h)) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void widget_resize(widget *widget, short w, short h) {
|
||||
if (widget == NULL) {
|
||||
void widget_resize(widget *wid, short w, short h) {
|
||||
if (wid == NULL) {
|
||||
return;
|
||||
}
|
||||
if (widget->resize != NULL) {
|
||||
if (widget->w != w || widget->h != h) {
|
||||
widget->resize(widget, w, h);
|
||||
if (wid->resize != NULL) {
|
||||
if (wid->w != w || wid->h != h) {
|
||||
wid->resize(wid, w, h);
|
||||
}
|
||||
} else {
|
||||
widget->w = w;
|
||||
widget->h = h;
|
||||
wid->w = w;
|
||||
wid->h = h;
|
||||
}
|
||||
// On a resize we always want to update.
|
||||
widget_queue_redraw(widget);
|
||||
widget_queue_redraw(wid);
|
||||
}
|
||||
void widget_move(widget *widget, short x, short y) {
|
||||
if (widget == NULL) {
|
||||
void widget_move(widget *wid, short x, short y) {
|
||||
if (wid == NULL) {
|
||||
return;
|
||||
}
|
||||
widget->x = x;
|
||||
widget->y = y;
|
||||
wid->x = x;
|
||||
wid->y = y;
|
||||
}
|
||||
void widget_set_type(widget *widget, WidgetType type) {
|
||||
if (widget == NULL) {
|
||||
void widget_set_type(widget *wid, WidgetType type) {
|
||||
if (wid == NULL) {
|
||||
return;
|
||||
}
|
||||
widget->type = type;
|
||||
wid->type = type;
|
||||
}
|
||||
|
||||
gboolean widget_enabled(widget *widget) {
|
||||
if (widget == NULL) {
|
||||
gboolean widget_enabled(widget *wid) {
|
||||
if (wid == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
return widget->enabled;
|
||||
return wid->enabled;
|
||||
}
|
||||
|
||||
void widget_set_enabled(widget *widget, gboolean enabled) {
|
||||
if (widget == NULL) {
|
||||
void widget_set_enabled(widget *wid, gboolean enabled) {
|
||||
if (wid == NULL) {
|
||||
return;
|
||||
}
|
||||
if (widget->enabled != enabled) {
|
||||
widget->enabled = enabled;
|
||||
widget_update(widget);
|
||||
widget_update(widget->parent);
|
||||
widget_queue_redraw(widget);
|
||||
if (wid->enabled != enabled) {
|
||||
wid->enabled = enabled;
|
||||
widget_update(wid);
|
||||
widget_update(wid->parent);
|
||||
widget_queue_redraw(wid);
|
||||
}
|
||||
}
|
||||
|
||||
void widget_draw(widget *widget, cairo_t *d) {
|
||||
if (widget == NULL) {
|
||||
void widget_draw(widget *wid, cairo_t *d) {
|
||||
if (wid == NULL) {
|
||||
return;
|
||||
}
|
||||
// Check if enabled and if draw is implemented.
|
||||
if (widget->enabled && widget->draw) {
|
||||
if (wid->enabled && wid->draw) {
|
||||
// Don't draw if there is no space.
|
||||
if (widget->h < 1 || widget->w < 1) {
|
||||
widget->need_redraw = FALSE;
|
||||
if (wid->h < 1 || wid->w < 1) {
|
||||
wid->need_redraw = FALSE;
|
||||
return;
|
||||
}
|
||||
// Store current state.
|
||||
cairo_save(d);
|
||||
const int margin_left =
|
||||
distance_get_pixel(widget->margin.left, ROFI_ORIENTATION_HORIZONTAL);
|
||||
distance_get_pixel(wid->margin.left, ROFI_ORIENTATION_HORIZONTAL);
|
||||
const int margin_top =
|
||||
distance_get_pixel(widget->margin.top, ROFI_ORIENTATION_VERTICAL);
|
||||
distance_get_pixel(wid->margin.top, ROFI_ORIENTATION_VERTICAL);
|
||||
const int margin_right =
|
||||
distance_get_pixel(widget->margin.right, ROFI_ORIENTATION_HORIZONTAL);
|
||||
distance_get_pixel(wid->margin.right, ROFI_ORIENTATION_HORIZONTAL);
|
||||
const int margin_bottom =
|
||||
distance_get_pixel(widget->margin.bottom, ROFI_ORIENTATION_VERTICAL);
|
||||
distance_get_pixel(wid->margin.bottom, ROFI_ORIENTATION_VERTICAL);
|
||||
const int left =
|
||||
distance_get_pixel(widget->border.left, ROFI_ORIENTATION_HORIZONTAL);
|
||||
distance_get_pixel(wid->border.left, ROFI_ORIENTATION_HORIZONTAL);
|
||||
const int right =
|
||||
distance_get_pixel(widget->border.right, ROFI_ORIENTATION_HORIZONTAL);
|
||||
distance_get_pixel(wid->border.right, ROFI_ORIENTATION_HORIZONTAL);
|
||||
const int top =
|
||||
distance_get_pixel(widget->border.top, ROFI_ORIENTATION_VERTICAL);
|
||||
distance_get_pixel(wid->border.top, ROFI_ORIENTATION_VERTICAL);
|
||||
const int bottom =
|
||||
distance_get_pixel(widget->border.bottom, ROFI_ORIENTATION_VERTICAL);
|
||||
int radius_bl = distance_get_pixel(widget->border_radius.left,
|
||||
distance_get_pixel(wid->border.bottom, ROFI_ORIENTATION_VERTICAL);
|
||||
int radius_bl = distance_get_pixel(wid->border_radius.left,
|
||||
ROFI_ORIENTATION_HORIZONTAL);
|
||||
int radius_tr = distance_get_pixel(widget->border_radius.right,
|
||||
int radius_tr = distance_get_pixel(wid->border_radius.right,
|
||||
ROFI_ORIENTATION_HORIZONTAL);
|
||||
int radius_tl = distance_get_pixel(widget->border_radius.top,
|
||||
ROFI_ORIENTATION_VERTICAL);
|
||||
int radius_br = distance_get_pixel(widget->border_radius.bottom,
|
||||
int radius_tl =
|
||||
distance_get_pixel(wid->border_radius.top, ROFI_ORIENTATION_VERTICAL);
|
||||
int radius_br = distance_get_pixel(wid->border_radius.bottom,
|
||||
ROFI_ORIENTATION_VERTICAL);
|
||||
|
||||
double vspace =
|
||||
widget->h - margin_top - margin_bottom - top / 2.0 - bottom / 2.0;
|
||||
wid->h - margin_top - margin_bottom - top / 2.0 - bottom / 2.0;
|
||||
double hspace =
|
||||
widget->w - margin_left - margin_right - left / 2.0 - right / 2.0;
|
||||
wid->w - margin_left - margin_right - left / 2.0 - right / 2.0;
|
||||
if ((radius_bl + radius_tl) > (vspace)) {
|
||||
int j = ((vspace) / 2.0);
|
||||
radius_bl = MIN(radius_bl, j);
|
||||
|
@ -198,14 +197,14 @@ void widget_draw(widget *widget, cairo_t *d) {
|
|||
|
||||
// Background painting.
|
||||
// Set new x/y position.
|
||||
cairo_translate(d, widget->x, widget->y);
|
||||
cairo_translate(d, wid->x, wid->y);
|
||||
cairo_set_line_width(d, 0);
|
||||
|
||||
// Outer outline outlines
|
||||
double x1, y1, x2, y2;
|
||||
x1 = margin_left + left / 2.0, y1 = margin_top + top / 2.0,
|
||||
x2 = widget->w - margin_right - right / 2.0,
|
||||
y2 = widget->h - margin_bottom - bottom / 2.0;
|
||||
x2 = wid->w - margin_right - right / 2.0,
|
||||
y2 = wid->h - margin_bottom - bottom / 2.0;
|
||||
|
||||
if (radius_tl > 0) {
|
||||
cairo_move_to(d, x1, y1 + radius_tl);
|
||||
|
@ -238,15 +237,15 @@ void widget_draw(widget *widget, cairo_t *d) {
|
|||
cairo_close_path(d);
|
||||
|
||||
cairo_set_source_rgba(d, 1.0, 1.0, 1.0, 1.0);
|
||||
rofi_theme_get_color(widget, "background-color", d);
|
||||
rofi_theme_get_color(wid, "background-color", d);
|
||||
cairo_fill_preserve(d);
|
||||
if (rofi_theme_get_image(widget, "background-image", d)) {
|
||||
if (rofi_theme_get_image(wid, "background-image", d)) {
|
||||
cairo_fill_preserve(d);
|
||||
}
|
||||
cairo_clip(d);
|
||||
|
||||
widget->draw(widget, d);
|
||||
widget->need_redraw = FALSE;
|
||||
wid->draw(wid, d);
|
||||
wid->need_redraw = FALSE;
|
||||
|
||||
cairo_restore(d);
|
||||
|
||||
|
@ -255,9 +254,9 @@ void widget_draw(widget *widget, cairo_t *d) {
|
|||
// thus no need for these.
|
||||
cairo_push_group(d);
|
||||
cairo_set_operator(d, CAIRO_OPERATOR_ADD);
|
||||
cairo_translate(d, widget->x, widget->y);
|
||||
cairo_translate(d, wid->x, wid->y);
|
||||
cairo_new_path(d);
|
||||
rofi_theme_get_color(widget, "border-color", d);
|
||||
rofi_theme_get_color(wid, "border-color", d);
|
||||
|
||||
// Calculate the different offsets for the corners.
|
||||
double minof_tr = MIN(right / 2.0, top / 2.0);
|
||||
|
@ -309,30 +308,30 @@ void widget_draw(widget *widget, cairo_t *d) {
|
|||
|
||||
if (left > 0) {
|
||||
cairo_set_line_width(d, left);
|
||||
distance_get_linestyle(widget->border.left, d);
|
||||
distance_get_linestyle(wid->border.left, d);
|
||||
cairo_move_to(d, x1, margin_top + offset_ttl);
|
||||
cairo_line_to(d, x1, widget->h - margin_bottom - offset_bbl);
|
||||
cairo_line_to(d, x1, wid->h - margin_bottom - offset_bbl);
|
||||
cairo_stroke(d);
|
||||
}
|
||||
if (right > 0) {
|
||||
cairo_set_line_width(d, right);
|
||||
distance_get_linestyle(widget->border.right, d);
|
||||
distance_get_linestyle(wid->border.right, d);
|
||||
cairo_move_to(d, x2, margin_top + offset_ttr);
|
||||
cairo_line_to(d, x2, widget->h - margin_bottom - offset_bbr);
|
||||
cairo_line_to(d, x2, wid->h - margin_bottom - offset_bbr);
|
||||
cairo_stroke(d);
|
||||
}
|
||||
if (top > 0) {
|
||||
cairo_set_line_width(d, top);
|
||||
distance_get_linestyle(widget->border.top, d);
|
||||
distance_get_linestyle(wid->border.top, d);
|
||||
cairo_move_to(d, margin_left + offset_ltl, y1);
|
||||
cairo_line_to(d, widget->w - margin_right - offset_rtr, y1);
|
||||
cairo_line_to(d, wid->w - margin_right - offset_rtr, y1);
|
||||
cairo_stroke(d);
|
||||
}
|
||||
if (bottom > 0) {
|
||||
cairo_set_line_width(d, bottom);
|
||||
distance_get_linestyle(widget->border.bottom, d);
|
||||
distance_get_linestyle(wid->border.bottom, d);
|
||||
cairo_move_to(d, margin_left + offset_lbl, y2);
|
||||
cairo_line_to(d, widget->w - margin_right - offset_rbr, y2);
|
||||
cairo_line_to(d, wid->w - margin_right - offset_rbr, y2);
|
||||
cairo_stroke(d);
|
||||
}
|
||||
if (radius_tl > 0) {
|
||||
|
@ -353,61 +352,59 @@ void widget_draw(widget *widget, cairo_t *d) {
|
|||
}
|
||||
if (radius_tr > 0) {
|
||||
double radius_outer = radius_tr + minof_tr;
|
||||
cairo_arc(d, widget->w - margin_right - radius_outer,
|
||||
cairo_arc(d, wid->w - margin_right - radius_outer,
|
||||
margin_top + radius_outer, radius_outer, -G_PI_2, 0);
|
||||
cairo_line_to(d, widget->w - margin_right, margin_top + offset_ttr);
|
||||
cairo_line_to(d, widget->w - margin_right - right,
|
||||
cairo_line_to(d, wid->w - margin_right, margin_top + offset_ttr);
|
||||
cairo_line_to(d, wid->w - margin_right - right,
|
||||
margin_top + offset_ttr);
|
||||
if (radius_inner_tr > 0) {
|
||||
cairo_arc_negative(
|
||||
d, widget->w - margin_right - right - radius_inner_tr,
|
||||
margin_top + top + radius_inner_tr, radius_inner_tr, 0, -G_PI_2);
|
||||
cairo_line_to(d, widget->w - margin_right - offset_rtr,
|
||||
cairo_arc_negative(d, wid->w - margin_right - right - radius_inner_tr,
|
||||
margin_top + top + radius_inner_tr,
|
||||
radius_inner_tr, 0, -G_PI_2);
|
||||
cairo_line_to(d, wid->w - margin_right - offset_rtr,
|
||||
margin_top + top);
|
||||
}
|
||||
cairo_line_to(d, widget->w - margin_right - offset_rtr, margin_top);
|
||||
cairo_line_to(d, wid->w - margin_right - offset_rtr, margin_top);
|
||||
cairo_close_path(d);
|
||||
cairo_fill(d);
|
||||
}
|
||||
if (radius_br > 0) {
|
||||
double radius_outer = radius_br + minof_br;
|
||||
cairo_arc(d, widget->w - margin_right - radius_outer,
|
||||
widget->h - margin_bottom - radius_outer, radius_outer, 0.0,
|
||||
cairo_arc(d, wid->w - margin_right - radius_outer,
|
||||
wid->h - margin_bottom - radius_outer, radius_outer, 0.0,
|
||||
G_PI_2);
|
||||
cairo_line_to(d, widget->w - margin_right - offset_rbr,
|
||||
widget->h - margin_bottom);
|
||||
cairo_line_to(d, widget->w - margin_right - offset_rbr,
|
||||
widget->h - margin_bottom - bottom);
|
||||
cairo_line_to(d, wid->w - margin_right - offset_rbr,
|
||||
wid->h - margin_bottom);
|
||||
cairo_line_to(d, wid->w - margin_right - offset_rbr,
|
||||
wid->h - margin_bottom - bottom);
|
||||
if (radius_inner_br > 0) {
|
||||
cairo_arc_negative(
|
||||
d, widget->w - margin_right - right - radius_inner_br,
|
||||
widget->h - margin_bottom - bottom - radius_inner_br,
|
||||
radius_inner_br, G_PI_2, 0.0);
|
||||
cairo_line_to(d, widget->w - margin_right - right,
|
||||
widget->h - margin_bottom - offset_bbr);
|
||||
cairo_arc_negative(d, wid->w - margin_right - right - radius_inner_br,
|
||||
wid->h - margin_bottom - bottom - radius_inner_br,
|
||||
radius_inner_br, G_PI_2, 0.0);
|
||||
cairo_line_to(d, wid->w - margin_right - right,
|
||||
wid->h - margin_bottom - offset_bbr);
|
||||
}
|
||||
cairo_line_to(d, widget->w - margin_right,
|
||||
widget->h - margin_bottom - offset_bbr);
|
||||
cairo_line_to(d, wid->w - margin_right,
|
||||
wid->h - margin_bottom - offset_bbr);
|
||||
cairo_close_path(d);
|
||||
cairo_fill(d);
|
||||
}
|
||||
if (radius_bl > 0) {
|
||||
double radius_outer = radius_bl + minof_bl;
|
||||
cairo_arc(d, margin_left + radius_outer,
|
||||
widget->h - margin_bottom - radius_outer, radius_outer,
|
||||
G_PI_2, G_PI);
|
||||
cairo_line_to(d, margin_left, widget->h - margin_bottom - offset_bbl);
|
||||
wid->h - margin_bottom - radius_outer, radius_outer, G_PI_2,
|
||||
G_PI);
|
||||
cairo_line_to(d, margin_left, wid->h - margin_bottom - offset_bbl);
|
||||
cairo_line_to(d, margin_left + left,
|
||||
widget->h - margin_bottom - offset_bbl);
|
||||
wid->h - margin_bottom - offset_bbl);
|
||||
if (radius_inner_bl > 0) {
|
||||
cairo_arc_negative(d, margin_left + left + radius_inner_bl,
|
||||
widget->h - margin_bottom - bottom -
|
||||
radius_inner_bl,
|
||||
wid->h - margin_bottom - bottom - radius_inner_bl,
|
||||
radius_inner_bl, G_PI, G_PI_2);
|
||||
cairo_line_to(d, margin_left + offset_lbl,
|
||||
widget->h - margin_bottom - bottom);
|
||||
wid->h - margin_bottom - bottom);
|
||||
}
|
||||
cairo_line_to(d, margin_left + offset_lbl, widget->h - margin_bottom);
|
||||
cairo_line_to(d, margin_left + offset_lbl, wid->h - margin_bottom);
|
||||
cairo_close_path(d);
|
||||
|
||||
cairo_fill(d);
|
||||
|
@ -430,53 +427,53 @@ void widget_free(widget *wid) {
|
|||
}
|
||||
}
|
||||
|
||||
int widget_get_height(widget *widget) {
|
||||
if (widget == NULL) {
|
||||
int widget_get_height(widget *wid) {
|
||||
if (wid == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (widget->get_height == NULL) {
|
||||
return widget->h;
|
||||
if (wid->get_height == NULL) {
|
||||
return wid->h;
|
||||
}
|
||||
return widget->get_height(widget);
|
||||
return wid->get_height(wid);
|
||||
}
|
||||
int widget_get_width(widget *widget) {
|
||||
if (widget == NULL) {
|
||||
int widget_get_width(widget *wid) {
|
||||
if (wid == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (widget->get_width == NULL) {
|
||||
return widget->w;
|
||||
if (wid->get_width == NULL) {
|
||||
return wid->w;
|
||||
}
|
||||
return widget->get_width(widget);
|
||||
return wid->get_width(wid);
|
||||
}
|
||||
int widget_get_x_pos(widget *widget) {
|
||||
if (widget == NULL) {
|
||||
int widget_get_x_pos(widget *wid) {
|
||||
if (wid == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return widget->x;
|
||||
return wid->x;
|
||||
}
|
||||
int widget_get_y_pos(widget *widget) {
|
||||
if (widget == NULL) {
|
||||
int widget_get_y_pos(widget *wid) {
|
||||
if (wid == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return widget->y;
|
||||
return wid->y;
|
||||
}
|
||||
|
||||
void widget_xy_to_relative(widget *widget, gint *x, gint *y) {
|
||||
*x -= widget->x;
|
||||
*y -= widget->y;
|
||||
if (widget->parent == NULL) {
|
||||
void widget_xy_to_relative(widget *wid, gint *x, gint *y) {
|
||||
*x -= wid->x;
|
||||
*y -= wid->y;
|
||||
if (wid->parent == NULL) {
|
||||
return;
|
||||
}
|
||||
widget_xy_to_relative(widget->parent, x, y);
|
||||
widget_xy_to_relative(wid->parent, x, y);
|
||||
}
|
||||
|
||||
void widget_update(widget *widget) {
|
||||
if (widget == NULL) {
|
||||
void widget_update(widget *wid) {
|
||||
if (wid == NULL) {
|
||||
return;
|
||||
}
|
||||
// When (desired )size of widget changes.
|
||||
if (widget->update != NULL) {
|
||||
widget->update(widget);
|
||||
// When (desired )size of wid changes.
|
||||
if (wid->update != NULL) {
|
||||
wid->update(wid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#ifdef XCB_IMDKIT
|
||||
#include <xcb-imdkit/encoding.h>
|
||||
#include <xcb/xcb_keysyms.h>
|
||||
#endif
|
||||
#include <cairo-xcb.h>
|
||||
#include <cairo.h>
|
||||
|
@ -91,6 +92,7 @@ struct _xcb_stuff xcb_int = {.connection = NULL,
|
|||
.screen = NULL,
|
||||
#ifdef XCB_IMDKIT
|
||||
.im = NULL,
|
||||
.syms = NULL,
|
||||
#endif
|
||||
.screen_nbr = -1,
|
||||
.sndisplay = NULL,
|
||||
|
@ -127,13 +129,13 @@ const struct {
|
|||
} cursor_names[] = {
|
||||
{"default", "left_ptr"}, {"pointer", "hand"}, {"text", "xterm"}};
|
||||
|
||||
static xcb_visualtype_t *lookup_visual(xcb_screen_t *s, xcb_visualid_t visual) {
|
||||
static xcb_visualtype_t *lookup_visual(xcb_screen_t *s, xcb_visualid_t vis) {
|
||||
xcb_depth_iterator_t d;
|
||||
d = xcb_screen_allowed_depths_iterator(s);
|
||||
for (; d.rem; xcb_depth_next(&d)) {
|
||||
xcb_visualtype_iterator_t v = xcb_depth_visuals_iterator(d.data);
|
||||
for (; v.rem; xcb_visualtype_next(&v)) {
|
||||
if (v.data->visual_id == visual) {
|
||||
if (v.data->visual_id == vis) {
|
||||
return v.data;
|
||||
}
|
||||
}
|
||||
|
@ -1188,7 +1190,7 @@ static gboolean x11_button_to_nk_bindings_scroll(guint32 x11_button,
|
|||
static void rofi_key_press_event_handler(xcb_key_press_event_t *xkpe,
|
||||
RofiViewState *state) {
|
||||
gchar *text;
|
||||
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "press handler");
|
||||
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "press handler %d", xkpe->detail);
|
||||
|
||||
xcb->last_timestamp = xkpe->time;
|
||||
if (config.xserver_i300_workaround) {
|
||||
|
@ -1207,6 +1209,7 @@ static void rofi_key_press_event_handler(xcb_key_press_event_t *xkpe,
|
|||
|
||||
static void rofi_key_release_event_handler(xcb_key_release_event_t *xkre,
|
||||
G_GNUC_UNUSED RofiViewState *state) {
|
||||
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "release handler %d", xkre->detail);
|
||||
xcb->last_timestamp = xkre->time;
|
||||
nk_bindings_seat_handle_key(xcb->bindings_seat, NULL, xkre->detail,
|
||||
NK_BINDINGS_KEY_STATE_RELEASE);
|
||||
|
@ -1371,8 +1374,9 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) {
|
|||
xcb_key_press_event_t *xkpe = (xcb_key_press_event_t *)event;
|
||||
#ifdef XCB_IMDKIT
|
||||
if (xcb->ic) {
|
||||
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "input xim");
|
||||
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "press key %d to xim", xkpe->detail);
|
||||
xcb_xim_forward_event(xcb->im, xcb->ic, xkpe);
|
||||
return;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
@ -1384,7 +1388,19 @@ static void main_loop_x11_event_handler_view(xcb_generic_event_t *event) {
|
|||
xcb_key_release_event_t *xkre = (xcb_key_release_event_t *)event;
|
||||
#ifdef XCB_IMDKIT
|
||||
if (xcb->ic) {
|
||||
g_log("IMDKit", G_LOG_LEVEL_DEBUG, "release key %d to xim", xkre->detail);
|
||||
|
||||
// Check if the keysym is a modifier key (e.g., Shift, Ctrl, Alt). If it
|
||||
// is, sleep for 5 milliseconds as a workaround for XCB XIM limitation.
|
||||
// This sleep helps to ensure that XCB XIM can properly handle subsequent
|
||||
// key events that may occur rapidly after a modifier key is pressed.
|
||||
xcb_keysym_t sym = xcb_key_press_lookup_keysym(xcb->syms, xkre, 0);
|
||||
if (xcb_is_modifier_key(sym)) {
|
||||
struct timespec five_millis = {.tv_sec = 0, .tv_nsec = 5000000};
|
||||
nanosleep(&five_millis, NULL);
|
||||
}
|
||||
xcb_xim_forward_event(xcb->im, xcb->ic, xkre);
|
||||
return;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
@ -1407,6 +1423,7 @@ void x11_event_handler_fowarding(G_GNUC_UNUSED xcb_xim_t *im,
|
|||
if (state == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t type = event->response_type & ~0x80;
|
||||
if (type == XCB_KEY_PRESS) {
|
||||
rofi_key_press_event_handler(event, state);
|
||||
|
@ -1414,6 +1431,7 @@ void x11_event_handler_fowarding(G_GNUC_UNUSED xcb_xim_t *im,
|
|||
xcb_key_release_event_t *xkre = (xcb_key_release_event_t *)event;
|
||||
rofi_key_release_event_handler(xkre, state);
|
||||
}
|
||||
rofi_view_maybe_update(state);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1434,9 +1452,8 @@ static gboolean main_loop_x11_event_handler(xcb_generic_event_t *ev,
|
|||
}
|
||||
|
||||
#ifdef XCB_IMDKIT
|
||||
if (xcb->im && xcb_xim_filter_event(xcb->im, ev)) {
|
||||
if (xcb->im && xcb_xim_filter_event(xcb->im, ev))
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint8_t type = ev->response_type & ~0x80;
|
||||
|
@ -1670,6 +1687,7 @@ static gboolean xcb_display_setup(GMainLoop *main_loop, NkBindings *bindings) {
|
|||
xcb->connection = g_water_xcb_source_get_connection(xcb->source);
|
||||
#ifdef XCB_IMDKIT
|
||||
xcb->im = xcb_xim_create(xcb->connection, xcb->screen_nbr, NULL);
|
||||
xcb->syms = xcb_key_symbols_alloc(xcb->connection);
|
||||
#endif
|
||||
|
||||
#ifdef XCB_IMDKIT
|
||||
|
@ -1892,7 +1910,7 @@ static gboolean xcb_display_late_setup(void) {
|
|||
// Try to grab the keyboard as early as possible.
|
||||
// We grab this using the rootwindow (as dmenu does it).
|
||||
// this seems to result in the smallest delay for most people.
|
||||
if (find_arg("-normal-window") >= 0) {
|
||||
if (find_arg("-normal-window") >= 0 || find_arg("-transient-window") >= 0) {
|
||||
return TRUE;
|
||||
}
|
||||
if (find_arg("-no-lazy-grab") >= 0) {
|
||||
|
|
|
@ -124,6 +124,13 @@ static XrmOption xrmOptions[] = {
|
|||
NULL,
|
||||
"Whether to load and show icons",
|
||||
CONFIG_DEFAULT},
|
||||
|
||||
{xrm_String,
|
||||
"preview-cmd",
|
||||
{.str = &config.preview_cmd},
|
||||
NULL,
|
||||
"Custom command to generate preview icons",
|
||||
CONFIG_DEFAULT},
|
||||
|
||||
{xrm_String,
|
||||
"terminal",
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 42a145150cff135be377754486c504836ddea836
|
||||
Subproject commit d86f9903efb9c490c0e3b0316d7f2da5b5a5632c
|
|
@ -59,6 +59,12 @@ int rofi_is_in_dmenu_mode = 0;
|
|||
|
||||
ThemeWidget *rofi_configuration = NULL;
|
||||
|
||||
void rofi_timings_tick(G_GNUC_UNUSED const char *file,
|
||||
G_GNUC_UNUSED char const *str, G_GNUC_UNUSED int line,
|
||||
G_GNUC_UNUSED char const *msg);
|
||||
void rofi_timings_tick(G_GNUC_UNUSED const char *file,
|
||||
G_GNUC_UNUSED char const *str, G_GNUC_UNUSED int line,
|
||||
G_GNUC_UNUSED char const *msg) {}
|
||||
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
|
||||
G_GNUC_UNUSED const int size) {
|
||||
return 0;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*/
|
||||
|
||||
#include "display.h"
|
||||
#include "glibconfig.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "rofi.h"
|
||||
#include "xrmoptions.h"
|
||||
|
@ -57,6 +58,12 @@ uint32_t rofi_icon_fetcher_query_advanced(G_GNUC_UNUSED const char *name,
|
|||
G_GNUC_UNUSED const int hsize) {
|
||||
return 0;
|
||||
}
|
||||
void rofi_timings_tick(G_GNUC_UNUSED const char *file,
|
||||
G_GNUC_UNUSED char const *str, G_GNUC_UNUSED int line,
|
||||
G_GNUC_UNUSED char const *msg);
|
||||
void rofi_timings_tick(G_GNUC_UNUSED const char *file,
|
||||
G_GNUC_UNUSED char const *str, G_GNUC_UNUSED int line,
|
||||
G_GNUC_UNUSED char const *msg) {}
|
||||
|
||||
cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in a new issue