This commit is contained in:
QC 2014-08-01 23:29:01 +02:00
parent c2ccd37312
commit 65903e61d0
4 changed files with 181 additions and 154 deletions

View File

@ -1,35 +1,30 @@
ROFI 1 rofi # ROFI 1 rofi
===========
NAME ## NAME
----
rofi - A window switcher, run dialog and dmenu replacement rofi - A window switcher, run dialog and dmenu replacement
SYNOPSIS ## SYNOPSIS
--------
`rofi` [ -width *pct_scr* ] [ -lines *lines* ] [ -columns *columns* ] [ -font *xftfont* ] [ -fg *color* ] **rofi** [ -width *pct_scr* ] [ -lines *lines* ] [ -columns *columns* ] [ -font *xftfont* ] [ -fg *color* ]
[ -bg *color* ] [ -hlfg *color* ] [ -hlbg *color* ] [ -key *combo* ] [ -dkey *comdo* ] [ -rkey *comdo* ] [ -bg *color* ] [ -hlfg *color* ] [ -hlbg *color* ] [ -key *combo* ] [ -dkey *comdo* ] [ -rkey *comdo* ]
[ -terminal *terminal* ] [ -location *position* ] [ -hmode ] [ -fixed-num-lines ] [ -padding *padding* ] [ -terminal *terminal* ] [ -location *position* ] [ -hmode ] [ -fixed-num-lines ] [ -padding *padding* ]
[ -opacity *opacity%* ] [ -display *display* ] [ -bc *color* ] [ -bw *width* ] [ -dmenu [ -p *prompt* ] ] [ -opacity *opacity%* ] [ -display *display* ] [ -bc *color* ] [ -bw *width* ] [ -dmenu [ -p *prompt* ] ]
[ -ssh-set-title *true|false* ] [ -now ] [ -rnow ] [ -snow ] [ -version ] [ -help] [ -dump-xresources ] [ -ssh-set-title *true|false* ] [ -now ] [ -rnow ] [ -snow ] [ -version ] [ -help] [ -dump-xresources ]
[ -disable-history ] [ -levenshtein-sort ] [ -show *mode* ] [ -switcher *mode1,mode2* ] [ -disable-history ] [ -levenshtein-sort ] [ -show *mode* ] [ -switcher *mode1,mode2* ]
DESCRIPTION ## DESCRIPTION
-----------
`rofi` is an X11 popup window switcher. A list is displayed center-screen showing open window titles, WM_CLASS, and desktop number. **rofi** is an X11 popup window switcher. A list is displayed center-screen showing open window titles, WM_CLASS, and desktop number.
The user may filter the list by typing, navigate with Up/Down or Tab keys, and select a window with Return (Enter). Escape cancels. The user may filter the list by typing, navigate with Up/Down or Tab keys, and select a window with Return (Enter). Escape cancels.
License ## License
-------
MIT/X11 MIT/X11
USAGE ## USAGE
-----
`rofi` can be used in two ways, single-shot; executes once and directly exits when done or as **rofi** can be used in two ways, single-shot; executes once and directly exits when done or as
daemon listening to specific key-combinations. daemon listening to specific key-combinations.
The default key combinations are: The default key combinations are:
@ -47,138 +42,138 @@ The default key combinations are:
Show run-dialog. Show run-dialog.
OPTIONS ## OPTIONS
-------
`-key` `-key`
Change the key combination to display all windows (default: F12). Change the key combination to display all windows (default: F12).
rofi -key F12 rofi -key F12
rofi -key control+shift+s rofi -key control+shift+s
rofi -key mod1+Tab rofi -key mod1+Tab
`-rkey` `-rkey`
Change the key combination to display the run dialog (default: mod1-F2). Change the key combination to display the run dialog (default: mod1-F2).
rofi -rkey F11 rofi -rkey F11
rofi -rkey control+shift+d rofi -rkey control+shift+d
rofi -rkey mod1+grave (grave=backtick) rofi -rkey mod1+grave (grave=backtick)
`-skey` `-skey`
Change the key combination to display the ssh dialog (default: Alt-F3). Change the key combination to display the ssh dialog (default: Alt-F3).
rofi -skey F10 rofi -skey F10
rofi -skey control+shift+s rofi -skey control+shift+s
rofi -skey mod1+grave (grave=backtick) rofi -skey mod1+grave (grave=backtick)
`-now` `-now`
Run rofi in all-windows mode once then exit. Does not bind any keys. Run rofi in all-windows mode once then exit. Does not bind any keys.
`-rnow` `-rnow`
Run rofi in run-dialog mode once then exit. Does not bind any keys. Run rofi in run-dialog mode once then exit. Does not bind any keys.
`-snow` `-snow`
Run rofi in ssh mode once then exit. Does not bind any keys. Run rofi in ssh mode once then exit. Does not bind any keys.
`-bg` `-bg`
Set the background text color (X11 named color or hex #rrggbb) for the menu (default: #222222). Set the background text color (X11 named color or hex #rrggbb) for the menu (default: #222222).
rofi -fg "#222222" rofi -fg "#222222"
`-bc` `-bc`
Set the border color (X11 named color or hex #rrggbb) for the menu (default: #000000). Set the border color (X11 named color or hex #rrggbb) for the menu (default: #000000).
rofi -bc black rofi -bc black
`-bw` `-bw`
Set the border width in pixels (default: 1). Set the border width in pixels (default: 1).
rofi -bw 1 rofi -bw 1
`-fg` `-fg`
Set the foreground text color (X11 named color or hex #rrggbb) for the menu (default: #cccccc). Set the foreground text color (X11 named color or hex #rrggbb) for the menu (default: #cccccc).
rofi -fg "#cccccc" rofi -fg "#cccccc"
`-font` `-font`
Xft font name for use by the menu (default: mono-14). Xft font name for use by the menu (default: mono-14).
rofi -font monospace-14:medium rofi -font monospace-14:medium
`-hlbg` `-hlbg`
Set the background text color (X11 named color or hex #rrggbb) for the highlighted item in the Set the background text color (X11 named color or hex #rrggbb) for the highlighted item in the
menu (default: #005577). menu (default: #005577).
rofi -fg "#005577" rofi -fg "#005577"
`-hlfg` `-hlfg`
Set the foreground text color (X11 named color or hex #rrggbb) for the highlighted item in the Set the foreground text color (X11 named color or hex #rrggbb) for the highlighted item in the
menu (default: #ffffff). menu (default: #ffffff).
rofi -fg "#ffffff" rofi -fg "#ffffff"
`-opacity` `-opacity`
Set the window opacity (0-100). Set the window opacity (0-100).
rofi -opacity "75" rofi -opacity "75"
`-lines` `-lines`
Maximum number of lines the menu may show before scrolling (default: 25). Maximum number of lines the menu may show before scrolling (default: 25).
rofi -lines 25 rofi -lines 25
`-columns` `-columns`
The number of columns the menu may show before scrolling (default: 25). The number of columns the menu may show before scrolling (default: 25).
rofi -columns 2 rofi -columns 2
`-width` `-width`
Set the width of the menu as a percentage of the screen width (default: 60). Set the width of the menu as a percentage of the screen width (default: 60).
rofi -width 60 rofi -width 60
`-terminal` `-terminal`
Specify what terminal to start (default x-terminal-emulator) Specify what terminal to start (default x-terminal-emulator)
rofi -terminal xterm rofi -terminal xterm
`-location` `-location`
Specify where the window should be located. The numbers map to the following location on the Specify where the window should be located. The numbers map to the following location on the
monitor: monitor:
1 2 3 1 2 3
8 0 4 8 0 4
7 6 5 7 6 5
`-hmode` `-hmode`
@ -187,20 +182,23 @@ OPTIONS
`-fixed-num-lines` `-fixed-num-lines`
Keep a fixed number of visible lines (See the `-lines` option.) Keep a fixed number of visible lines (See the `-lines` option.)
`-padding` `-padding`
Define the inner margin of the window. Default is 5 pixels. Define the inner margin of the window. Default is 5 pixels.
To make rofi look like dmenu: To make rofi look like dmenu:
rofi -hmode -padding 0 rofi -hmode -padding 0
`-dmenu` `-dmenu`
Run rofi in dmenu mode. Allowing it to be used for user interaction in scripts. Run rofi in dmenu mode. Allowing it to be used for user interaction in scripts.
Pressing `shift-enter` will open the selected entries and move to the next entry.
`-dump-xresources` `-dump-xresources`
Dump the current active configuration in xresources format to the command-line. Dump the current active configuration in xresources format to the command-line.
@ -246,19 +244,17 @@ OPTIONS
rofi -switchers "window,run,ssh,Workspaces:i3_switch_workspaces.sh" -show Workspaces rofi -switchers "window,run,ssh,Workspaces:i3_switch_workspaces.sh" -show Workspaces
Switch between modi ## Switch between modi
-------------------
Type '?' *enter* to switch between window list, run and ssh mode. The list can be customized with Type '?' *enter* to switch between window list, run and ssh mode. The list can be customized with
the `-switchers` argument. the `-switchers` argument.
WEBSITE ## WEBSITE
-------
`rofi` website can be found at [here](https://davedavenport.github.io/rofi/) **rofi** website can be found at [here](https://davedavenport.github.io/rofi/)
## AUTHOR
AUTHOR
------
Qball Cow <qball@gmpclient.org> Qball Cow <qball@gmpclient.org>
Original code based on work by: Sean Pringle <sean.pringle@gmail.com> Original code based on work by: Sean Pringle <sean.pringle@gmail.com>

View File

@ -4,7 +4,7 @@
rofi \- A window switcher, run dialog and dmenu replacement rofi \- A window switcher, run dialog and dmenu replacement
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\fB\fCrofi\fR [ \-width \fIpct_scr\fP ] [ \-lines \fIlines\fP ] [ \-columns \fIcolumns\fP ] [ \-font \fIxftfont\fP ] [ \-fg \fIcolor\fP ] \fBrofi\fP [ \-width \fIpct_scr\fP ] [ \-lines \fIlines\fP ] [ \-columns \fIcolumns\fP ] [ \-font \fIxftfont\fP ] [ \-fg \fIcolor\fP ]
[ \-bg \fIcolor\fP ] [ \-hlfg \fIcolor\fP ] [ \-hlbg \fIcolor\fP ] [ \-key \fIcombo\fP ] [ \-dkey \fIcomdo\fP ] [ \-rkey \fIcomdo\fP ] [ \-bg \fIcolor\fP ] [ \-hlfg \fIcolor\fP ] [ \-hlbg \fIcolor\fP ] [ \-key \fIcombo\fP ] [ \-dkey \fIcomdo\fP ] [ \-rkey \fIcomdo\fP ]
[ \-terminal \fIterminal\fP ] [ \-location \fIposition\fP ] [ \-hmode ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fP ] [ \-terminal \fIterminal\fP ] [ \-location \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 ] ] [ \-opacity \fIopacity%\fP ] [ \-display \fIdisplay\fP ] [ \-bc \fIcolor\fP ] [ \-bw \fIwidth\fP ] [ \-dmenu [ \-p \fIprompt\fP ] ]
@ -12,14 +12,14 @@ rofi \- A window switcher, run dialog and dmenu replacement
[ \-disable\-history ] [ \-levenshtein\-sort ] [ \-show \fImode\fP ] [ \-switcher \fImode1,mode2\fP ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \-show \fImode\fP ] [ \-switcher \fImode1,mode2\fP ]
.SH DESCRIPTION .SH DESCRIPTION
.PP .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. \fBrofi\fP is an X11 popup window switcher. A list is displayed center\-screen showing open window titles, WM_CLASS, and desktop number.
The user may filter the list by typing, navigate with Up/Down or Tab keys, and select a window with Return (Enter). Escape cancels. The user may filter the list by typing, navigate with Up/Down or Tab keys, and select a window with Return (Enter). Escape cancels.
.SH License .SH License
.PP .PP
MIT/X11 MIT/X11
.SH USAGE .SH USAGE
.PP .PP
\fB\fCrofi\fR can be used in two ways, single\-shot; executes once and directly exits when done or as \fBrofi\fP can be used in two ways, single\-shot; executes once and directly exits when done or as
daemon listening to specific key\-combinations. daemon listening to specific key\-combinations.
.PP .PP
The default key combinations are: The default key combinations are:
@ -44,181 +44,185 @@ The default key combinations are:
.SH OPTIONS .SH OPTIONS
.PP .PP
\fB\fC\-key\fR \fB\fC\-key\fR
.IP
Change the key combination to display all windows (default: F12).
.PP .PP
.RS .RS
.nf .nf
Change the key combination to display all windows (default: F12). rofi \-key F12
rofi \-key F12 rofi \-key control+shift+s
rofi \-key control+shift+s rofi \-key mod1+Tab
rofi \-key mod1+Tab
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-rkey\fR \fB\fC\-rkey\fR
.IP
Change the key combination to display the run dialog (default: mod1\-F2).
.PP .PP
.RS .RS
.nf .nf
Change the key combination to display the run dialog (default: mod1\-F2). rofi \-rkey F11
rofi \-rkey F11 rofi \-rkey control+shift+d
rofi \-rkey control+shift+d rofi \-rkey mod1+grave (grave=backtick)
rofi \-rkey mod1+grave (grave=backtick)
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-skey\fR \fB\fC\-skey\fR
.IP
Change the key combination to display the ssh dialog (default: Alt\-F3).
.PP .PP
.RS .RS
.nf .nf
Change the key combination to display the ssh dialog (default: Alt\-F3). rofi \-skey F10
rofi \-skey F10 rofi \-skey control+shift+s
rofi \-skey control+shift+s rofi \-skey mod1+grave (grave=backtick)
rofi \-skey mod1+grave (grave=backtick)
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-now\fR \fB\fC\-now\fR
.PP .IP
.RS
.nf
Run rofi in all\-windows mode once then exit. Does not bind any keys. Run rofi in all\-windows mode once then exit. Does not bind any keys.
.fi
.RE
.PP .PP
\fB\fC\-rnow\fR \fB\fC\-rnow\fR
.PP .IP
.RS
.nf
Run rofi in run\-dialog mode once then exit. Does not bind any keys. Run rofi in run\-dialog mode once then exit. Does not bind any keys.
.fi
.RE
.PP .PP
\fB\fC\-snow\fR \fB\fC\-snow\fR
.PP .IP
.RS
.nf
Run rofi in ssh mode once then exit. Does not bind any keys. Run rofi in ssh mode once then exit. Does not bind any keys.
.fi
.RE
.PP .PP
\fB\fC\-bg\fR \fB\fC\-bg\fR
.IP
Set the background text color (X11 named color or hex #rrggbb) for the menu (default: #222222).
.PP .PP
.RS .RS
.nf .nf
Set the background text color (X11 named color or hex #rrggbb) for the menu (default: #222222). rofi \-fg "#222222"
rofi \-fg "#222222"
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-bc\fR \fB\fC\-bc\fR
.IP
Set the border color (X11 named color or hex #rrggbb) for the menu (default: #000000).
.PP .PP
.RS .RS
.nf .nf
Set the border color (X11 named color or hex #rrggbb) for the menu (default: #000000). rofi \-bc black
rofi \-bc black
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-bw\fR \fB\fC\-bw\fR
.IP
Set the border width in pixels (default: 1).
.PP .PP
.RS .RS
.nf .nf
Set the border width in pixels (default: 1). rofi \-bw 1
rofi \-bw 1
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-fg\fR \fB\fC\-fg\fR
.IP
Set the foreground text color (X11 named color or hex #rrggbb) for the menu (default: #cccccc).
.PP .PP
.RS .RS
.nf .nf
Set the foreground text color (X11 named color or hex #rrggbb) for the menu (default: #cccccc). rofi \-fg "#cccccc"
rofi \-fg "#cccccc"
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-font\fR \fB\fC\-font\fR
.IP
Xft font name for use by the menu (default: mono\-14).
.PP .PP
.RS .RS
.nf .nf
Xft font name for use by the menu (default: mono\-14). rofi \-font monospace\-14:medium
rofi \-font monospace\-14:medium
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-hlbg\fR \fB\fC\-hlbg\fR
.IP
Set the background text color (X11 named color or hex #rrggbb) for the highlighted item in the
menu (default: #005577).
.PP .PP
.RS .RS
.nf .nf
Set the background text color (X11 named color or hex #rrggbb) for the highlighted item in the rofi \-fg "#005577"
menu (default: #005577).
rofi \-fg "#005577"
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-hlfg\fR \fB\fC\-hlfg\fR
.IP
Set the foreground text color (X11 named color or hex #rrggbb) for the highlighted item in the
menu (default: #ffffff).
.PP .PP
.RS .RS
.nf .nf
Set the foreground text color (X11 named color or hex #rrggbb) for the highlighted item in the rofi \-fg "#ffffff"
menu (default: #ffffff).
rofi \-fg "#ffffff"
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-opacity\fR \fB\fC\-opacity\fR
.IP
Set the window opacity (0\-100).
.PP .PP
.RS .RS
.nf .nf
Set the window opacity (0\-100). rofi \-opacity "75"
rofi \-opacity "75"
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-lines\fR \fB\fC\-lines\fR
.IP
Maximum number of lines the menu may show before scrolling (default: 25).
.PP .PP
.RS .RS
.nf .nf
Maximum number of lines the menu may show before scrolling (default: 25). rofi \-lines 25
rofi \-lines 25
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-columns\fR \fB\fC\-columns\fR
.IP
The number of columns the menu may show before scrolling (default: 25).
.PP .PP
.RS .RS
.nf .nf
The number of columns the menu may show before scrolling (default: 25). rofi \-columns 2
rofi \-columns 2
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-width\fR \fB\fC\-width\fR
.IP
Set the width of the menu as a percentage of the screen width (default: 60).
.PP .PP
.RS .RS
.nf .nf
Set the width of the menu as a percentage of the screen width (default: 60). rofi \-width 60
rofi \-width 60
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-terminal\fR \fB\fC\-terminal\fR
.IP
Specify what terminal to start (default x\-terminal\-emulator)
.PP .PP
.RS .RS
.nf .nf
Specify what terminal to start (default x\-terminal\-emulator) rofi \-terminal xterm
rofi \-terminal xterm
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-location\fR \fB\fC\-location\fR
.IP
Specify where the window should be located. The numbers map to the following location on the
monitor:
.PP .PP
.RS .RS
.nf .nf
Specify where the window should be located. The numbers map to the following location on the 1 2 3
monitor: 8 0 4
1 2 3 7 6 5
8 0 4
7 6 5
.fi .fi
.RE .RE
.PP .PP
@ -228,22 +232,26 @@ Switch to horizontal mode (ala dmenu). The number of elements is the number of \
number of \fB\fCcolumns\fR\&. number of \fB\fCcolumns\fR\&.
.PP .PP
\fB\fC\-fixed\-num\-lines\fR \fB\fC\-fixed\-num\-lines\fR
.PP .IP
Keep a fixed number of visible lines (See the \fB\fC\-lines\fR option.) Keep a fixed number of visible lines (See the \fB\fC\-lines\fR option.)
.PP .PP
\fB\fC\-padding\fR \fB\fC\-padding\fR
.IP
Define the inner margin of the window. Default is 5 pixels.
.IP
To make rofi look like dmenu:
.PP .PP
.RS .RS
.nf .nf
Define the inner margin of the window. Default is 5 pixels. rofi \-hmode \-padding 0
To make rofi look like dmenu:
rofi \-hmode \-padding 0
.fi .fi
.RE .RE
.PP .PP
\fB\fC\-dmenu\fR \fB\fC\-dmenu\fR
.IP .IP
Run rofi in dmenu mode. Allowing it to be used for user interaction in scripts. Run rofi in dmenu mode. Allowing it to be used for user interaction in scripts.
.IP
Pressing \fB\fCshift\-enter\fR will open the selected entries and move to the next entry.
.PP .PP
\fB\fC\-dump\-xresources\fR \fB\fC\-dump\-xresources\fR
.IP .IP
@ -310,7 +318,7 @@ Type '?' \fIenter\fP to switch between window list, run and ssh mode. The list c
the \fB\fC\-switchers\fR argument. the \fB\fC\-switchers\fR argument.
.SH WEBSITE .SH WEBSITE
.PP .PP
\fB\fCrofi\fR website can be found at here \fBrofi\fP website can be found at here
.UR https://davedavenport.github.io/rofi/ .UR https://davedavenport.github.io/rofi/
.UE .UE
.SH AUTHOR .SH AUTHOR

View File

@ -71,20 +71,39 @@ SwitcherMode dmenu_switcher_dialog ( char **input, void *data )
SwitcherMode retv = MODE_EXIT; SwitcherMode retv = MODE_EXIT;
unsigned int length = 0; unsigned int length = 0;
char **list = get_dmenu ( &length ); char **list = get_dmenu ( &length );
int restart = FALSE;
int mretv = menu ( list, length, input, dmenu_prompt, NULL, NULL, do {
token_match, NULL, &selected_line ); int shift = 0;
int mretv = menu ( list, length, input, dmenu_prompt, NULL, &shift,
if ( mretv == MENU_NEXT ) { token_match, NULL, &selected_line );
retv = RELOAD_DIALOG;
}
else if ( mretv == MENU_OK && list[selected_line] != NULL ) {
fputs ( list[selected_line], stdout );
}
else if ( mretv == MENU_CUSTOM_INPUT && *input != NULL && *input[0] != '\0' ) {
fputs ( *input, stdout );
}
// We normally do not want to restart the loop.
restart = FALSE;
if ( mretv == MENU_NEXT ) {
retv = RELOAD_DIALOG;
}
else if ( mretv == MENU_OK && list[selected_line] != NULL ) {
fputs ( list[selected_line], stdout );
fputc ( '\n', stdout );
fflush ( stdout );
if ( shift ) {
restart = TRUE;
// Move to next line.
selected_line = MIN ( selected_line + 1, length - 1 );
}
}
else if ( mretv == MENU_CUSTOM_INPUT && *input != NULL && *input[0] != '\0' ) {
fputs ( *input, stdout );
fputc ( '\n', stdout );
fflush ( stdout );
if ( shift ) {
restart = TRUE;
// Move to next line.
selected_line = MIN ( selected_line + 1, length - 1 );
}
}
} while ( restart );
for ( unsigned int i = 0; i < length; i++ ) { for ( unsigned int i = 0; i < length; i++ ) {
free ( list[i] ); free ( list[i] );
} }
@ -92,7 +111,6 @@ SwitcherMode dmenu_switcher_dialog ( char **input, void *data )
if ( list != NULL ) { if ( list != NULL ) {
free ( list ); free ( list );
} }
return retv; return retv;
} }

View File

@ -1210,6 +1210,11 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
KeySym prev_key = 0; KeySym prev_key = 0;
unsigned int selected = 0; unsigned int selected = 0;
int last_offset = 0; int last_offset = 0;
if ( selected_line != NULL ) {
if ( *selected_line >= 0 && *selected_line <= num_lines ) {
selected = *selected_line;
}
}
for (;; ) { for (;; ) {
// If something changed, refilter the list. (paste or text entered) // If something changed, refilter the list. (paste or text entered)