kuokuo123/otter-launcher
Über uns
Ein anpassbarer CLI/TUI-Launcher für Nutzer von Fenstermanagern, die vorwiegend die Tastatur verwenden. Mit vi- und emacs-Tastenbelegungen, ANSI-Dekorationen und mehr.
Weitere ProjekteWhat you can do
- Modularized to run different commands.
- Vi and emacs keybinds.
- Two suggestion modes: list & hint.
- Tab completion; tab again to undo completion.
Gemessener Sternzuwachs
- in 24h
- 0
- in 7 days
- +3
- in 15 days
- +1
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
Original
minimalist, blazingly fast, keyboard-centric
Since v0.8.0, otter-launcher has been rebased to ratatui, which is a breaking change. Read the release note to know how to migrate the old config files.
Overview
A hackable app launcher designed for keyboard-centric wm users. It is blazingly fast, supports vi and emacs keybinds, and can be decorated with ansi color codes, sixel or kitty image protocols.
The core concept is making these behaviours possible with a TUI:
- type "gg margaret thatcher" to google the lady in a web browser
- "sh htop" to run htop in a terminal
- "dc linux" to search the word linux with an online dictionary
- "app" to launch application menu
- etc.
There's also a CLI usage. Running "ot gg maragaret thatcher" will google the lady without entering the TUI. With one otter config, you get a CLI toolbox across different machines.
It's recommended to setup a dedicated desktop app launcher as a module, like fsel or sway-launcher-desktop. Some helper scripts can be found in the contrib folder, modules in wiki.

Table of Contents
Features
- Modularized to run different commands.
- Vi and emacs keybinds.
- Two suggestion modes: list & hint.
- Tab completion; tab again to undo completion.
- Edit prompt in an external editor (vim, emacs, etc.).
- Url encoding for web searching.
- Show image through sixel or kitty graphics, or chafa symbols.
- Cheat sheet.
- Customizable shell by which programs are launched (sh -c, zsh -c, etc).
- Cli mode to launch modules without Tui.
Demo
Workflow

External editor, list selection, and cheatsheet

Installation
With the AUR
paru -S otter-launcher
Building from source
git clone https://github.com/kuokuo123/otter-launcher /tmp/otter-launcher
cd /tmp/otter-launcher
cargo build --release
mkdir -p $HOME/.config/otter-launcher
cp /tmp/otter-launcher/config_example/config.toml $HOME/.config/otter-launcher/config.toml
sudo cp /tmp/otter-launcher/target/release/otter-launcher /usr/bin/
Configuration
Otter reads from $HOME/.config/otter-launcher/config.toml. If missing, it looks into /etc/otter-launcher/config.toml. Use the '--config' or '-c' flag to specify your preferred path otherwise.
The default config comes only with a minimal setup. Check more examples for module setup, styling for image integration.

All the available options are listed here.
[general]
height = 7 # the total lines that otter-launcher should occupy; 0 to be fullscreen
empty_module = "app" # module to run with an empty prompt
default_module = "gg" # module to run when no module is matched
alternative_module = "" # module to run with alt+enter
control_module = "" # module to run with ctrl+enter
exec_cmd = "sh -c" # your chosen shell, eg. "zsh -c" for zsh
vi_mode = false # true for vi keybinds, false emacs keybinds
cheatsheet_entry = "?" # the key to show configured modules
cheatsheet_viewer = "less -R; clear" # command to show cheatsheet; through piping stdout
external_editor = "vi" # ctrl+x ctrl+e (or v in vi normal mode)
[interface]
# options for the layout
padding = [0, 1, 0, 1] # pad with columns/lines, [top, right, down, left]
# use three quotes to write longer codes; ANSI color codes and shell expansion are allowed
header = """
$(
load=$(awk 'NR == 1 {print $1"%"}' /proc/loadavg)
mem=$(free -h | awk 'NR == 2 {print $3}' | sed 's/Gi/0G/')
left="$USER@$HOSTNAME"
left="> $left"
right="> $load% > $mem"
gap=$(( COLUMNS - ${#left} - ${#right} ))
(( gap < 0 )) && gap=0
printf '\x1b[34;1m> \x1b[0m%s@%s%*s\x1b[31;1m> \x1b[0m%s \x1b[33;1m> \x1b[0m%s' "$USER" "$HOSTNAME" "$gap" '' "$load" "$mem")"""
# available colors: https://docs.rs/ratatui/latest/ratatui/prelude/enum.Color.html
header_color = "blue"
# options for input field
prompt_sign = "> "
prompt_sign_color = "blue"
placeholder = "type & search"
placeholder_color = "black"
# options for selectable suggestions
suggestion_mode = "list" # available options: list, hint
suggestion_position = "bottom" # to the input field; options: top, bottom
prefix_color = "yellow"
prefix_padding = 3 # pad with spaces to have uniformed width
description_color = "reset"
selection_prefix = "▌ " # shown for the selected
selection_prefix_color = "red"
inverse_selection = true # highlight the selected
list_prefix = " " # shown for the not selected
list_prefix_color = "reset"
indicator_args = "" # shown for modules taking arguments
indicator_bare = "" # for those not taking arguments
indicator_color = "red"
scrollbar = true
# options for separator
separator = true # draw a line between intput field and suggestion list; only affect list mode
separator_label = " otter "
separator_color = "darkgray"
[image]
format = "symbol" # graphics protocols to use; options: kitty, sixel, iterm2, symbol
path = "" # path to the image file
width = 12 # the size of image; count columns for horizontal layout, lines for vertical layout
position = "left" # image placement; options: left, right, top, bottom
padding = [0, 0, 0, 0] # [top, right, down, left]
# modules are defined as followed
[[modules]]
description = "google search"
prefix = "gg"
cmd = "xdg-open https://www.google.com/search?q='{}'"
# if with_argument is true, {} in cmd will be replaced with user input. if not explicitly set, taken as false.
with_argument = true
# url_encode should be true when calling webpages; this ensures special characters in url being readable to browsers; taken as false if not explicitly set
url_encode = true
# run cmd in a forked shell as opposed to as a child process (simply by prepending setsid -f to the configured cmd); useful for launching gui programs; taken as false if not explicitly set
unbind_proc = true
# fzf is needed to run below functions
[[modules]]
description = "desktop programs"
prefix = "app"
cmd = """
desktop_file() {
find /usr/share/applications -name "*.desktop" 2>/dev/null
find /usr/local/share/applications -name "*.desktop" 2>/dev/null
find "$HOME/.local/share/applications" -name "*.desktop" 2>/dev/null
find /var/lib/flatpak/exports/share/applications -name "*.desktop" 2>/dev/null
find "$HOME/.local/share/flatpak/exports/share/applications" -name "*.desktop" 2>/dev/null
}
selected="$(desktop_file | awk -F/ '{name=$NF; sub(/\\.desktop$/, "", name); print name}' | sort -k1,1 | cut -f2- | fzf --cycle --gutter ' ' --color 'pointer:1,info:8,separator:8,scrollbar:0' -m -d / --with-nth -1 )"
[ -z "$selected" ] && exit
echo "$selected" | while read -r line ; do setsid -f gtk-launch "$(basename $line)"; done
"""
[[modules]]
description = "power menu"
prefix = "po"
cmd = """
function power {
if [[ -n $1 ]]; then
case $1 in
"logout") session=`loginctl session-status | head -n 1 | awk '{print $1}'`; loginctl terminate-session $session ;;
"suspend") systemctl suspend ;;
"hibernate") systemctl hibernate ;;
"reboot") systemctl reboot ;;
"shutdown") systemctl poweroff ;;
esac fi }
power $(echo -e 'reboot\nshutdown\nlogout\nsuspend\nhibernate' | fzf --cycle --gutter ' ' --color 'pointer:1,info:8,separator:8,scrollbar:0' | tail -1)
"""
[[modules]]
description = "run commands"
prefix = "sh"
cmd = """
$(printf $TERM | sed 's/xterm-//g') -e sh -c "{}"
"""
with_argument = true
unbind_proc = true
[[modules]]
description = "search archwiki"
prefix = "aw"
cmd = "xdg-open https://wiki.archlinux.org/index.php?search='{}'"
with_argument = true
url_encode = true
unbind_proc = true
[[modules]]
description = "search packages"
prefix = "pac"
cmd = "xdg-open https://archlinux.org/packages/?q='{}'"
with_argument = true
url_encode = true
unbind_proc = true
[[modules]]
description = "search the AUR"
prefix = "aur"
cmd = "xdg-open https://aur.archlinux.org/packages?K='{}'"
with_argument = true
url_encode = true
unbind_proc = true
[[modules]]
description = "cambridge dict"
prefix = "dc"
cmd = "xdg-open 'https://dictionary.cambridge.org/dictionary/english/{}'"
with_argument = true
url_encode = true
unbind_proc = true
[[modules]]
description = "open files (fzf)"
prefix = "fo"
cmd = """
find $HOME -type f -not -path '*/.cache/*' 2>/dev/null | fzf --cycle --gutter ' ' --color 'pointer:1,info:8,separator:8,scrollbar:0' | setsid -f xargs -r -I [] xdg-open '[]'
"""
[[modules]]
description = "open dirs (yazi)"
prefix = "yz"
cmd = """
find $HOME -type d -not -path '*/.cache/*' 2>/dev/null | fzf --cycle --gutter ' ' --color 'pointer:1,info:8,separator:8,scrollbar:0' | xargs -r -I [] setsid -f "$(echo $TERM | sed 's/xterm-//g')" -e yazi '[]'
"""
Integration
Otter works well with TUI programs and bash pipelines. Some tricktips:
Use your WM's window rules to control window size.
modules.cmd can be scripted to adjust window sizes. For example:
[[modules]]
description = "pulsemixer for audio control"
prefix = "vol"
cmd = "swaymsg [app_id=otter-launcher] resize set width 600 px height 300 px; pulsemixer; swaymsg [app_id=otter-launcher] resize set width 600 px height 60 px"
Some tui utilities that works really well:
- Desktop app launcher: sway-launcher-desktop fsel
- Audio control: pulsemixer wiremix
- Bluetooth control: bluetui bluetuith
- Wifi control: nmtui impala
- Spotify: spotify_player
- Mouse control: wl-kbptr
- More on Awesome TUIs or Awesome Command Line(CLI/TUI) Programs.
To change external editor's window size , call a wrapper script at general.external_editor. Examples are in contrib.
Styling
Banner
[general]
height = 14
[interface]
# Bash scripting widgets in $()
header = """
$(
load=$(awk 'NR == 1 {print $1}' /proc/loadavg)
mem=$(free -h | awk 'NR == 2 {print $3}' | sed 's/Gi/0/')
left="$USER@$HOSTNAME"
left=" > $left"
right="> $load > $mem"
gap=$(( COLUMNS - ${#left} - ${#right} ))
(( gap < 0 )) && gap=0
printf '\x1b[34;1m \x1b[0m%s@%s%*s\x1b[31;1m \x1b[0m%s \x1b[33;1m \x1b[0m%s' "$USER" "$HOSTNAME" "$gap" '' "$load" "$mem")"""
prompt_sign = " "
padding = [0, 1, 0, 1]
separator_label = " otter "
list_prefix = " "
selection_prefix = " ▌ "
inverse_selection = false
suggestion_position = "bottom"
indicator_bare = "$ "
indicator_args = "^ "
prefix_padding = 4
[image]
format = "kitty"
path = "$HOME/.config/otter-launcher/images/images_other/waterways_and_otterways.jpg"
width = 6
position = "top"
Two-liner

[general]
height = 2
[interface]
header = """
$(
load=$(awk 'NR == 1 {print $1}' /proc/loadavg)
mem=$(free -h | awk 'NR == 2 {print $3}' | sed 's/Gi/0 /')
left="$USER@$HOSTNAME"
left=" > $left"
right="> $load > $mem"
gap=$(( COLUMNS - ${#left} - ${#right} ))
(( gap < 0 )) && gap=0
printf '\x1b[34;1m \x1b[0m%s@%s%*s\x1b[31;1m \x1b[0m%s \x1b[33;1m \x1b[0m%s' "$USER" "$HOSTNAME" "$gap" '' "$load" "$mem")"""
prompt_sign = " "
suggestion_mode = "hint"
Fastfetch

Images should be rendered by otter-launcher as ratatui does not allow graphics passed through. Also, "--pipe false" should be attached to fastfetch to prevent colors being stripped.
[general]
height = 9
[interface]
# Strip fastfetch of the image and use the --pipe flag
header = "$( fastfetch --structure colors:title:os:shell:uptime --pipe false --logo none)"
prompt_sign = "\x1b[0m: "
prompt_sign_color = "cyan"
padding = [1, 2, 1, 0]
suggestion_mode = "hint"
suggestion_position = "top"
indicator_bare = "$ "
indicator_args = "^ "
# Let otter handles the image
[image]
format = "kitty"
path = "$HOME/.config/otter-launcher/images/images_squ/archlinux_chan.jpg"
width = 20
padding = [1, 1, 1, 2]
Fzf-like

[general]
height = 7
[interface]
padding = [1, 1, 1, 1]
separator_label = " otter "
list_prefix = " "
selection_prefix = "▌ "
inverse_selection = true
[image]
format = "kitty"
path = "$HOME/.config/otter-launcher/images_rec.image"
width = 12
One-liner

[general]
height = 1
[interface]
prompt_sign = " > "
suggestion_mode = "hint"
placeholder = ""
Image to the Right

[general]
height = 10
[interface]
padding = [1, 2, 1, 2]
header = """
┌ \u001B[1;34m $USER@$(echo $HOSTNAME) \u001B[0m───┐
│ \u001B[90m \u001B[31m \u001B[32m \u001B[33m \u001B[34m \u001B[35m \u001B[36m\u001B[0m │
└ \u001B[36m \u001B[1;36m system\u001B[0m archlinux ┘
┌ \u001B[33m \u001B[1;36m window \u001B[0m $XDG_CURRENT_DESKTOP ┐
│ \u001B[31m \u001B[1;36m loads\u001B[0m $(cat /proc/loadavg | cut -d ' ' -f 1) │
│ \u001B[32m \u001B[1;36m memory\u001B[0m $(free -h | awk 'FNR == 2 {print $3}') │"""
prompt_sign = " └ \u001B[90m \u001B[0m "
prompt_sign_color = "reset"
suggestion_mode = "list"
suggestion_position = "bottom"
inverse_selection = false
separator = false
prefix_padding = 3
list_prefix = " "
selection_prefix = " "
scrollbar = false
[image]
padding = [1, 2, 0, 0]
format = "kitty"
path = "$HOME/.config/otter-launcher/images/images_rec/prinny.png"
width = 19
position = "right"
Otter Shocked

[general]
height = 10
[interface]
header = """
\x1b[90m░█▀█░▀█▀░▀█▀░█▀▀░█▀█░░░░░ ░ ░
░█░█░░█░░░█░░█▀▀░█▀▄░▀▀▀░ ░ ░
░▀▀▀░░▀░░░▀░░▀▀▀░▀░▀░░░░░ ░ ░
░█░░░█▀█░█░█░█▀█░█▀▀░█░█░ ░ ░
░█░░░█▀█░█░█░█░█░█░░░█▀█░ ░ ░
░▀▀▀░▀░▀░▀▀▀░▀░▀░▀▀▀░▀░▀░ ░ ░
\x1b[31;1m \x1b[0m$USER@$HOSTNAME \x1b[31;1m \x1b[0m$(free -h | awk 'NR == 2 {print $3}' | sed 's/i//')
"""
prompt_sign = " "
prompt_sign_color = "yellow"
padding = [1, 2, 1, 0]
suggestion_mode = "hint"
suggestion_position = "top"
prefix_padding = 3
[image]
format = "kitty"
path = "$HOME/.config/otter-launcher/images/images_squ/otter_shocked.webp"
width = 22
padding = [1, 1, 1, 2]
Sponsorship
If you find the project helpful, you can buy me a coffee through paypal.
Ähnliche Projekte entdecken
Wird geladen…
