### Example: Install Rofi to /usr Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md An example of setting the installation prefix to `/usr` using Meson. ```bash meson setup build --prefix /usr ``` -------------------------------- ### Install Rofi Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Installs the compiled rofi application. Execute with root privileges if installing to a system-wide location. ```bash ninja -C build install ``` -------------------------------- ### Install Rofi from Source Source: https://context7.com/davatorium/rofi/llms.txt Build and install Rofi from its GitHub repository using Meson. Includes commands for installing build dependencies on Debian/Ubuntu and build configuration options for Wayland or X11 only. ```bash # Install build dependencies (Debian/Ubuntu) apt install meson ninja-build pkg-config flex bison \ libpango1.0-dev libcairo2-dev libglib2.0-dev libgdk-pixbuf-2.0-dev \ libstartup-notification0-dev libxkbcommon-dev libxkbcommon-x11-dev \ libxcb1-dev libxcb-xkb-dev libxcb-randr0-dev libxcb-xinerama0-dev \ xcb-util-wm-dev xcb-util-dev xcb-util-cursor-dev \ libwayland-dev wayland-protocols # Clone and build git clone --recursive https://github.com/DaveDavenport/rofi cd rofi/ meson setup build --prefix /usr ninja -C build sudo ninja -C build install # Or install from distro packages apt install rofi # Debian/Ubuntu dnf install rofi # Fedora pacman -S rofi # Arch Linux brew install rofi # macOS (via MacPorts: sudo port install rofi) # Build with only Wayland (no X11) meson setup build -Dxcb=disabled # Build with only X11 (no Wayland) meson setup build -Dwayland=disabled ``` -------------------------------- ### Install rofi on FreeBSD Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Use pkg to install rofi on FreeBSD. ```bash sudo pkg install rofi ``` -------------------------------- ### ROFI Configuration Example with Comments Source: https://github.com/davatorium/rofi/blob/next/CONFIG.md An example of a dumped ROFI configuration file, showing commented-out default settings. ```css configuration { /* modes: "window,run,ssh,drun";*/ /* font: "mono 12";*/ /* location: 0;*/ /* yoffset: 0;*/ /* xoffset: 0;*/ /* fixed-num-lines: true;*/ ... /* ml-row-down: "ScrollDown";*/ /* me-select-entry: "MousePrimary";*/ /* me-accept-entry: "MouseDPrimary";*/ /* me-accept-custom: "Control+MouseDPrimary";*/ } ``` -------------------------------- ### Install Rofi Locally with Meson Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Configures Meson to install rofi to the user's local directory. This is useful for testing or avoiding system-wide installations. ```bash meson setup build --prefix ${HOME}/.local ``` -------------------------------- ### Rofi Padding Example Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Illustrates how to set padding using a percentage of the monitor size. This example shows a 10% padding which translates to 192px horizontally and 108px vertically on a 1920x1080 monitor. ```css padding: 10%; ``` -------------------------------- ### Set Custom Installation Prefix with Meson Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Configures the Meson build system to install rofi to a specified directory. Replace `` with your desired location. ```bash meson setup build --prefix ``` -------------------------------- ### Install rofi on openSUSE Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Use zypper to install rofi on openSUSE Leap and Tumbleweed. ```bash sudo zypper install rofi ``` -------------------------------- ### Full rofi theme example in .rasi format Source: https://context7.com/davatorium/rofi/llms.txt A comprehensive example of a rofi theme using .rasi syntax, including global variables, widget styling, and media queries for responsiveness. ```css /* ~/.config/rofi/config.rasi — full theme example */ @theme "gruvbox-light" /* Global variables */ * { bg: #282828; fg: #ebdbb2; accent: #458588; urgent-color: #cc241d; font: "JetBrains Mono 12"; border-color: @accent; } window { background-color: @bg; border: 2px solid; border-radius: 8px; width: 50%; location: center; anchor: center; /* True transparency requires a compositor */ transparency: "real"; } inputbar { children: [ prompt, entry, case-indicator ]; padding: 6px; spacing: 6px; } prompt { text-color: @accent; font: "JetBrains Mono Bold 12"; } entry { placeholder: "Type to filter..."; placeholder-color: #665c54; cursor-color: @accent; cursor-width: 3px; hide-cursor-on-empty: true; text-color: @fg; } listview { lines: 10; columns: 1; scrollbar: true; spacing: 2px; fixed-height: true; dynamic: false; } element { padding: 4px 8px; border-radius: 4px; orientation: horizontal; children: [ element-icon, element-text ]; spacing: 6px; } element-icon { size: 1.5em; vertical-align: 0.5; } element-text { vertical-align: 0.5; text-color: @fg; highlight: bold @accent; } element selected.normal { background-color: @accent; text-color: @bg; } element urgent { text-color: @urgent-color; } element active { text-color: #b8bb26; } scrollbar { handle-color: @accent; handle-width: 4px; handle-rounded-corners: true; background-color: transparent; } /* Responsive: full-screen on small monitors */ @media ( max-width: 1280 px ) { window { width: 80%; } } /* Apply different style in dmenu mode */ @media ( enabled: DMENU ) { window { anchor: north; location: north; width: 100%; } } ``` -------------------------------- ### Install rofi on macOS with MacPorts Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Use MacPorts to install rofi on macOS. ```bash sudo port install rofi ``` -------------------------------- ### Install Rofi on Arch Linux Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Installs rofi using the pacman package manager on Arch Linux. ```bash pacman -S rofi ``` -------------------------------- ### Install Rofi on Debian/Ubuntu Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Installs rofi using the apt package manager on Debian-based systems. ```bash apt install rofi ``` -------------------------------- ### Install rofi as dmenu drop-in replacement Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-dmenu.5.markdown Creates a symbolic link to use rofi as a drop-in replacement for dmenu. ```bash ln -s /usr/bin/rofi /usr/bin/dmenu ``` -------------------------------- ### Dmenu Emulation Theme Example Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown A comprehensive rofi theme example designed to emulate the appearance and behavior of dmenu. It sets global styles, window properties, and defines the layout for input and list views. ```css * { background-color: Black; text-color: White; border-color: White; font: "Times New Roman 12"; } window { anchor: north; location: north; width: 100%; padding: 4px; children: [ horibox ]; } horibox { orientation: horizontal; children: [ prompt, entry, listview ]; } listview { layout: horizontal; spacing: 5px; lines: 10; } entry { expand: false; width: 10em; } element { padding: 0px 2px; } element selected { background-color: SteelBlue; } ``` -------------------------------- ### Integer Property Example Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Demonstrates the syntax for defining an integer value for a property. ```css lines: 12; ``` -------------------------------- ### CSS Color Examples for Rofi Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Demonstrates how to apply background, border, and text colors using hexadecimal, RGBA, and named color formats. ```css background-color: #FF0000; border-color: rgba(0,0,1, 0.5); text-color: SeaGreen; ``` ```css background-color: transparent; text-color: Black; ``` -------------------------------- ### Get rofi help information Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-debugging.5.markdown This command provides details about parsed configuration files, rofi version, and monitor layout, useful for debugging. ```bash rofi -help ``` -------------------------------- ### Install Rofi on Fedora Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Installs rofi using the dnf package manager on Fedora systems. ```bash dnf install rofi ``` -------------------------------- ### Example XDG Thumbnailer Configuration Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-thumbnails.5.markdown This is an example of a .thumbnailer file for SVG images. It specifies the command to execute and the MIME types it supports. ```ini [Thumbnailer Entry] TryExec=/usr/bin/gdk-pixbuf-thumbnailer Exec=/usr/bin/gdk-pixbuf-thumbnailer -s %s %u %o MimeType=image/svg+xml;image/svg+xml-compressed; ``` -------------------------------- ### Simple rofi-script Example Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-script.5.markdown A basic bash script demonstrating the rofi-script API. It outputs 'reload' and 'quit' options and handles the 'quit' command. ```bash #!/usr/bin/env bash if [ x"$@" = x"quit" ] then exit 0 fi echo "reload" echo "quit" ``` -------------------------------- ### Example Advanced Font String Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown An example demonstrating the advanced font string format with family, style, weight, and a specific variation. ```text "Cantarell Italic Light 15 \`wght`=200" ``` -------------------------------- ### ROFI String Data Type Example Source: https://github.com/davatorium/rofi/blob/next/mkdocs/docs/CONFIG.md Illustrates the syntax for defining string values in ROFI configuration. ```css ml-row-down: "ScrollDown"; ``` -------------------------------- ### Example Rofi Timing Trace Output Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-debugging.5.markdown This is an example of the output generated when rofi's timing traces are enabled. It shows the time taken at various stages of rofi's execution, helping to pinpoint slow operations. ```text (process:14942): Timings-DEBUG: 13:47:39.335: 0.000000 (0.000000): Started (process:14942): Timings-DEBUG: 13:47:39.335: 0.000126 (0.000126): ../source/rofi.c:main:786 (process:14942): Timings-DEBUG: 13:47:39.335: 0.000163 (0.000037): ../source/rofi.c:main:819 (process:14942): Timings-DEBUG: 13:47:39.336: 0.000219 (0.000056): ../source/rofi.c:main:826 Setup Locale (process:14942): Timings-DEBUG: 13:47:39.337: 0.001235 (0.001016): ../source/rofi.c:main:828 Collect MODI (process:14942): Timings-DEBUG: 13:47:39.337: 0.001264 (0.000029): ../source/rofi.c:main:830 Setup MODI (process:14942): Timings-DEBUG: 13:47:39.337: 0.001283 (0.000019): ../source/rofi.c:main:834 Setup mainloop (process:14942): Timings-DEBUG: 13:47:39.337: 0.001369 (0.000086): ../source/rofi.c:main:837 NK Bindings (process:14942): Timings-DEBUG: 13:47:39.337: 0.001512 (0.000143): ../source/xcb.c:display_setup:1177 Open Display (process:14942): Timings-DEBUG: 13:47:39.337: 0.001829 (0.000317): ../source/xcb.c:display_setup:1192 Setup XCB (process:14942): Timings-DEBUG: 13:47:39.346: 0.010650 (0.008821): ../source/rofi.c:main:844 Setup Display (process:14942): Timings-DEBUG: 13:47:39.346: 0.010715 (0.000065): ../source/rofi.c:main:848 Setup abe (process:14942): Timings-DEBUG: 13:47:39.350: 0.015101 (0.004386): ../source/rofi.c:main:883 Load cmd config (process:14942): Timings-DEBUG: 13:47:39.351: 0.015275 (0.000174): ../source/rofi.c:main:907 Setup Modi (process:14942): Timings-DEBUG: 13:47:39.351: 0.015291 (0.000016): ../source/view.c:rofi_view_workers_initialize:1922 Setup Threadpool, start (process:14942): Timings-DEBUG: 13:47:39.351: 0.015349 (0.000058): ../source/view.c:rofi_view_workers_initialize:1945 Setup Threadpool, done (process:14942): Timings-DEBUG: 13:47:39.367: 0.032018 (0.016669): ../source/rofi.c:main:1000 Setup late Display (process:14942): Timings-DEBUG: 13:47:39.367: 0.032080 (0.000062): ../source/rofi.c:main:1003 Theme setup (process:14942): Timings-DEBUG: 13:47:39.367: 0.032109 (0.000029): ../source/rofi.c:startup:668 Startup (process:14942): Timings-DEBUG: 13:47:39.367: 0.032121 (0.000012): ../source/rofi.c:startup:677 Grab keyboard (process:14942): Timings-DEBUG: 13:47:39.368: 0.032214 (0.000093): ../source/view.c:__create_window:701 xcb create window (process:14942): Timings-DEBUG: 13:47:39.368: 0.032235 (0.000021): ../source/view.c:__create_window:705 xcb create gc (process:14942): Timings-DEBUG: 13:47:39.331: 0.033136 (0.000901): ../source/view.c:__create_window:714 create cairo surface (process:14942): Timings-DEBUG: 13:47:39.369: 0.033286 (0.000150): ../source/view.c:__create_window:723 pango cairo font setup (process:14942): Timings-DEBUG: 13:47:39.369: 0.033351 (0.000065): ../source/view.c:__create_window:761 configure font (process:14942): Timings-DEBUG: 13:47:39.381: 0.045896 (0.012545): ../source/view.c:__create_window:769 textbox setup (process:14942): Timings-DEBUG: 13:47:39.381: 0.045944 (0.000048): ../source/view.c:__create_window:781 setup window attributes (process:14942): Timings-DEBUG: 13:47:39.381: 0.045955 (0.000011): ../source/view.c:__create_window:791 setup window fullscreen (process:14942): Timings-DEBUG: 13:47:39.381: 0.045966 (0.000011): ../source/view.c:__create_window:797 setup window name and class (process:14942): Timings-DEBUG: 13:47:39.381: 0.045974 (0.000008): ../source/view.c:__create_window:808 setup startup notification (process:14942): Timings-DEBUG: 13:47:39.381: 0.045981 (0.000007): ../source/view.c:__create_window:810 done (process:14942): Timings-DEBUG: 13:47:39.381: 0.045992 (0.000011): ../source/rofi.c:startup:679 Create Window (process:14942): Timings-DEBUG: 13:47:39.381: 0.045999 (0.000007): ../source/rofi.c:startup:681 Parse ABE (process:14942): Timings-DEBUG: 13:47:39.381: 0.046113 (0.000114): ../source/rofi.c:startup:684 Config sanity check (process:14942): Timings-DEBUG: 13:47:39.384: 0.048229 (0.002116): ../source/dialogs/run.c:get_apps:216 start (process:14942): Timings-DEBUG: 13:47:39.390: 0.054626 (0.006397): ../source/dialogs/run.c:get_apps:336 stop (process:14942): Timings-DEBUG: 13:47:39.390: 0.054781 (0.000155): ../source/dialogs/drun.c:get_apps:634 Get Desktop apps (start) (process:14942): Timings-DEBUG: 13:47:39.391: 0.055264 (0.000483): ../source/dialogs/drun.c:get_apps:641 Get Desktop apps (user dir) (process:14942): Timings-DEBUG: 13:47:39.418: 0.082884 (0.027620): ../source/dialogs/drun.c:get_apps:659 Get Desktop apps (system dirs) (process:14942): Timings-DEBUG: 13:47:39.418: 0.082944 (0.000060): ../source/dialogs/drun.c:get_apps_history:597 Start drun history ``` -------------------------------- ### Launch rofi in drun mode Source: https://github.com/davatorium/rofi/blob/next/doc/rofi.1.markdown Use this command to launch rofi and display the 'drun' dialog, which lists installed applications. ```bash rofi -show drun ``` -------------------------------- ### Rofi Theme State Example Source: https://github.com/davatorium/rofi/blob/next/mkdocs/docs/2.0.0/rofi-theme.5.markdown Demonstrates how to apply styles based on widget states like 'selected' and 'urgent'. States modify original elements and inherit their properties. ```css button selected.normal { } element selected.urgent { } ``` ```css nametotextbox selected.active { background-color: #003642; text-color: #008ed4; } ``` -------------------------------- ### Widget State Example Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Demonstrates how to apply styles based on widget states like 'selected' and 'urgent'. States modify existing element properties. ```css button selected.normal { } ``` ```css element selected.urgent { } ``` -------------------------------- ### Build Rofi with Ninja Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Compiles rofi using the Ninja build tool after Meson setup. This command should be run from the project's root directory. ```bash ninja -C build ``` -------------------------------- ### Dump rofi configuration to a file Source: https://github.com/davatorium/rofi/blob/next/doc/rofi.1.markdown Generate a template configuration file for rofi. This file contains all configuration options, commented out, serving as a starting point for customization. ```bash rofi -dump-config > config.rasi ``` -------------------------------- ### Basic rofi-script Mode Configuration Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-script.5.markdown Example of how to specify a script mode in rofi. This sets up a mode named 'fb' that uses the 'file_browser.sh' script. ```bash rofi -show fb -modes "fb:file_browser.sh" ``` -------------------------------- ### Markup String for Icon Rendering Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Demonstrates how to render a string as an icon using Pango markup, allowing for color and font customization. This example pipes the output to rofi's dmenu mode. ```bash echo -en "testing\0icon\x1f" | ./rofi -dmenu ``` -------------------------------- ### Rofi configuration settings in config.rasi Source: https://context7.com/davatorium/rofi/llms.txt Example configuration settings for rofi, including modes, matching, behavior, and specific mode options like drun and filebrowser. ```css /* ~/.config/rofi/config.rasi */ configuration { /* Modes to enable */ modes: [ combi ]; combi-modes: [ window, drun, run ]; show-icons: true; icon-theme: "Papirus"; /* Matching */ matching: "fuzzy"; tokenize: true; sort: true; sorting-method: "fzf"; normalize-match: true; /* Behavior */ cycle: true; max-history-size: 25; click-to-exit: true; steal-focus: false; /* SSH mode */ parse-hosts: true; parse-known-hosts: true; /* drun mode options */ drun { scan-desktop: true; parse-user: true; parse-system: true; } /* File browser */ filebrowser { directory: "~"; sorting-method: "name"; directories-first: true; show-hidden: false; command: "xdg-open"; } /* Recursive browser with filter */ recursivebrowser { directory: "/home/user/projects"; filter-regex: "(.*\\.o|.*cache.*)"; command: "xdg-open"; } /* Auto-cancel after 15 seconds of inactivity */ timeout { delay: 15; action: "kb-cancel"; } /* Jump to first result when filter text changes */ inputchange { action: "kb-row-first"; } /* Per-mode fallback icon */ run,drun { fallback-icon: "application-x-addon"; } /* Entry history */ entry { max-history: 30; } } ``` -------------------------------- ### Rofi Script Mode: File Browser Example Source: https://context7.com/davatorium/rofi/llms.txt A bash script demonstrating a custom Rofi mode for browsing files. It handles initialization, directory traversal, file opening, and custom entry creation. ```bash #!/usr/bin/env bash # ~/.config/rofi/scripts/mymode.sh # Register: rofi -modes "MyMode:~/.config/rofi/scripts/mymode.sh" -show MyMode # Or place in ~/.config/rofi/scripts/ and run: rofi -show mymode # ROFI_RETV: 0=init, 1=entry selected, 2=custom entry, 3=entry deleted # ROFI_INFO: value of 'info' field of selected entry # ROFI_DATA: persistent data set by this script # ROFI_INPUT: raw user input string case "$ROFI_RETV" in 0) # Initial call — set up display options and list entries printf "\0prompt\x1fFile Browser\n" # Set prompt text printf "\0message\x1fSelect a file\n" # Message below entry (supports Pango) printf "\0markup-rows\x1ftrue\n" # Render markup in rows printf "\0no-custom\x1ffalse\n" # Allow free-text entry printf "\0use-hot-keys\x1ftrue\n" # Enable kb-custom-1..19 printf "\0data\x1f/home/user\n" # Persist state via ROFI_DATA # Entries with per-row options: \0key\x1fvalue (can chain multiple with \x1f) printf "Documents\0icon\x1ffolder\x1finfo\x1f/home/user/Documents\n" printf "Videos\0icon\x1ffolder,inode-directory\x1finfo\x1f/home/user/Videos\n" printf "README.md\0icon\x1ftext-x-readme\x1fmeta\x1fdocumentation readme\n" printf "separator\0nonselectable\x1ftrue\x1fpermanent\x1ftrue\n" printf "Create new…\0display\x1fCreate new…\n" ;; 1) # Entry selected — $1 is displayed text, ROFI_INFO has the 'info' value selected_path="$ROFI_INFO" if [ -d "$selected_path" ]; then # Recurse into directory — keep selection position, update data printf "\0keep-selection\x1ftrue\n" printf "\0data\x1f${selected_path}\n" for f in "$selected_path"/*; do name=$(basename "$f") if [ -d "$f" ]; then printf "%s\0icon\x1ffolder\x1finfo\x1f%s\n" "$name" "$f" else printf "%s\0icon\x1ftext-x-generic\x1finfo\x1f%s\n" "$name" "$f" fi done else # Open file and exit coproc ( xdg-open "$selected_path" > /dev/null 2>&1 ) exit 0 fi ;; 10) # kb-custom-1 pressed (Alt+1) — switch to drun mode printf "\0switch-mode\x1fdrun\n" ;; 3) # Entry deleted (Shift+Delete) — handle deletion echo "Deleting: $1" >> /tmp/rofi-deleted.log ;; 2) # Custom text entered (not matching a listed entry) coproc ( xdg-open "$1" > /dev/null 2>&1 ) exit 0 ;; esac ``` -------------------------------- ### Enable Rofi Debug Output Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-debugging.5.markdown Set the G_MESSAGES_DEBUG environment variable to enable specific debug domains. For example, to get debug output from the Desktop file run dialog, use 'Dialogs.DRun'. ```bash G_MESSAGES_DEBUG=Dialogs.DRun rofi -show drun ``` -------------------------------- ### Configure File Browser Settings Source: https://github.com/davatorium/rofi/blob/next/doc/rofi.1.markdown Set various options for the file browser, including starting directory, sorting method, and whether to show hidden files. ```css configuration { filebrowser { /** Directory the file browser starts in. */ directory: "/some/directory"; /** * Sorting method. Can be set to: * - "name" * - "mtime" (modification time) * - "atime" (access time) * - "ctime" (change time) */ sorting-method: "name"; /** Group directories before files. */ directories-first: true; /** Show hidden files. */ show-hidden: false; /** return 1 on cancel. */ cancel-returns-1: true; /** command */ command: "xdg-open"; } } ``` -------------------------------- ### Run Rofi with Custom Plugin Source: https://github.com/davatorium/rofi/blob/next/mkdocs/docs/guides/Plugins/2017-04-19-rofi-140-sneak-preview-plugins.md This bash command demonstrates how to launch Rofi and enable the custom 'file_browser' plugin. Use this after building the plugin. ```bash rofi -show file_browser -modi file_browser ``` -------------------------------- ### Configure Rofi Build with Meson Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Sets up the build system for rofi using Meson. Ensure all dependencies are met before running. ```bash meson setup build ``` -------------------------------- ### Configure Input Change Action in Rofi Source: https://github.com/davatorium/rofi/blob/next/doc/rofi.1.markdown Specify an action to be executed whenever the input in rofi's text box changes. This example binds the 'kb-row-first' action to input changes. ```css configuration { inputchange { action: "kb-row-first"; } } ``` -------------------------------- ### Generate Backtrace with GDB Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-debugging.5.markdown Enable core file generation (ulimit -c unlimited) and then load the core dump in GDB to analyze crashes. Use 'thread apply all bt' within GDB to get the backtrace. ```bash gdb rofi core ``` ```gdb thread apply all bt ``` -------------------------------- ### Run Rofi with Preview Enabled Source: https://github.com/davatorium/rofi/blob/next/mkdocs/docs/guides/DynamicThemes/dynamic_themes.md Execute Rofi with the 'PREVIEW' environment variable set to 'true' to activate the dynamic preview widget and layout changes defined in the theme. ```bash PREVIEW=true rofi -theme fullscreen-preview.rasi -show filebrowser ``` -------------------------------- ### Rofi Centering with Dummy Widgets Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Demonstrates advanced box packing using dummy widgets with 'expand: true' to center a child widget. ```text ┌────────────────────────────────────┐ │ ┌───────────────┐ ┌────────┐ ┌───────────────┐ │ │ │ dummy │ │ child │ │ dummy │ │ │ │ expand: true; │ │ │ │ expand: true; │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └───────────────┘ └────────┘ └───────────────┘ │ └────────────────────────────────────┘ ``` -------------------------------- ### Enable ~arch for Gentoo Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Add rofi to package.accept_keywords to enable ~arch for the latest release on Gentoo. ```bash echo 'x11-misc/rofi ~amd64' >> /etc/portage/package.accept_keywords ``` ```bash echo 'x11-misc/rofi ~x86' >> /etc/portage/package.accept_keywords ``` -------------------------------- ### Enable ~arch for Rofi on Gentoo Source: https://github.com/davatorium/rofi/blob/next/mkdocs/docs/INSTALL.md Add Rofi to package.accept_keywords to enable ~arch for the latest release on Gentoo. ```bash echo 'x11-misc/rofi ~amd64' >> /etc/portage/package.accept_keywords ``` -------------------------------- ### i3/Sway Keybinding for Rofi Source: https://context7.com/davatorium/rofi/llms.txt Configure keybindings in i3 or Sway config files to launch Rofi. Using `--release` is recommended to avoid keyboard grab issues. ```bash # ~/.config/i3/config: bindsym --release $mod+d exec rofi -show drun ``` -------------------------------- ### ROFI List Data Type Example (rasi format) Source: https://github.com/davatorium/rofi/blob/next/mkdocs/docs/CONFIG.md Example of defining a list of string values using the rasi format. ```css combi-modes: [window,drun]; ``` -------------------------------- ### ROFI Configuration: Splitting with Imports Source: https://github.com/davatorium/rofi/blob/next/CONFIG.md Shows how to split ROFI configuration across multiple files using `@import` and `@theme` directives. ```css configuration { } @import "myConfig" @theme "MyTheme" ``` -------------------------------- ### Rofi Theme Imports and CSS-like Properties Source: https://context7.com/davatorium/rofi/llms.txt Demonstrates how to import other theme files and use CSS-like properties for theming. Supports environment variables and basic arithmetic calculations. ```css /* Use @theme to discard the current theme and load a new one */ @theme "Arc-Dark" /* Use @import to layer on top of an existing theme */ @import "~/.config/rofi/themes/base.rasi" @import "~/.config/rofi/themes/colors.rasi" /* Optional import — no error if file is missing */ ?import "~/.config/rofi/themes/local-overrides.rasi" /* Reference environment variables in theme values */ * { background-color: ${ROFI_BG}; text-color: env(ROFI_FG, #eeeeee); } /* Theme property calc() — CSS-like arithmetic */ window { width: calc( 100% - 40px ); } listview { lines: calc( 20 min 10 ); } ``` -------------------------------- ### Set Ellipsize Mode to Start Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-dmenu.5.markdown The -keep-right flag sets the ellipsize mode to 'start', ensuring the end of the string remains visible when truncated. ```bash rofi -dmenu -keep-right ``` -------------------------------- ### Real Number Property Example Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Provides an example of a fractional number (real) value for a property. Note that scientific notation and trailing/leading decimal points are not valid. ```css real: 3.4; ``` -------------------------------- ### Get Display Value for File Browser Entries Source: https://github.com/davatorium/rofi/blob/next/mkdocs/docs/guides/Plugins/2017-04-19-rofi-140-sneak-preview-plugins.md This function is called by rofi to get the display string for each entry. It prepends icons based on file type and returns a dynamically allocated string. ```c static char *_get_display_value ( const Mode *sw, unsigned int selected_line, G_GNUC_UNUSED int *state, G_GNUC_UNUSED GList **attr_list, int get_entry ) { FileBrowserModePrivateData *pd = (FileBrowserModePrivateData *) mode_get_private_data ( sw ); // Only return the string if requested, otherwise only set state. if ( !get_entry ) return NULL; if ( pd->array[selected_line].type == DIRECTORY ){ return g_strdup_printf ( " %s", pd->array[selected_line].name); } else if ( pd->array[selected_line].type == UP ){ return g_strdup( " .."); } else { return g_strdup_printf ( " %s", pd->array[selected_line].name); } return g_strdup("n/a"); } ``` -------------------------------- ### Run Rofi with Basic Theme Source: https://github.com/davatorium/rofi/blob/next/mkdocs/docs/guides/DynamicThemes/dynamic_themes.md Launch Rofi using a specified theme file and the 'filebrowser' mode. This command applies the 'fullscreen-preview.rasi' theme. ```bash rofi -theme fullscreen-preview.rasi -show filebrowser ``` -------------------------------- ### Show Key Bindings Source: https://github.com/davatorium/rofi/blob/next/doc/rofi.1.markdown Displays a searchable list of rofi's key bindings. ```bash rofi -show keys ``` -------------------------------- ### Test Rofi Plugin Source: https://github.com/davatorium/rofi/blob/next/mkdocs/docs/guides/Plugins/2017-04-19-rofi-140-sneak-preview-plugins.md Command to test the installed Rofi plugin by showing it with a specific mode. ```bash rofi -show myplugin -modi myplugin ``` -------------------------------- ### String Property Example Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Illustrates how to define a string value for a property, enclosed in double quotes. ```css font: "Awasome 12"; ``` -------------------------------- ### Enable ~x86 for Rofi on Gentoo Source: https://github.com/davatorium/rofi/blob/next/mkdocs/docs/INSTALL.md Add Rofi to package.accept_keywords to enable ~x86 for the latest release on Gentoo. ```bash echo 'x11-misc/rofi ~x86' >> /etc/portage/package.accept_keywords ``` -------------------------------- ### ROFI Configuration: Number Data Type Source: https://github.com/davatorium/rofi/blob/next/CONFIG.md Example of defining an integer value in ROFI configuration. ```css eh: 2; ``` -------------------------------- ### Boolean Property Example Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Shows how to set a boolean property to either true or false. The values are case-sensitive. ```css dynamic: false; ``` -------------------------------- ### ROFI Configuration: Boolean Data Type Source: https://github.com/davatorium/rofi/blob/next/CONFIG.md Example of defining a boolean value in ROFI configuration. Values are case-sensitive. ```css show-icons: true; ``` -------------------------------- ### dmenu Basic Usage Source: https://github.com/davatorium/rofi/wiki/dmenu_specs Demonstrates the fundamental dmenu behavior of reading from stdin, displaying entries, and outputting the selected entry to stdout. ```bash echo -e "foo\nbar" | rofi -dmenu ``` -------------------------------- ### Rofi Debug Parser Command Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Run Rofi with the 'G_MESSAGES_DEBUG=Parser' environment variable to get debug information from the theme parser. ```bash G_MESSAGES_DEBUG=Parser rofi -show run ``` -------------------------------- ### Clone Rofi Repository Source: https://github.com/davatorium/rofi/blob/next/INSTALL.md Clones the rofi git repository recursively to include submodules. This is the first step for installing from a git checkout. ```bash git clone --recursive https://github.com/DaveDavenport/rofi ``` -------------------------------- ### Create Interactive Power Menu with Rofi Source: https://context7.com/davatorium/rofi/llms.txt Combine `printf`, `rofi -dmenu`, and `xargs` to build a dynamic power menu that executes system commands based on user selection. ```bash printf "Shutdown\nReboot\nSuspend\nLock" | \ rofi -dmenu -p "Power:" -i | \ xargs -I{} bash -c 'case "{}" in Shutdown) systemctl poweroff ;; Reboot) systemctl reboot ;; Suspend) systemctl suspend ;; Lock) loginctl lock-session ;; esac' ``` -------------------------------- ### Run Application in Dedicated Systemd Cgroup Source: https://github.com/davatorium/rofi/blob/next/doc/rofi.1.markdown Example of running applications in a dedicated cgroup using systemd. Requires shell escaping and interpolation. ```bash "bash -c 'systemd-run --user --unit=app-rofi-\\\$(systemd-escape {cmd})-\\$RANDOM {cmd}'" ``` -------------------------------- ### Configure `window` Switcher Options Source: https://context7.com/davatorium/rofi/llms.txt Customize the display format, icon preferences, and matching fields for the window switcher mode. Options include custom formatting, showing thumbnails, and specifying which fields to match against. ```bash # Custom window display format: desktop, class, title rofi -show window -window-format "{w} {c} {t}" # Show window thumbnails as icons rofi -show window -window-thumbnail # Match only title and class rofi -show window -window-match-fields "title,class" # Run command on alt-accept (Shift+Enter) against selected window rofi -show window -window-command "wmctrl -i -R {window}" ``` -------------------------------- ### Rofi dmenu with Custom Format Source: https://github.com/davatorium/rofi/wiki/dmenu_specs Shows how to use rofi's -format argument to customize the output, displaying line numbers and content. ```bash echo -e "foo\nbar" | rofi -dmenu -format i:s ``` -------------------------------- ### AppArmor Profile for Rofi Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-thumbnails.5.markdown An example AppArmor profile to grant rofi necessary permissions for thumbnail generation. This can be used as an alternative to disabling AppArmor. ```apparmor #vim:syntax=apparmor # AppArmor policy for rofi #include /usr/bin/rofi { #include # TCP/UDP network access for NFS network inet stream, network inet6 stream, network inet dgram, network inet6 dgram, /usr/bin/rofi mr, @{HOME}/ r, @{HOME}/** rw, owner @{HOME}/.cache/thumbnails/** rw, } ``` -------------------------------- ### ROFI Configuration: String Data Type Source: https://github.com/davatorium/rofi/blob/next/CONFIG.md Example of defining a string value in ROFI configuration. Strings must be enclosed in double quotes. ```css ml-row-down: "ScrollDown"; ``` -------------------------------- ### Set SSH Command Pattern Source: https://github.com/davatorium/rofi/blob/next/doc/rofi.1.markdown Defines the command executed when starting an SSH session. The {host} pattern is replaced by the selected SSH entry. ```bash rofi -ssh-command "{terminal} -e {ssh-client} {host}" ``` -------------------------------- ### Basic rofi dmenu usage Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-dmenu.5.markdown Launches rofi in dmenu emulation mode, piping the output of 'ls' to rofi for selection. ```bash ls | rofi -dmenu ``` -------------------------------- ### Set Ellipsize Mode for Listview Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-dmenu.5.markdown The -ellipsize-mode flag controls how text is truncated in the listview. Options are 'start', 'middle', or 'end'. The default is 'end'. ```bash rofi -dmenu -ellipsize-mode middle ``` -------------------------------- ### Reference Theme in config.rasi Source: https://github.com/davatorium/rofi/wiki/Themes Include a theme reference within your `config.rasi` file. This allows Rofi to load the specified theme automatically when it starts. ```css @theme "mytheme" ``` -------------------------------- ### Rofi dmenu with Icons Source: https://github.com/davatorium/rofi/wiki/dmenu_specs Illustrates how to include icon information with entries using null and field separator characters. ```bash echo -en "aap\0icon\x1ffolder\n" ``` -------------------------------- ### Display Rofi System Information Source: https://context7.com/davatorium/rofi/llms.txt Use `rofi -info` to display system information and `rofi -help` for command-line options, both useful for bug reports. ```bash rofi -info ``` ```bash rofi -help ``` -------------------------------- ### String Property Examples Source: https://github.com/davatorium/rofi/blob/next/mkdocs/docs/2.0.0/rofi-theme.5.markdown Demonstrates the syntax for string properties, which must be enclosed in double or single quotes. Special characters within strings can be escaped. ```css font: "Awasome 12"; ``` ```css text { content: "Line one\n\tIndented line two 'Quoted text'"; } ``` ```css text { content: 'Line one\n\tIndented line two "Quoted text"'; } ``` ```css text { content: "Line one\n\tIndented line two \"Quoted text\""; } ``` -------------------------------- ### Rofi Element Theme Sections Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Provides examples of defining styles for specific rofi elements using element paths, including combined selectors. ```css element normal.normal { background-color: blue; } button { background-color: blue; } ``` ```css element normal normal, button { background-color: blue; } ``` -------------------------------- ### ROFI Configuration: List Data Type (Rasi) Source: https://github.com/davatorium/rofi/blob/next/CONFIG.md Example of defining a list in the RASI configuration format. Entries are comma-separated and enclosed in square brackets. ```css combi-modes: [window,drun]; ``` -------------------------------- ### Rofi CSS Media Query Basic Source: https://github.com/davatorium/rofi/blob/next/doc/rofi-theme.5.markdown Example of a basic CSS @media query in Rofi, used for conditional theme loading based on screen dimensions. ```css @media ( min-width: 120 ) { } ``` -------------------------------- ### Create Empty ROFI Configuration Source: https://github.com/davatorium/rofi/blob/next/CONFIG.md Use this to create a new, empty configuration file. Options can then be added within the `configuration` block. ```css configuration { } ``` -------------------------------- ### ROFI Configuration: List Data Type (Older Format) Source: https://github.com/davatorium/rofi/blob/next/CONFIG.md Example of defining a list in the older ROFI configuration format, where the list is represented as a comma-separated string. ```css combi-modes: "window,drun"; ``` -------------------------------- ### Configure Recursive File Browser Settings Source: https://github.com/davatorium/rofi/blob/next/doc/rofi.1.markdown Set options for the recursive file browser, including starting directory, cancel return value, and filter regex. ```css configuration { recursivebrowser { /** Directory the file browser starts in. */ directory: "/some/directory"; /** return 1 on cancel. */ cancel-returns-1: true; /** filter entries using regex */ filter-regex: "(.*cache.*|.*\.o)"; /** command */ command: "xdg-open"; } } ``` -------------------------------- ### Dump rofi configuration with icon theme Source: https://github.com/davatorium/rofi/blob/next/doc/rofi.1.markdown Generate a template configuration file for rofi, specifically setting the 'hicolor' icon theme. This is useful for ensuring icon consistency. ```bash rofi -icon-theme hicolor -dump-config ```