- Notifications
You must be signed in to change notification settings - Fork13
A dynamic workspace renamer for i3 and Sway that updates names to reflect their active applications.
License
roosta/i3wsr
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A dynamic workspace renamer for i3 and Sway that updates names to reflect theiractive applications.
i3wsr
can be configured through command-line flags or aTOML
config file,offering extensive customization of workspace names, icons, aliases, anddisplay options.
Now thati3wsr
works withSway as well asI3, the name is a bit misleading, and could do with achange. Shame to lose the metrics, but it might help further discovery now thatit supports multiple display servers.
I've not thought of anything yet, but will advertise it here in the READMEbefore publishing anything under a new name.
Development forward will focus on Sway, but backward compatibility with I3 willbe maintained.
i3wsr requiresi3 orsway, andnumberedworkspaces,seeConfiguration
Rust, andCargo isrequired, andi3wsr
can be installed using cargo like so:
cargo install i3wsr
Or alternatively, you can build a release binary,
cargo build --release
Then place the built binary, located attarget/release/i3wsr
, somewhere on your$path
.
If you're running Arch you can install eitherstable, orlatest from AUR thanks to reddit useru/OniTux.
Just launch the program and it'll listen for events if you are running I3 orSway. Another option is to put something like this in your i3 or Sway config:
# i3exec_always --no-startup-id i3wsr# Swayexec_always i3wsr
exec_always
ensures a new instance ofi3wsr
is started when config is reloaded or wm/compositor is restarted.
This program depends on numbered workspaces, since we're constantly changing theworkspace name. So your I3 or Sway configuration need to reflect this:
bindsym $mod+1 workspace number 1assign [class="(?i)firefox"] 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:
set $myws "1:[Q]" # my sticky partbindsym $mod+q workspace number $mywsassign [class="(?i)firefox"] number $myws
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 configfile allows for more nuanced settings, and is required to configure icons andaliases. By default i3wsr looks for the config file at$XDG_HOME/.config/i3wsr/config.toml
or$XDG_CONFIG_HOME/i3wsr/config.toml
.To specify another path, pass it to the--config
option on invocation:
i3wsr --config~/my_config.toml
Example config can be found inassets/example_config.toml.
Sometimes a class, instance or name can be overly verbose, use aliases thatmatch to window properties to create simpler names instead of showing the fullproperty
# For Sway[aliases.app_id]# for i3[aliases.class]# Exact match"^Google-chrome-unstable$" ="Chrome-dev"# Substring matchfirefox ="Firefox"# Escape if you want to match literal periods"Org\\.gnome\\.Nautilus" ="Nautilus"
Alias keys uses regex for matching, so it's possible to get creative:
# This will match gimp regardless of version number reported in class"Gimp-\\d\\.\\d\\d" ="Gimp"
Remember to quote anything but[a-zA-Z]
, and to escape your slashes. Due torust string escapes if you want a literal backslash use two slashes\\d
.
i3wsr supports 4 window properties currently:
[aliases.name]# 1 i3 / wayland / sway[aliases.instance]# 2 i3 / xwayland[aliases.class]# 3 i3 / xwayland[aliases.app_id]# 3 wayland / sway only
These are checked in descending order, so if i3wsr finds a name alias, it'lluse that and if not, then check instance, then finally use class
Only for Xwayland / i3
This is the default fori3
, and the most succinct.
Only for Wayland / Sway
This is the default for wayland apps, and the most and works largely like class.
Only for Xwayland / i3
Useinstance
instead ofclass
when assigning workspace names,instance is usually more specific. i3wsr will try to get the instance but if itisn't defined will fall back to class.
A use case for this option could be launchingchromium --app="https://web.whatsapp.com"
, and then assign a different icon to whatsappin your config file, while chrome retains its own alias:
[icons]"WhatsApp" ="🗩"[aliases.class]Google-chrome ="Chrome"[aliases.instance]"web\\.whatsapp\\.com" ="Whatsapp"
Sway and i3
Usesname
instead ofinstance
andclass|app_id
, this option is veryverbose and relies on regex matching of aliases to be of any use.
A use-case is running some terminal application, and as default i3wsr will onlydisplay class regardless of whats running in the terminal.
So you could do something like this:
[aliases.name]".*mutt$" ="Mutt"
Which property to display if no aliases is found:
[general]display_property ="instance"
Possible options areclass
,app_id
,instance
, andname
, and will defaulttoclass
orapp_id
depending on display server if not present.
You can alternatively supply cmd argument:
i3wsr --display-property name
You can config icons for your WM property, these are defined in your config file.
[icons]Firefox ="🌍"# Use quote when matching anything other than [a-zA-Z]"Org.gnome.Nautilus" ="📘"
i3wsr tries to match an icon with an alias first, if none are found it thenchecks yourdisplay_property
, and tries to match an icon with a non aliaseddisplay_property
, lastly it will try to match on class.
[aliases.class]"Gimp-\\d\\.\\d\\d" ="Gimp"[icons]Gimp ="📄"
A font that provides icons is of course recommended, likefont-awesome. Make sure your bar has that fontconfigured.
Normally i3wsr uses the pipe character|
between class names in a workspace,but a custom separator can be configured in the config file:
[general]separator =" "
To use a default icon when no other is defined use:
[general]default_icon ="💀"
Set a label for empty workspaces.
[general]empty_label ="🌕"
To display names only if icon is not available, you can use the--no-icon-names
flag, or enable it in your config file like so:
[options]no_icon_names =true
If you don't want i3wsr to display names at all, you can use the--no-names
flag, or enable it in your config file like so:
[options]no_names =true
If you want duplicates removed from workspaces use either the flag--remove-duplicates
, or configure it in theoptions
section of the configfile:
[options]remove_duplicates =true
By default i3wsr will keep everything until the firstspace
character is found,then replace the remainder with titles.
If you want to define a different character that is used to split thenumbered/constant part of the workspace and the dynamic content, you can usethe option--split-at [CHAR]
[general]split_at =":"
Here we define colon as the split character, which results in i3wsr onlykeeping the numbered part of a workspace name when renaming.
This can give a cleaner config, but I've kept the old behavior as default.
To run tests locallyVagrant is required. Runscript/run_tests.sh
to run tests on ubuntu xenial.
About
A dynamic workspace renamer for i3 and Sway that updates names to reflect their active applications.