focus_move_app is a script to enable an app focused workflow.
In the past I used a workspace based workflow where each app was 'bound' to a certain workspace. For example, nvim would reside on workspace 1, tmux on workspace 2 and the browser on workspace 3. I would then have shortcuts to switch to each app.
The problem with this arose when I wanted to have 2 apps side by side.
For example: Coding in nvim while seeing live output in tmux.
Moving nvim to the tmux workspace mixed up the workspace assignment. Using shortcuts to go to another app's workspace and back to nvim's workspace did not lead to the wanted result. Because nvim was no longer on its 'bound' workspace. I would first have to move nvim back to its 'bound' workspace to make the shortcut's work.
Instead of a shortcut to got to workspace xy, have a shortcut to go to an app no matter its location.
In comes focus_move_app. It has 3 actions.
-
focus
focus_move_app.sh nvim focus
- Focus an app if it is already running.
- If the app is not started it will start it on a new workspace.
-
move
focus_move_app.sh nvim move
- Move an app to the current workspace.
- Start it if it is not running yet.
-
only
focus_move_app.sh nvim only
- Make the currently focused app the only one on the workspace.
- This only works if app is already running.
Using sxhkd as hotkey daemon.
mod4 + o
focus_move_app.sh "" "only"
mod4 + {_, control + } {n,t,z,c,f}
mode={"focus","move"}; \
app={"nvim","tmux","zen-browser","chrome","firefox"}; \
focus_move_app.sh "$app" "$mode"
This would make mod4+n focus nvim. Mod4+ctrl+n move nvim to the current workspace. So you are working in tmux (mod4+t) and want to have nvim beside it, mod4+ctrl+n and nvim is moved to your current workspace. Want to continue working in tmux full-screen. Focus tmux and mod4+o will move nvim away again.
See focus_move_app.toml.
[prioritize]
apps = [ "nvim", "tmux" ]
position = "right"
[app.nvim]
class = "terminal.nvim"
cmd = "xterm -class ${app_class} -e nvim"
[app.tmux]
class = "terminal.tmux"
cmd = "xterm -class ${app_class} -e tmux"- prioritize
- When using the move action prioritized apps will be positioned in the given position and get focus.
- The apps list is checked in order, so that the first app in the apps list that is also on the current workspace is treated as the prioritized app.
- Use the app header without the app. part.