In i3wm, or sway, replace current window with emacs buffer, browser tab or other window
Project description
i3-sway-switch-window
In i3wm, or sway, replace currently focused window with emacs buffer, file from emacs recentf, browser window showing URL from a browser tab, or another window. Can also place selected buffer window, recentf window, browser tab, or another window, adjacent to currently focused window. Emacs buffer and file from emacs recentf are displayed with emacsclient. Currently only tested under Ubuntu 23.04.
Installation
pipx install -U i3-sway-switch-window
It is necessary to install with 'pipx' rather than 'pip', as a number of command line entry points are included in the package.
Then you can run
browser_tab -h
emacs_buffers -h
emacs_recentf -h
wm_window_switch -h
To uninstall the package run:
pipx uninstall i3-sway-switch-window
Install requirements:
To use commands emacs_buffers and emacs_recentf, emacs must be running in server (daemon) mode. emacsclient must be available.
To use browser_tab, brotab must be installed. See https://github.com/balta2ar/brotab for how to install the command line application. You must also have the brotab browser extensiom installed in your browser, and enabled.
Note that the brotab command line application 'bt', is currently unable to communicate with browsers installed via flatpak and snap. On Ubuntu I have had success with the vivaldi browser. It is still possible to open the URLs with for example chrome. Note 2023-06-22: bt now works also with chrome on Ubuntu.
The i3-sway-switch-window applications expect to find a configuration file in "i3_sway_switch_window/config.ini" in your config directory. The file can be empty.
A sample config.ini is:
[roficommand]
# Default is "rofi -dmenu"
roficommand = /usr/local/bin/rofi -dmenu
[webbrowser]
# Default is "vivaldi"
webbrowser = google-chrome
[workspace]
# i3, or sway, workspace to which focused window will be swapped
# Default is "2"
swap_workspace = 9
How to use
The commands can be run from the command line. They can also be part of the i3, or sway, configuration. Here are some sample lines from my i3 configuration file:
# get wm window names, select one, display at current desktop window
bindsym $mod+w exec ~/.local/bin/wm_window_switch swap
# get wm window names, select one, display next to current desktop window
bindsym $mod+Shift+w exec ~/.local/bin/wm_window_switch add
# get web browser tab titles and URLs, select one, display at current desktop window
bindsym $mod+u exec ~/.local/bin/browser_tab swap
# get web browser tab titles and URLs, select one, display next to current desktop window
bindsym $mod+Shift+u exec ~/.local/bin/browser_tab add
# get current buffers from emacs, select one, display at current desktop window
bindsym $mod+b exec ~/.local/bin/emacs_buffers swap
# get current buffers from emacs, select one, display next to current desktop window
bindsym $mod+Shift+b exec ~/.local/bin/emacs_buffers add
# get recentf list from emacs, select one, display at current desktop window
bindsym $mod+r exec ~/.local/bin/emacs_recentf swap
# get recentf list from emacs, select one, display next to current desktop window
bindsym $mod+Shift+r exec ~/.local/bin/emacs_recentf add
Note for sway: An alternative to wm_window_switch is to use swayr command 'swap-focused-with', see https://sr.ht/~tsdh/swayr
Developer info
To build the package:
- Download the repo. E.g. git clone https://github.com/johanwiden/i3-sway-switch-window.git
- Create a virtual environment, for development. E.g. with conda
- conda create --name i3env
- conda activate i3env
- conda install -c anaconda pip
- pip install i3ipc This is a package dependency
- pip install build This is the tool to build the package.
- Change directory to the downloaded repo
- python3 -m build This should build the package, the result is stored in subdirectory 'dist'
Running the applications
One can execute the entry points directly in the development environment, from the repo directory, without installing the package:
- python3 -c "import i3_sway_switch_window.main; import sys; sys.argv = [sys.argv[0]] + ['swap']; i3_sway_switch_window.main.cli_browser_tab()"
- python3 -c "import i3_sway_switch_window.main; import sys; sys.argv = [sys.argv[0]] + ['--browser','google-chrome','add']; i3_sway_switch_window.main.cli_browser_tab()"
- python3 -c "import i3_sway_switch_window.main; import sys; sys.argv = [sys.argv[0]] + ['--config','foo']; i3_sway_switch_window.main.cli_browser_tab()"
- python3 -c "import i3_sway_switch_window.main; import sys; sys.argv = [sys.argv[0]] + ['--version']; i3_sway_switch_window.main.cli_browser_tab()"
To test installation of the package:
- From outside the virtual environment, or in a different virtual environment:
- Install pipx, if it is not already installed.
- pipx ensurepath Ensure directories necessary for pipx operation are in your PATH environment variable.
- pipx install --force PATH-TO-REPO/dist/i3_sway_switch_window-0.1.0.tar.gz
- One should now be able to execute the apps. They are usually stored in ~/.local/bin.
📈 Releases
You can see the list of available releases on the GitHub Releases page.
We follow Semantic Versions specification.
We use Release Drafter
. As pull requests are merged, a draft release is kept up-to-date listing the changes, ready to publish when you’re ready. With the categories option, you can categorize pull requests in release notes using labels.
List of labels and corresponding titles
Label | Title in Releases |
---|---|
enhancement , feature |
🚀 Features |
bug , refactoring , bugfix , fix |
🔧 Fixes & Refactoring |
build , ci , testing |
📦 Build System & CI/CD |
breaking |
💥 Breaking Changes |
documentation |
📝 Documentation |
dependencies |
⬆️ Dependencies updates |
You can update it in release-drafter.yml
.
GitHub creates the bug
, enhancement
, and documentation
labels for you. Dependabot creates the dependencies
label. Create the remaining labels on the Issues tab of your GitHub repository, when you need them.
🛡 License
This project is licensed under the terms of the MIT
license. See LICENSE for more details.
📃 Citation
@misc{i3-sway-switch-window,
author = {Johan Widén},
title = {In i3wm replace current window with emacs buffer, emacs recentf file, or browser tab},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/johanwiden/i3-sway-switch-window}}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for i3_sway_switch_window-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c841ed18573e13431600d732fd7604b9755991ae0ea41b3ec41ac73543708550 |
|
MD5 | 76dfe178d164bd56bf7ed9fe62f59b51 |
|
BLAKE2b-256 | 7c4834d4442ca170cd57bf1a3063ed50c5b2a023ee15e63f4da5f89c292ab137 |
Hashes for i3_sway_switch_window-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d55510b3557affbdb68c5175ca9b29c8655af7b690122d2ad1271dd70769ab0e |
|
MD5 | 752a1f39aebb53aaac57f58758fba954 |
|
BLAKE2b-256 | 1f2dbbe19f6e2ee1f5977a5632c45b51d1b9c1661db261bca27627f7e4eb95c1 |