i3wsr
is a small program that uses I3's IPC Interface
to change the name of a workspace based on its contents.
The chosen name for a workspace is a composite of the WM_CLASS
X11 window
property for each window in a workspace. In action it would look something like this:
Rust, and Cargo is
required, and i3wsr
can be installed using cargo like so:
sh
cargo install i3wsr
Or alternatively, you can build a release binary,
sh
cargo build --release
Then place the built binary, located at target/release/i3wsr
, somewhere on your $path
.
If you're running Arch you can install either stable, or latest from AUR thanks to reddit user u/OniTux.
Just launch the program and it'll listen for events if you are running I3. Another option is to put something like this in your i3 config
```
exec_always --no-startup-id $HOME/.cargo/bin/i3wsr
exec_always --no-startup-id /usr/bin/i3wsr ```
This program depends on numbered workspaces, since we're constantly changing the workspace name. So your I3 configuration need to reflect this:
bindsym $mod+1 workspace number 1
If you're like me and don't necessarily bind your workspaces to only numbers, or you want to keep a part of the name constant you can do like this:
bindsym $mod+q workspace number 1:[Q]
This way the workspace would look something like this when it gets changed:
1:[Q] Emacs|Firefox
You can take this a bit further by using a bar that trims the workspace number and be left with only
[Q] Emacs|Firefox
Configuration for i3wsr can be done using cmd flags, or a config file. A config
file allows for more nuanced settings, and is required to configure icons and
aliases. To use a config file pass to the --config
option on invocation:
bash
i3wsr --config ~/my_config.toml
Example config can be found in
assets/example_config.toml.
You can configure icons for the respective classes, a very basic preset for
font-awesome is configured, to enable it use the option --icons awesome
(requires font-awesome to be installed).
A more in depth icon configuration can be setup by using a configuration file. In there you can define icons for whatever class you'd like. ```toml [icons] Firefox = "🌍"
"Org.gnome.Nautilus" = "📘" ``` A font that provides icons is of course recommended, like font-awesome. Make sure your bar has that font configured.
Sometimes class names for windows can be overly verbose, so its possible to match a class name with an alias:
```toml [aliases] Google-chrome-unstable = "Chrome-dev"
"Org.gnome.Nautilus" = "Nautilus" ``` Now i3wsr will display the alias instead of the full class name.
Normally i3wsr uses the pipe character |
between class names in a workspace,
but a custom separator can be configured in the config file:
toml
[general]
separator = " "
To use a default icon when no other is defined use:
toml
[general]
default_icon = "💀"
If you have icons and don't want the names to be displayed, you can use the
--no-names
flag, or enable it in your config file like so:
toml
[options]
no_names = true
If you want duplicates removed from workspaces use either the flag
--remove-duplicates
, or configure it in the options
section of the config
file:
toml
[options]
remove_duplicates = true
Use WMINSTANCE instead of WMCLASS when assigning workspace names, instance is usually more specific. i3wsr will try to match icon with instance, and if that fail, will fall back to class.
To enable this, either pass the flag --use-instance
, or add it in your config
file under options
.
toml
[options]
use_instance = true
A use case for this option could be launching chromium
--app="https://web.whatsapp.com"
, and then assign a different icon to whatsapp
in your config file:
toml
[icons]
"web.whatsapp.com" = "💧"
Aliases will also match on instance:
toml
[aliases]
"web.whatsapp.com" = "WhatsApp"
Check Pedro Scaff's port swaywsr.
To run the tests Xvfb
needs to be installed and run:
shell
Xvfb :99.0
This sets up a headless x server running on DISPLAY :99.0, then some apps needs to be run in this new server:
shell
env DISPLAY=:99.0 gpick
env DISPLAY=:99.0 i3 -c /etc/i3/config
refer to .travis.yml for a CI example
This program would not be possible without i3ipc-rs, a rust library for controlling i3-wm through its IPC interface and rust-xcb, a set of rust bindings and wrappers for XCB.