From f9149b5bdb2a9f03ad9d48880f7e12db7828c0c6 Mon Sep 17 00:00:00 2001 From: QC Date: Thu, 5 Jun 2014 21:55:47 +0200 Subject: [PATCH] Add option to disable history. --- config/config.c | 3 ++- doc/rofi-manpage.markdown | 5 +++++ doc/rofi.1 | 12 ++++++------ include/rofi.h | 2 ++ source/history.c | 9 +++++++++ source/rofi.c | 7 +++++-- source/xrmoptions.c | 1 + 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/config/config.c b/config/config.c index 7d28c052..78956116 100644 --- a/config/config.c +++ b/config/config.c @@ -74,6 +74,7 @@ Settings config = { .ssh_set_title = TRUE, .y_offset = 0, .x_offset = 0, - .fixed_num_lines = FALSE + .fixed_num_lines = FALSE, + .disable_history = FALSE }; diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 802de926..6c4279e3 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -14,6 +14,7 @@ SYNOPSIS [ -terminal *terminal* ] [ -loc *position* ] [ -hmode ] [ -fixed-num-lines ] [ -padding *padding* ] [ -opacity *opacity%* ] [ -display *display* ] [ -bc *color* ] [ -bw *width* ] [ -dmenu [ -p *prompt* ] ] [ -ssh-set-title *true|false* ] [ -now ] [ -rnow ] [ -snow ] [ -version ] [ -help] [ -dump-xresources ] +[ -disable-history ] DESCRIPTION ----------- @@ -210,6 +211,10 @@ OPTIONS Not all terminals support this. Default value is true. +`-disable-history` + + Disable history + Switch between modi ------------------- diff --git a/doc/rofi.1 b/doc/rofi.1 index 0449ab99..c1feed29 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -8,8 +8,8 @@ rofi \- A window switcher, run dialog and dmenu replacement [ \-bg \fIcolor\fP ] [ \-hlfg \fIcolor\fP ] [ \-hlbg \fIcolor\fP ] [ \-key \fIcombo\fP ] [ \-dkey \fIcomdo\fP ] [ \-rkey \fIcomdo\fP ] [ \-terminal \fIterminal\fP ] [ \-loc \fIposition\fP ] [ \-hmode ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fP ] [ \-opacity \fIopacity%\fP ] [ \-display \fIdisplay\fP ] [ \-bc \fIcolor\fP ] [ \-bw \fIwidth\fP ] [ \-dmenu [ \-p \fIprompt\fP ] ] -[ \-ssh\-set\-title \fItrue|false\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ] [ \-help] [ \-dump ] -[ \-dump\-xresources ] +[ \-ssh\-set\-title \fItrue|false\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ] [ \-help] [ \-dump\-xresources ] +[ \-disable\-history ] .SH DESCRIPTION .PP \fB\fCrofi\fR is an X11 popup window switcher. A list is displayed center\-screen showing open window titles, WM_CLASS, and desktop number. @@ -245,10 +245,6 @@ To make rofi look like dmenu: .IP Run rofi in dmenu mode. Allowing it to be used for user interaction in scripts. .PP -\fB\fC\-dump\fR -.IP -Dump the current active configuration to the command\-line. -.PP \fB\fC\-dump\-xresources\fR .IP Dump the current active configuration in xresources format to the command\-line. @@ -258,6 +254,10 @@ Dump the current active configuration in xresources format to the command\-line. SSH dialogs tries to set 'ssh hostname' of the spawned terminal. Not all terminals support this. Default value is true. +.PP +\fB\fC\-disable\-history\fR +.IP +Disable history .SH Switch between modi .PP Type '?' \fIenter\fP to switch between window list, run and ssh mode. diff --git a/include/rofi.h b/include/rofi.h index 27b29298..00a96f01 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -133,6 +133,8 @@ typedef struct _Settings unsigned int ssh_set_title; unsigned int fixed_num_lines; + + unsigned int disable_history; } Settings; extern Settings config; diff --git a/source/history.c b/source/history.c index e5693ac8..9de9f18e 100644 --- a/source/history.c +++ b/source/history.c @@ -113,6 +113,9 @@ static _element ** __history_get_element_list ( FILE *fd, unsigned int *length ) void history_set ( const char *filename, const char *entry ) { + if ( config.disable_history ) { + return; + } int found = 0; unsigned int curr = 0; unsigned int length = 0; @@ -179,6 +182,9 @@ void history_set ( const char *filename, const char *entry ) void history_remove ( const char *filename, const char *entry ) { + if ( config.disable_history ) { + return; + } _element ** list = NULL; int found = 0; unsigned int curr = 0; @@ -235,6 +241,9 @@ void history_remove ( const char *filename, const char *entry ) char ** history_get_list ( const char *filename, unsigned int *length ) { + if ( config.disable_history ) { + return NULL; + } _element **list = NULL; char **retv = NULL; // Open file. diff --git a/source/rofi.c b/source/rofi.c index 8a0670c6..fab08b77 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -956,7 +956,7 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi XStoreName ( display, box, "rofi" ); // Hack to set window opacity. - unsigned int opacity_set = ( unsigned int ) ( ( config.window_opacity / 100.0 ) * UINT32_MAX); + unsigned int opacity_set = ( unsigned int ) ( ( config.window_opacity / 100.0 ) * UINT32_MAX ); XChangeProperty ( display, box, netatoms[_NET_WM_WINDOW_OPACITY], XA_CARDINAL, 32, PropModeReplace, ( unsigned char * ) &opacity_set, 1L ); @@ -1745,7 +1745,7 @@ static inline void display_get_i3_path ( Display *display ) Screen *screen = DefaultScreenOfDisplay ( display ); Window root = RootWindow ( display, XScreenNumberOfScreen ( screen ) ); i3_socket_path = window_get_text_prop ( root, netatoms[I3_SOCKET_PATH] ); - config_i3_mode = (i3_socket_path != NULL)?TRUE:FALSE; + config_i3_mode = ( i3_socket_path != NULL ) ? TRUE : FALSE; } #endif //HAVE_I3_IPC_H @@ -1801,6 +1801,9 @@ static void parse_cmd_options ( int argc, char ** argv ) if ( find_arg ( argc, argv, "-fixed-num-lines" ) >= 0 ) { config.fixed_num_lines = 1; } + if ( find_arg ( argc, argv, "-disable-history" ) >= 0 ) { + config.disable_history = TRUE; + } // Parse commandline arguments about behavior find_arg_str ( argc, argv, "-terminal", &( config.terminal_emulator ) ); diff --git a/source/xrmoptions.c b/source/xrmoptions.c index c0b0900f..01be247e 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -98,6 +98,7 @@ static XrmOption xrmOptions[] = { { xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL }, { xrm_Boolean, "ssh-set-title", { .num = &config.ssh_set_title }, NULL }, + { xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL }, /* Key bindings */ { xrm_String, "key", { .str = &config.window_key }, NULL }, { xrm_String, "rkey", { .str = &config.run_key }, NULL },