Rofi - A Window Switcher, Application Launcher, SSH Dialog, dmenu Replacement and More
Category: Linux
Date: February 2023
Views: 774
Rofi is a versatile and lightweight application launcher, window switcher, SSH dialog, and dmenu replacement for Linux systems. It provides a fast and efficient way to launch applications, switch between windows, and perform a variety of other tasks.
Installation
Rofi is available in most Linux distributions' official repositories. To install it, open your terminal and type the following command:
sudo apt-get install rofi
If you are using a different package manager, replace apt-get
with the appropriate command for your system.
Alternatively, you can download the source code from the official Rofi website and build it manually.
Basic Usage
Application Launcher
One of the most common uses of Rofi is as an application launcher. To launch Rofi, open your terminal and type the following command:
rofi -show run
This will open the Rofi launcher with a list of installed applications. You can use the arrow keys to navigate the list and press Enter to launch the selected application.
You can also search for an application by typing its name in the search bar at the top of the Rofi window. Rofi will filter the list of applications based on your search query.
Window Switcher
Rofi can also be used as a window switcher. To launch Rofi in window switcher mode, type the following command in your terminal:
rofi -show window
This will open the Rofi window switcher, which will display a list of currently open windows. You can use the arrow keys to navigate the list and press Enter to switch to the selected window.
SSH Dialog
Rofi also provides an SSH dialog, which allows you to quickly connect to remote servers using SSH. To launch the SSH dialog, type the following command in your terminal:
rofi -show ssh
This will open the Rofi SSH dialog, which will prompt you to enter the hostname or IP address of the server you want to connect to. Once you enter the server information, press Enter to initiate the SSH connection.
dmenu Replacement
Rofi can also be used as a replacement for the dmenu utility, which is used in many Linux window managers to launch applications and perform other tasks. To launch Rofi as a dmenu replacement, type the following command in your terminal:
rofi -dmenu
This will open the Rofi dmenu, which will display a list of items based on the input you provide. You can use the arrow keys to navigate the list and press Enter to select the item.
Customization
Rofi provides many customization options that allow you to tailor its behavior and appearance to your needs. You can customize Rofi by editing its configuration file, which is located at ~/.config/rofi/config.rasi
.
Some of the things you can customize in the Rofi configuration file include:
- The color scheme
- The font
- The keybindings
- The behavior of each mode (application launcher, window switcher, SSH dialog, dmenu replacement)
For example, to change the color scheme of Rofi, you can add the following lines to the configuration file:
configuration {
/* ... */
theme: "my-theme";
/* ... */
}
# Colors for my-theme
* {
background-color: #282828;
text-color: #ebdbb2;
selected-background-color: #458588;
selected-text-color: #ebdbb2;
}
This will set the theme to "my-theme" and define the colors for the background, text, selected background, and selected text.
You can also create custom keybindings for Rofi by adding the following lines to the configuration file:
configuration {
/* ... */
key-ctrl-t: "spawn urxvt";
key-super-d: "spawn rofi -show run";
/* ... */
}
This will create two custom keybindings: Ctrl + T
will launch the urxvt
terminal emulator, and Super + D
will launch the Rofi application launcher.
My Personal config
In my home config directory: ~/.config/rofi
I have two files; the config file config.rasi
and the theme file Monokai.rasi
config.rasi
configuration {
modi: "window,run,drun,combi";
font: "Awesome 11";
location: 0;
yoffset: 20;
xoffset: 0;
fixed-num-lines: false;
show-icons: true;
terminal: "lxterminal";
ssh-client: "ssh";
ssh-command: "{terminal} -e {ssh-client} {host}";
run-command: "{cmd}";
run-list-command: "";
run-shell-command: "{terminal} -e {cmd}";
window-command: "xkill -id {window}";
disable-history: false;
case-sensitive: false;
cycle: true;
sidebar-mode: false;
eh: 1;
auto-select: false;
parse-hosts: false;
parse-known-hosts: true;
combi-modi: "window,drun";
tokenize: true;
m: "-1";
filter: "";
dpi: -1;
threads: 1;
scroll-method: 0;
}
@theme "Monokai"
Monokai.rasi, the theme file which I don't remember where I got it from
/**
* ROFI Color theme
* User: milouse
* Copyright: Étienne Deparis
*/
* {
selected-normal-foreground: rgba ( 0, 0, 0, 100 % );
foreground: rgba ( 248, 248, 242, 100 % );
normal-foreground: @foreground;
alternate-normal-background: rgba ( 39, 40, 34, 0 % );
red: rgba ( 220, 50, 47, 100 % );
selected-urgent-foreground: rgba ( 248, 248, 242, 100 % );
blue: rgba ( 38, 139, 210, 100 % );
urgent-foreground: rgba ( 249, 38, 114, 100 % );
alternate-urgent-background: rgba ( 39, 40, 34, 0 % );
active-foreground: rgba ( 166, 226, 42, 100 % );
lightbg: rgba ( 238, 232, 213, 100 % );
selected-active-foreground: rgba ( 166, 226, 42, 100 % );
alternate-active-background: rgba ( 39, 40, 34, 0 % );
background: rgba ( 39, 40, 34, 93 % );
bordercolor: rgba ( 0, 43, 54, 100 % );
alternate-normal-foreground: @foreground;
normal-background: rgba ( 39, 40, 34, 0 % );
lightfg: rgba ( 88, 104, 117, 100 % );
selected-normal-background: rgba ( 248, 248, 248, 100 % );
border-color: @foreground;
spacing: 2;
separatorcolor: rgba ( 230, 219, 116, 100 % );
urgent-background: rgba ( 39, 40, 34, 0 % );
selected-urgent-background: rgba ( 249, 38, 114, 100 % );
alternate-urgent-foreground: @urgent-foreground;
background-color: rgba ( 0, 0, 0, 0 % );
alternate-active-foreground: @active-foreground;
active-background: rgba ( 39, 40, 34, 0 % );
selected-active-background: rgba ( 20, 20, 17, 100 % );
}
window {
background-color: @background;
border: 1;
padding: 5;
}
mainbox {
border: 0;
padding: 0;
}
message {
border: 2px 0px 0px ;
border-color: @separatorcolor;
padding: 1px ;
}
textbox {
text-color: @foreground;
}
listview {
fixed-height: 0;
border: 2px 0px 0px ;
border-color: @separatorcolor;
spacing: 2px ;
scrollbar: true;
padding: 2px 0px 0px ;
}
element {
border: 0;
padding: 1px ;
}
element-text {
background-color: inherit;
text-color: inherit;
}
element.normal.normal {
background-color: @normal-background;
text-color: @normal-foreground;
}
element.normal.urgent {
background-color: @urgent-background;
text-color: @urgent-foreground;
}
element.normal.active {
background-color: @active-background;
text-color: @active-foreground;
}
element.selected.normal {
background-color: @selected-normal-background;
text-color: @selected-normal-foreground;
}
element.selected.urgent {
background-color: @selected-urgent-background;
text-color: @selected-urgent-foreground;
}
element.selected.active {
background-color: @selected-active-background;
text-color: @selected-active-foreground;
}
element.alternate.normal {
background-color: @alternate-normal-background;
text-color: @alternate-normal-foreground;
}
element.alternate.urgent {
background-color: @alternate-urgent-background;
text-color: @alternate-urgent-foreground;
}
element.alternate.active {
background-color: @alternate-active-background;
text-color: @alternate-active-foreground;
}
scrollbar {
width: 4px ;
border: 0;
handle-width: 8px ;
padding: 0;
}
mode-switcher {
border: 2px 0px 0px ;
border-color: @separatorcolor;
}
button.selected {
background-color: @selected-normal-background;
text-color: @selected-normal-foreground;
}
inputbar {
spacing: 0;
text-color: @normal-foreground;
padding: 1px ;
}
case-indicator {
spacing: 0;
text-color: @normal-foreground;
}
entry {
spacing: 0;
text-color: @normal-foreground;
}
prompt {
spacing: 0;
text-color: @normal-foreground;
}
inputbar {
children: [ prompt,textbox-prompt-colon,entry,case-indicator ];
}
textbox-prompt-colon {
expand: false;
str: ":";
margin: 0px 0.3em 0em 0em ;
text-color: @normal-foreground;
}
Conclusion
Rofi is a versatile and lightweight application launcher, window switcher, SSH dialog, and dmenu replacement for Linux systems. It provides a fast and efficient way to launch applications, switch between windows, and perform a variety of other tasks. With its extensive customization options, you can tailor Rofi to your needs and preferences. Try it out and see how it can improve your workflow!
0 Comments, latest
No comments.