1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00

Merge branch 'master' into wip/wayland

This commit is contained in:
Quentin Glidic 2017-03-28 22:56:33 +02:00
commit b25439c633
No known key found for this signature in database
GPG key ID: AC203F96E2C34BB7
19 changed files with 207 additions and 136 deletions

View file

@ -1,5 +1,10 @@
# Installation guide
This guide explains how to install rofi using its build system and how you can make debug builds.
Rofi uses autotools (GNU Build system), for more information see
[here](https://www.gnu.org/software/automake/manual/html_node/Autotools-Introduction.html).
## DEPENDENCY
### For building:
@ -20,6 +25,8 @@
* libcairo
* libcairo-xcb
* libglib2.0 >= 2.40
* gmodule-2.0
* gio-unix-2.0
* libstartup-notification-1.0
* libxkbcommon >= 0.5.0
* libxkbcommon-x11
@ -51,6 +58,7 @@ The actual install, execute as root (if needed):
make install
```
The default installation prefix is: `/usr/local/` use `./configure --prefix={prefix}` to install into another location.
## Install a checkout from git
@ -59,6 +67,14 @@ The GitHub Pages version of these directions may be out of date. Please use
[master-install]: https://github.com/DaveDavenport/rofi/blob/master/INSTALL.md#install-a-checkout-from-git
Make a checkout:
```
git clone https://github.com/DaveDavenport/rofi
cd rofi/
```
Pull in dependencies
```
@ -142,7 +158,7 @@ make V=1
### Debug build
Compile with debug symbols and no optimization
Compile with debug symbols and no optimization, this is useful for making backtraces:
```
make CFLAGS="-O0 -g3" clean rofi
@ -159,12 +175,15 @@ can then load the core in GDB.
gdb rofi core
```
> Where the core file is located and what its exact name is different on each distributions. Please consult the
> relevant documentation.
## Install distribution
### Debian or Ubuntu
```
apt-get install rofi
apt install rofi
```
@ -174,3 +193,9 @@ rofi from [russianfedora repository](http://ru.fedoracommunity.org/repository)
and also
[Yaroslav's COPR (Cool Other Package Repo)](https://copr.fedorainfracloud.org/coprs/yaroslav/i3desktop/)
### ArchLinux
```
pacman -S rofi
```

View file

@ -19,6 +19,10 @@ BUILT_SOURCES=\
lexer/theme-parser.c\
lexer/theme-lexer.c
$(top_builddir)/lexer/theme-lexer.c: $(top_srcdir)/lexer/theme-lexer.l
$(top_builddir)/lexer/theme-parser.c $(top_builddir)/lexer/theme-parser.h: $(top_srcdir)/lexer/theme-parser.y
rofiincludedir=${includedir}/rofi
rofiinclude_HEADERS=\
include/mode.h\

View file

@ -7,13 +7,13 @@
[![Coverity](https://scan.coverity.com/projects/3850/badge.svg)](https://scan.coverity.com/projects/davedavenport-rofi)
[![Forum](https://img.shields.io/badge/forum-online-green.svg)](https://forum.qtools.org)
# A window switcher, run dialog and dmenu replacement
# A window switcher, Application launcher and dmenu replacement
**Rofi** started as clone of simpleswitcher, written by [Sean Pringle](http://github.com/seanpringle/simpleswitcher) a
popup window switcher roughly based on [superswitcher](http://code.google.com/p/superswitcher/).
Simpleswitcher laid the foundations and therefor Sean Pringle deserves most of the credit for this tool. **Rofi**,
renamed as it lost the *simple* property, has been extended with extra features, like a run-dialog, ssh-launcher and
can act as a drop-in dmenu replacement, making it a very versatile tool.
renamed as it lost the *simple* property, has been extended with extra features, like a application launcher,
ssh-launcher and can act as a drop-in dmenu replacement, making it a very versatile tool.
**Rofi**, like dmenu, will provide the user with a textual list of options where one or more can be selected.
This can either be, running an application, selecting a window or options provided by an external script.
@ -33,8 +33,8 @@ It main features are:
* Build in modes:
- Window switcher mode.
- EWMH compatible WM.
- Run mode.
- Desktop File Run mode.
- Application launcher.
- Desktop File Application launcher.
- SSH launcher mode.
- Combi mode, allow several modes to be merged into one list.
* History based ordering last 25 choices are ordered on top based on use. (optional)
@ -65,7 +65,7 @@ Window mode features:
- Custom command by `Shift-Return`
## Run mode
## Application launcher
![run mode](https://davedavenport.github.io/rofi/images/rofi/run-dialog.png)
@ -78,7 +78,7 @@ Run mode features:
- Execute command to add custom entries, like aliases.
## DRun mode
## Desktop File Application launcher
The desktop run mode allows users to quickly search and launch an application from the *freedesktop.org* Desktop
Entries. These are used by most common Desktop Environments to populate launchers and menus.
@ -240,7 +240,7 @@ The boolean option has a non-default commandline syntax, to enable option X you
to disable it:
rofi -no-X
# Manpage
For more detailed information, please see the [manpage](doc/rofi-manpage.markdown), the [wiki](https://github.com/DaveDavenport/rofi/wiki) or the [forum](https://forum.qtools.org).

View file

@ -167,6 +167,16 @@ echo "Window Switcher dialog Enabled"
else
echo "Window Switcher dialog Disabled"
fi
if test x$enable_asan = xyes; then
echo "Asan address sanitize Enabled"
else
echo "Asan address sanitize Disabled"
fi
if test x$enable_gcov = xyes; then
echo "Code Coverage Enabled"
else
echo "Code Coverage Disabled"
fi
echo "-------------------------------------"
echo "Now type 'make' to build"
echo ""

View file

@ -240,7 +240,6 @@ dynamic: false;
* Format: `#{HEX}{6}`
* Format: `#{HEX}{8}`
* Format: `argb:{HEX}{8}`
* Format: `rgb({INTEGER},{INTEGER},{INTEGER})`
* Format: `rgba({INTEGER},{INTEGER},{INTEGER}, {REAL})`

View file

@ -4,6 +4,7 @@
#include <cairo.h>
#include <widgets/widget.h>
#include <settings.h>
#include "theme.h"
/** Style of text highlight */
typedef enum

View file

@ -1,8 +1,8 @@
#ifndef ROFI_XRMOPTIONS_H
#define ROFI_XRMOPTIONS_H
#include "theme.h"
// Big thanks to Sean Pringle for this code.
// FIXME: for real
typedef void xcb_stuff;
/**
@ -78,30 +78,6 @@ void config_parse_xresource_options_file ( const char *filename );
*/
void config_parse_cmd_options ( void );
/**
* Parse dynamic commandline options.
* @ingroup CONFCommandline
*/
void config_parse_cmd_options_dynamic ( void );
/**
* @param xcb Handler object that holds connection to X11 server to fetch the settings from.
*
* Parse the rofi related X resource options of the
* connected X server.
*
* @ingroup CONFXServer
*/
void config_parse_xresource_options_dynamic ( xcb_stuff *xcb );
/**
* @param filename The xresources file to parse
*
* Parses filename and updates the config. For dynamic options.
* @ingroup CONFFile
*/
void config_parse_xresource_options_dynamic_file ( const char *filename );
/**
* Free any allocated memory.
*
@ -160,5 +136,13 @@ void print_help_msg ( const char *option, const char *type, const char*text, con
*/
char ** config_parser_return_display_help ( unsigned int *length );
/**
* @brief Set config option.
*
* Sets both the static as dynamic config option.
*
* @param p Property to set
*/
void config_parse_set_property ( const Property *p );
/* @}*/
#endif

View file

@ -1,4 +1,6 @@
%option noyywrap nounput never-interactive
%option noyywrap
%option nounput
%option never-interactive
%option bison-locations
%{
@ -35,7 +37,7 @@ typedef struct _ParseObject {
char *filename;
/** Length of string */
size_t str_len;
yy_size_t str_len;
/** String */
const char *input_str;
/** Position in file */
@ -100,9 +102,21 @@ static char * rofi_theme_parse_prepare_file ( const char *file, const char *pare
yylloc->first_column = yylloc->last_column;\
}
%}
ASC [\x00-\x7f]
ASCN [\x00-\t\v-\x7f]
U [\x80-\xbf]
U2 [\xc2-\xdf]
U3 [\xe0-\xef]
U4 [\xf0-\xf4]
// UANY {ASC}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
UANYN {ASCN}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
// UONLY {U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U}
WHITESPACE [[:blank:]]
WORD [[:alnum:]-]+
STRING [[:print:]]+
STRING {UANYN}+
HEX [[:xdigit:]]
NUMBER [[:digit:]]
PNNUMBER [-+]?[[:digit:]]+
@ -129,6 +143,8 @@ LS_SOLID "solid"
INCLUDE "@import"
CONFIGURATION "Configuration"
%x INCLUDE
%x PROPERTIES
%x NAMESTR
@ -143,6 +159,9 @@ YY_LLOC_START
if ( queue == NULL ){
queue = g_queue_new ( );
yylloc->filename = current->filename;
// unsure why todo this.
yylloc->first_line = yylloc->last_line = 1;
yylloc->first_column = yylloc->last_column = 1;
}
%}
@ -245,6 +264,12 @@ if ( queue == NULL ){
/**
* Handle defaults: * { ... }
*/
<INITIAL>{CONFIGURATION} {
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
BEGIN(DEFAULTS);
return CONFIGURATION;
}
<INITIAL>{ASTERIX} {
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
BEGIN(DEFAULTS);

View file

@ -7,6 +7,7 @@
%parse-param {const char *what}
%code requires {
#include "theme.h"
#include "xrmoptions.h"
typedef struct YYLTYPE {
int first_line;
@ -89,6 +90,7 @@ int yylex (YYSTYPE *, YYLTYPE *);
%token NAME_PREFIX "Element section ('# {name} { ... }')"
%token WHITESPACE "White space"
%token PDEFAULTS "Default settings section ( '* { ... }')"
%token CONFIGURATION "Configuration block"
%type <ival> highlight_styles
%type <sval> entry
@ -131,6 +133,15 @@ NAME_PREFIX name_path BOPEN optional_properties BCLOSE
PDEFAULTS BOPEN optional_properties BCLOSE {
rofi_theme_widget_add_properties ( rofi_theme, $3);
}
| CONFIGURATION BOPEN optional_properties BCLOSE {
GHashTableIter iter;
g_hash_table_iter_init ( &iter, $3 );
gpointer key,value;
while ( g_hash_table_iter_next ( &iter, &key, &value ) ) {
Property *p = (Property *) value;
config_parse_set_property ( p );
}
}
;
/**

View file

@ -371,8 +371,8 @@ static void get_apps_history ( DRunModePrivateData *pd )
for ( unsigned int index = 0; index < length; index++ ) {
char **st = g_strsplit ( retv[index], ":::", 2 );
if ( st && st[0] && st[1] ) {
if ( ! read_desktop_file ( pd, st[0], st[1] ) ) {
history_remove ( path, retv[index]);
if ( !read_desktop_file ( pd, st[0], st[1] ) ) {
history_remove ( path, retv[index] );
}
}
g_strfreev ( st );

View file

@ -17,8 +17,7 @@ int mode_init ( Mode *mode )
{
g_return_val_if_fail ( mode != NULL, FALSE );
g_return_val_if_fail ( mode->_init != NULL, FALSE );
mode->_init ( mode );
return TRUE;
return mode->_init ( mode );
}
void mode_destroy ( Mode *mode )

View file

@ -65,7 +65,7 @@
// TODO: move this check to mode.c
#include "mode-private.h"
#define LOG_DOMAIN "Rofi"
#define LOG_DOMAIN "Rofi"
// Pidfile.
char *pidfile = NULL;
@ -149,7 +149,7 @@ static int setup ()
*/
static void teardown ( int pfd )
{
g_log ( LOG_DOMAIN , G_LOG_LEVEL_DEBUG, "Teardown");
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Teardown" );
// Cleanup font setup.
textbox_cleanup ( );
@ -305,7 +305,6 @@ static void help ( G_GNUC_UNUSED int argc, char **argv )
}
/**
* Function bound by 'atexit'.
* Cleanup globally allocated memory.
*/
static void cleanup ()
@ -490,7 +489,6 @@ static int add_mode ( const char * token )
Mode *sw = script_switcher_parse_setup ( token );
if ( sw != NULL ) {
modi[num_modi] = sw;
mode_set_config ( sw );
num_modi++;
}
else {
@ -512,34 +510,6 @@ static void setup_modi ( void )
}
// Free string that was modified by strtok_r
g_free ( switcher_str );
rofi_collect_modi_setup ();
}
/**
* Load configuration.
* Following priority: (current), X, commandline arguments
*/
static inline void load_configuration ( )
{
// Load distro default settings
gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
config_parse_xresource_options_file ( etc );
}
g_free ( etc );
// Load in config from X resources.
config_parse_xresource_options_file ( config_path );
}
static inline void load_configuration_dynamic ( )
{
// Load distro default settings
gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
config_parse_xresource_options_dynamic_file ( etc );
}
g_free ( etc );
// Load in config from X resources.
config_parse_xresource_options_dynamic_file ( config_path );
}
/**
@ -744,7 +714,7 @@ int main ( int argc, char *argv[] )
#else
fprintf ( stdout, "Version: "VERSION "\n" );
#endif
exit ( EXIT_SUCCESS );
return EXIT_SUCCESS;
}
// Detect if we are in dmenu mode.
@ -775,10 +745,12 @@ int main ( int argc, char *argv[] )
const char *path = g_get_user_runtime_dir ();
if ( path ) {
if ( g_mkdir_with_parents ( path, 0700 ) < 0 ) {
fprintf ( stderr, "Failed to create user runtime directory: %s\n", strerror ( errno ) );
return EXIT_FAILURE;
g_log ( LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Failed to create user runtime directory: %s with error: %s\n", path, strerror ( errno ) );
pidfile = g_build_filename ( g_get_home_dir (), ".rofi.pid", NULL );
}
else {
pidfile = g_build_filename ( path, "rofi.pid", NULL );
}
pidfile = g_build_filename ( path, "rofi.pid", NULL );
}
config_parser_add_option ( xrm_String, "pid", (void * *) &pidfile, "Pidfile location" );
@ -794,13 +766,10 @@ int main ( int argc, char *argv[] )
config_path = rofi_expand_path ( c );
}
TICK ();
// Register cleanup function.
atexit ( cleanup );
TICK ();
if ( setlocale ( LC_ALL, "" ) == NULL ) {
fprintf ( stderr, "Failed to set locale.\n" );
cleanup ();
return EXIT_FAILURE;
}
@ -811,6 +780,7 @@ int main ( int argc, char *argv[] )
TICK_N ( "Open Display" );
rofi_collect_modi ();
rofi_collect_modi_setup ();
TICK_N ( "Collect MODI" );
main_loop = g_main_loop_new ( NULL, FALSE );
@ -822,10 +792,29 @@ int main ( int argc, char *argv[] )
TICK_N ( "Setup abe" );
if ( find_arg ( "-no-config" ) < 0 ) {
load_configuration ( );
// Load distro default settings
gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
config_parse_xresource_options_file ( etc );
}
g_free ( etc );
// Load in config from X resources.
config_parse_xresource_options_file ( config_path );
find_arg_str ( "-theme", &( config.theme ) );
if ( config.theme ) {
TICK_N ( "Parse theme" );
if ( rofi_theme_parse_file ( config.theme ) ) {
// TODO: instantiate fallback theme.?
rofi_theme_free ( rofi_theme );
rofi_theme = NULL;
}
TICK_N ( "Parsed theme" );
}
}
// Parse command line for settings, independent of other -no-config.
config_parse_cmd_options ( );
TICK_N ( "Load cmd config " );
if ( !dmenu_mode ) {
// setup_modi
@ -833,25 +822,6 @@ int main ( int argc, char *argv[] )
TICK_N ( "Setup Modi" );
}
if ( find_arg ( "-no-config" ) < 0 ) {
// Reload for dynamic part.
load_configuration_dynamic ( );
TICK_N ( "Load config dynamic" );
}
// Parse command line for settings, independent of other -no-config.
config_parse_cmd_options_dynamic ( );
TICK_N ( "Load cmd config dynamic" );
if ( config.theme ) {
TICK_N ( "Parse theme" );
if ( rofi_theme_parse_file ( config.theme ) ) {
// TODO: instantiate fallback theme.?
rofi_theme_free ( rofi_theme );
rofi_theme = NULL;
}
TICK_N ( "Parsed theme" );
}
const char ** theme_str = find_arg_strv ( "-theme-str" );
if ( theme_str ) {
for ( int index = 0; theme_str && theme_str[index]; index++ ) {
@ -868,21 +838,25 @@ int main ( int argc, char *argv[] )
if ( find_arg ( "-dump-theme" ) >= 0 ) {
rofi_theme_print ( rofi_theme );
exit ( EXIT_SUCCESS );
cleanup ();
return EXIT_SUCCESS;
}
// Dump.
// catch help request
if ( find_arg ( "-h" ) >= 0 || find_arg ( "-help" ) >= 0 || find_arg ( "--help" ) >= 0 ) {
help ( argc, argv );
exit ( EXIT_SUCCESS );
cleanup ();
return EXIT_SUCCESS;
}
if ( find_arg ( "-dump-xresources" ) >= 0 ) {
config_parse_xresource_dump ();
exit ( EXIT_SUCCESS );
cleanup ();
return EXIT_SUCCESS;
}
if ( find_arg ( "-dump-xresources-theme" ) >= 0 ) {
config_parse_xresources_theme_dump ();
exit ( EXIT_SUCCESS );
cleanup ();
return EXIT_SUCCESS;
}
if ( ! display_init ( main_loop, display_str ) )
@ -909,5 +883,6 @@ int main ( int argc, char *argv[] )
// Start mainloop.
g_main_loop_run ( main_loop );
teardown ( pfd );
cleanup ();
return return_code;
}

View file

@ -769,7 +769,7 @@ void rofi_theme_convert_old_theme ( void )
ThemeWidget *walternate = rofi_theme_find_or_create_name ( widget, "alternate" );
rofi_theme_convert_create_property_ht ( widget );
Property *p= rofi_theme_property_create ( P_INTEGER );
Property *p = rofi_theme_property_create ( P_INTEGER );
p->name = g_strdup ( "border" );
p->value.i = 0;
g_hash_table_replace ( widget->properties, p->name, p );

View file

@ -1350,7 +1350,7 @@ void rofi_view_workers_initialize ( void )
void rofi_view_workers_finalize ( void )
{
if ( tpool ) {
g_thread_pool_free ( tpool, TRUE, FALSE );
g_thread_pool_free ( tpool, TRUE, TRUE );
tpool = NULL;
}
}

View file

@ -44,6 +44,7 @@ const char * const ConfigSourceStr[] = {
"Default",
"XResources",
"File",
"Rasi File",
"Commandline",
};
/** Enumerator of different sources of configuration. */
@ -52,7 +53,8 @@ enum ConfigSource
CONFIG_DEFAULT = 0,
CONFIG_XRESOURCES = 1,
CONFIG_FILE = 2,
CONFIG_CMDLINE = 3
CONFIG_FILE_THEME = 3,
CONFIG_CMDLINE = 4
};
typedef struct
@ -325,48 +327,71 @@ void config_parse_cmd_options ( void )
XrmOption *op = &( xrmOptions[i] );
config_parse_cmd_option ( op );
}
}
void config_parse_cmd_options_dynamic ( void )
{
for ( unsigned int i = 0; i < num_extra_options; ++i ) {
XrmOption *op = &( extra_options[i] );
config_parse_cmd_option ( op );
}
}
static void __config_parse_xresource_options_dynamic ( xcb_xrm_database_t *xDB, enum ConfigSource source )
static void __config_parser_set_property ( XrmOption *option, const Property *p )
{
const char * namePrefix = "rofi";
for ( unsigned int i = 0; i < num_extra_options; ++i ) {
char *name;
name = g_strdup_printf ( "%s.%s", namePrefix, extra_options[i].name );
char *xrmValue = NULL;
if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) {
config_parser_set ( &( extra_options[i] ), xrmValue, source );
if ( option->type == xrm_String ) {
if ( p->type != P_STRING ) {
fprintf ( stderr, "Option: %s needs to be set with a string.\n", option->name );
return;
}
if ( xrmValue ) {
free ( xrmValue );
if ( ( option )->mem != NULL ) {
g_free ( option->mem );
option->mem = NULL;
}
*( option->value.str ) = g_strdup ( p->value.s );
g_free ( name );
// Memory
( option )->mem = *( option->value.str );
option->source = CONFIG_FILE_THEME;
}
else if ( option->type == xrm_Number ) {
if ( p->type != P_INTEGER ) {
fprintf ( stderr, "Option: %s needs to be set with a number.\n", option->name );
return;
}
*( option->value.snum ) = p->value.i;
option->source = CONFIG_FILE_THEME;
}
else if ( option->type == xrm_SNumber ) {
if ( p->type != P_INTEGER ) {
fprintf ( stderr, "Option: %s needs to be set with a number.\n", option->name );
return;
}
*( option->value.num ) = (unsigned int ) ( p->value.i );
option->source = CONFIG_FILE_THEME;
}
else if ( option->type == xrm_Boolean ) {
if ( p->type != P_BOOLEAN ) {
fprintf ( stderr, "Option: %s needs to be set with a boolean.\n", option->name );
return;
}
*( option->value.num ) = ( p->value.b );
option->source = CONFIG_FILE_THEME;
}
}
void config_parse_xresource_options_dynamic_file ( const char *filename )
void config_parse_set_property ( const Property *p )
{
if ( !filename ) {
return;
for ( unsigned int i = 0; i < sizeof ( xrmOptions ) / sizeof ( XrmOption ); ++i ) {
XrmOption *op = &( xrmOptions[i] );
if ( g_strcmp0 ( op->name, p->name ) == 0 ) {
__config_parser_set_property ( op, p );
return;
}
}
// Map Xresource entries to rofi config options.
xcb_xrm_database_t *xDB = xcb_xrm_database_from_file ( filename );
if ( xDB == NULL ) {
return;
for ( unsigned int i = 0; i < num_extra_options; ++i ) {
XrmOption *op = &( extra_options[i] );
if ( g_strcmp0 ( op->name, p->name ) == 0 ) {
__config_parser_set_property ( op, p );
return;
}
}
__config_parse_xresource_options_dynamic ( xDB, CONFIG_FILE );
xcb_xrm_database_free ( xDB );
}
void config_xresource_free ( void )

View file

@ -23,6 +23,9 @@ unsigned int test =0;
} \
}
void config_parse_set_property ( const void *p )
{
}
char * rofi_expand_path ( const char *path )
{

View file

@ -22,6 +22,9 @@ unsigned int test =0;
abort ( ); \
} \
}
void config_parse_set_property ( const void *p )
{
}
void rofi_add_error_message ( GString *msg )
{}

View file

@ -20,6 +20,10 @@ unsigned int normal_window_mode = 0;
#include "view.h"
void config_parse_set_property ( void *p )
{
}
void rofi_add_error_message ( GString *msg)
{
}

View file

@ -12,6 +12,9 @@ unsigned int test =0;
assert ( a ); \
printf ( "Test %3i passed (%s)\n", ++test, # a ); \
}
void config_parse_set_property ( const void *p )
{
}
void rofi_add_error_message ( GString *msg )
{
}