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

Reload configuration in daemon mode on SIGHUP

This commit is contained in:
Dave Davenport 2014-11-05 10:52:10 +01:00
parent b27725834c
commit c549c4f72d
3 changed files with 64 additions and 8 deletions

View file

@ -337,6 +337,12 @@ This way it can be used as a drop-in replacement for dmenu. just copy or symlink
ln -s /usr/bin/dmenu /usr/bin/rofi
## Signals
`HUP`
If in daemon mode, reload the configuration from Xresources. (arguments still override).
## Keybindings
Rofi supports the following keybindings:

View file

@ -422,6 +422,15 @@ This way it can be used as a drop\-in replacement for dmenu. just copy or symlin
ln \-s /usr/bin/dmenu /usr/bin/rofi
.fi
.RE
.SH Signals
.PP
\fB\fCHUP\fR
.PP
.RS
.nf
If in daemon mode, reload the configuration from Xresources. (arguments still override).
.fi
.RE
.SH Keybindings
.PP
Rofi supports the following keybindings:

View file

@ -2397,9 +2397,52 @@ static void setup_switchers ( void )
g_free ( switcher_str );
}
/**
* Keep a copy of arc, argv around, so we can use the same parsing method
*/
int stored_argc;
char **stored_argv;
/**
* @param display Pointer to the X connection to use.
* Load configuration.
* Following priority: (current), X, commandline arguments
*/
static inline void load_configuration ( Display *display )
{
// Load in config from X resources.
parse_xresource_options ( display );
// Parse command line for settings.
parse_cmd_options ( stored_argc, stored_argv );
// Sanity check
config_sanity_check ();
}
/**
* Handle sighub request.
* Currently we just reload the configuration.
*/
static void hup_action_handler ( int num )
{
/**
* Open new connection to X. It seems the XResources do not get updated
* on the old connection.
*/
Display *display = XOpenDisplay ( display_str );
if ( display ) {
load_configuration ( display );
XCloseDisplay ( display );
}
}
int main ( int argc, char *argv[] )
{
stored_argc = argc;
stored_argv = argv;
// Get the path to the cache dir.
cache_dir = g_get_user_cache_dir ();
@ -2415,14 +2458,7 @@ int main ( int argc, char *argv[] )
return EXIT_FAILURE;
}
// Load in config from X resources.
parse_xresource_options ( display );
// Parse command line for settings.
parse_cmd_options ( argc, argv );
// Sanity check
config_sanity_check ();
load_configuration ( display );
// setup_switchers
setup_switchers ();
@ -2539,6 +2575,11 @@ int main ( int argc, char *argv[] )
grab_key ( display, sshdialog_modmask, sshdialog_keysym );
}
// Setup handler for sighub (reload config)
const struct sigaction hup_action = { hup_action_handler, };
sigaction ( SIGHUP, &hup_action, NULL );
// Main loop
for (;; ) {
XEvent ev;