swaycons

Window Icons in Sway with Nerd Fonts!

Go from before to after

Installation

Prerequisites

  1. Install Rust
  2. Sway
  3. A font with icons and pango enabled in your sway config. The default config assumes a nerd font is used. The config should look something like this:

font pango:FuraCode Nerd Font 11

Install Swaycons

  1. cargo install swaycons

Usage

Config

```toml

global section. all windows will default to these settings

[global] color = "#FFFFFF" # this must be a valid color focusedcolor = "#FFFFFF" # to disable a focusedcolor set this to "" icon = "类" # to disable a default icon just set this to "" size = "14pt" # must be a valid pango size value

appid section. This does an exact string comparison to the appid or

windowproperties.class value reported in swaymsg -t gettree for the window

It will be appid for wayland apps and windowproperties.class for X11 apps

[app_id] chromium = { icon = "", color = "#a1c2fa", size = "13pt" } firefox = { icon = "", color = "#ff8817" } foot = { icon = "" } neovide = { icon = "", color = "#8fff6d" }

This does a regex match on the window title. Matches from this section

will take precedence over matches from the app_id section. A very basic

algorithm is used to select the more exact regex if there are multiple

matches. If 1 regex contains another it will choose the longer one. For

instance mail\.google\.com and google\.com/maps will be chosen over

google\.com

[title]

escape . for an exact match. Normally . matches any character

"crates\.io" = { icon = "", color = "#ffc933" } "github\.com" = { icon = "" } "google\.com" = { icon = "", color = "#4285f4" } "google\.com/maps" = { icon = "﫴", color = "#4caf50" } "mail\.google\.com" = { icon = "", color = "#ad1f1c" }

use | for or

"sr\.ht|sourcehut\.org" = { icon = "" }

can do an or around just a substring with (a|b)

"travis-ci\.(com|org)" = { icon = "", color = "#cd324a" }

The app_id setting means that this will only match if both the title matches

the regex and the appid or windowproperties.class equals one of the values

provided in the app_id array

For example this allows a vim logo in the terminal but keeps a github logo

when viewing a github page with vim in the repository name

vim = { app_id = ["foot", "Alacritty"], icon = "", color = "#8fff6d" } ```

Using Sway Tabs for Firefox

This plugin is extremely useful when using sway tabs instead of browser tabs. To get this working properly with Firefox a few steps and plugins are necessary:

  1. Open Firefox Settings and Disable Open links in tabs instead of new windows
  2. Install Tab-less from Firefox Add-ons
  3. Install Add URL To Window Title from Firefox Add-ons
  4. Hide the tab bar - directions are in the sidebery github wiki here: https://github.com/mbnuqw/sidebery/wiki/Firefox-Styles-Snippets-(via-userChrome.css)#firefox-styles-snippets-via-userchromecss