mirror of
https://github.com/lbonn/rofi
synced 2024-11-15 08:37:17 +00:00
Reload configuration in daemon mode on SIGHUP
This commit is contained in:
parent
b27725834c
commit
c549c4f72d
3 changed files with 64 additions and 8 deletions
|
@ -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
|
ln -s /usr/bin/dmenu /usr/bin/rofi
|
||||||
|
|
||||||
|
## Signals
|
||||||
|
|
||||||
|
`HUP`
|
||||||
|
|
||||||
|
If in daemon mode, reload the configuration from Xresources. (arguments still override).
|
||||||
|
|
||||||
## Keybindings
|
## Keybindings
|
||||||
|
|
||||||
Rofi supports the following keybindings:
|
Rofi supports the following keybindings:
|
||||||
|
|
|
@ -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
|
ln \-s /usr/bin/dmenu /usr/bin/rofi
|
||||||
.fi
|
.fi
|
||||||
.RE
|
.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
|
.SH Keybindings
|
||||||
.PP
|
.PP
|
||||||
Rofi supports the following keybindings:
|
Rofi supports the following keybindings:
|
||||||
|
|
|
@ -2397,9 +2397,52 @@ static void setup_switchers ( void )
|
||||||
g_free ( switcher_str );
|
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[] )
|
int main ( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
|
stored_argc = argc;
|
||||||
|
stored_argv = argv;
|
||||||
|
|
||||||
// Get the path to the cache dir.
|
// Get the path to the cache dir.
|
||||||
cache_dir = g_get_user_cache_dir ();
|
cache_dir = g_get_user_cache_dir ();
|
||||||
|
|
||||||
|
@ -2415,14 +2458,7 @@ int main ( int argc, char *argv[] )
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load in config from X resources.
|
load_configuration ( display );
|
||||||
parse_xresource_options ( display );
|
|
||||||
|
|
||||||
// Parse command line for settings.
|
|
||||||
parse_cmd_options ( argc, argv );
|
|
||||||
|
|
||||||
// Sanity check
|
|
||||||
config_sanity_check ();
|
|
||||||
|
|
||||||
// setup_switchers
|
// setup_switchers
|
||||||
setup_switchers ();
|
setup_switchers ();
|
||||||
|
@ -2539,6 +2575,11 @@ int main ( int argc, char *argv[] )
|
||||||
grab_key ( display, sshdialog_modmask, sshdialog_keysym );
|
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
|
// Main loop
|
||||||
for (;; ) {
|
for (;; ) {
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
Loading…
Reference in a new issue