應用啓動器yofi使用配置

應用程序啓動器(application launcher), 通常是用來快速定位和啓動計算機中的其它程序的。例如 Linux 中的 Albert Launcher、Synapse,macOS 中的 Alfred 等。Gnome 環境按 Super 快捷鍵後也是差不多的功能。

啓動器一般有模糊搜索功能,本文介紹的是 yofi,一個用 rust 編寫的適用於 wanyland 環境的輕量啓動器,rust 編寫好感度增加,作者還在積極維護,目前看起來使用的人不多,寫這個文章的時候,Google 搜索不出中文相關資料,不小心填補了中文世界的空白,做了一點點微小工作,功德+1。

1. 下載編譯安裝

  • 下載源碼
1 git clone https://github.com/l4l/yofi
  • 編譯安裝

rust 的應用,cargo 編譯,省心省力,坐等生成可執行文件即可。生成的二進制在target/release/目錄下,

1➜  cargo run --release
2➜  yofi git:(master) ls
3  Cargo.lock  Cargo.toml  CHANGELOG.md  flake.lock  flake.nix  LICENSE  README.md  rust-toolchain  src  target
4➜  yofi git:(master) ls -al target/release/yofi
5  -rwxrwxr-x 2 mephisto mephisto 11454816 Mar 17 14:54 target/release/yofi
6➜  yofi git:(master) file target/release/yofi
7  target/release/yofi: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=83e34f2d6952622f6767b088083ed045c53ca4df, for GNU/Linux 3.2.0, with debug_info, not stripped
  • 做個軟鏈接

方便後續升級

1sudo ln -s /home/mephisto/github/yofi/target/release/yofi /usr/bin/yofi
  • 綁定個快捷鍵

如果你是 Gnome 環境: Settings/Keyboard/Coustom Shortcuts 根據喜好設置快捷鍵。

圖示:

Gnome yofi settings

F8搜索啓動對應的程序,使用頻次高的會靠前展示。

Gnome yofi

如果你是 Sway 環境:

1➜  ~ grep yofi  ~/.config/sway/config
2    # yofi lancher
3    bindsym F8 exec yofi apps

意思是綁定F8快捷鍵,執行 yofi apps 命令

圖示:

sway yofi

我主要用 Gnome 和 sway 兩個環境,其它不做介紹。

可能有讀者會有疑問,既然 Gnome 的Super鍵有類似效果,爲什麼還要費勁。先生此言差矣,不是人人都用 Gnome,比如用 sway 環境的時候,Gnome 不好定製,這個想怎麼改就怎麼改,還有黑名單等功能,詳情參考yofi wiki

2. 個性化配置

主要定製 yofi 呼出後的樣式,例如窗口大小、字體、圓角、顏色相關。

記得找個好看的圖標集,絕對值得,顏值也很關鍵,我選的Papirus,理由是好看,圖標多且全。

個人配置僅供參考:

  1➜  ~ cat ~/.config/yofi/yofi.config
  2# Width/height of the app in pixels
  3width = 800
  4height = 512
  5
  6# If set forces usage of basic window instead of Layer Shell wayland protocol
  7force_window = false
  8
  9# if unset, renders window centered
 10# window_offsets = [500, -50] # in format [top_offset_pixels, left_offset_pixels]
 11
 12# Similar to CSS border-radius for main window, for more details see corner_radius
 13# for [input_text]
 14corner_radius = "0"
 15
 16# font = "DejaVu Sans"
 17font = "Source Sans Pro"
 18# or you may use an absolute path, e.g:
 19# font = "/usr/share/fonts/TTF/DejaVuSans.ttf"
 20font_size = 24
 21
 22# Color of the app background
 23# Colors are specified in 0xRRGGBBAA format
 24bg_color = 0x272822ee
 25# Border around background
 26#bg_border_color = 0x131411ff
 27bg_border_color = 0xa6e22eff
 28# bg_border_width = 2.0
 29
 30# Color for the fonts
 31# font_color = 0xf8f8f2ff
 32
 33# HiDPI scaling factor; default is requested from compositor but
 34# fractional values are truncated, so one may want to set it explicitly.
 35# scale = 3
 36
 37# Terminal emulator to use for apps that require terminal.
 38# Certain apps like vim might not launch unless specified.
 39#term = "alacritty -e"
 40
 41# TOML sections are scope config values for a related blocks.
 42# This one for instance is for input field area.
 43[input_text]
 44# font = ...
 45font_color = 0xf8f8f2ff
 46bg_color = 0x75715eff
 47
 48# Margin/padding values are specified as in CSS but only in pixels.
 49# So it's either a single value for all directions
 50# or two values: the first for top/bottom and the second for left/right
 51# or finally four values: for top, right, bottom and left directions respectively.
 52margin = "5" # equivalent to "5 5 5 5"
 53padding = "1.7 -4" # equivalent to "1.7 -4 1.7 -4"
 54
 55# Corner radius is the arc radius for the surrounding input box.
 56# Similar to border-radius in CSS but only in pixels.
 57# So it's either a single value for all corners
 58# or two values: the first for top-left/bottom-right and the second for top-right/bottom-left
 59# or finally four values: for top-left, top-right, bottom-right and bottom-left respectively.
 60# By default the radius is a maximal possible value.
 61# corner_radius = "1 2 3 4"
 62
 63# Section for items in the search results area.
 64[list_items]
 65# font = ...
 66font_color = 0xf8f8f2ff
 67
 68# Font color for an item that currently selected
 69selected_font_color = 0xa6e22eff
 70
 71# if specified, search matches are emphasized with this color
 72match_color = 0xe69f66ff
 73
 74margin = "5 10"
 75
 76# If set to true hides the desktop actions
 77hide_actions = false
 78# Specify left margin for action line
 79action_left_margin = 60
 80
 81# Additional spacing between list items.
 82# By default there's a space around 10 pixels
 83# the value can be reduced by specifying a negative value
 84item_spacing = 2
 85
 86# Spacing between an icon and a text.
 87icon_spacing = 5
 88
 89# Sections for the icons. When this section presents, icons are displayed
 90[icon]
 91# For now app only supports fixed sized icons and there's no icon up/down-scaling yet.
 92# More info: https://github.com/l4l/yofi/issues/76#issuecomment-1023631399
 93size = 32
 94
 95# For the icon search path, by default "hicolor" is used which usually not what you want.
 96theme = "Papirus"
 97
 98# If no icon found for an entry, this one will be used instead
 99#fallback_icon_path = "/usr/share/icons/Adwaita/16x16/categories/applications-engineering-symbolic.symbolic.png"
100fallback_icon_path = "/usr/share/icons/Papirus/32x32/apps/rust.svg"
最後修改於: Friday, February 23, 2024

相關文章:

翻譯: