Git Product home page Git Product logo

window-switch's Introduction

Window Switch

Window switch (wswitch) is a utility which enables you to bind a key to a particular application on Ubuntu. When the key is pressed, one of these three things will happen based on the current state.

  1. If the application is not running, wswitch will start the application.
  2. If the application is running but its window is not in focus, wswitch will bring it to focus.
  3. If the application is running and its window is in focus, wswitch will iconify (minimize) it.

How to use wswitch?

Install dependencies

As a first step, install the dependencies

sudo apt-get install wmctrl xwit

Add wswitch to path

The best way to do this is to make a soft link of wswitch in /usr/local/bin/

  1. Navigate to the directory containing wswitch on a terminal.
  2. Run the following:
    sudo ln -s $(pwd)/wswitch /usr/local/bin/wswitch

Identify WM_CLASS of your target application

Now let's configure wswitch for your favorite application. Let's assume that your target application is Terminator.

First you need to find the WM_CLASS of your target application. The following will help you do that.

  1. Start your target application.
  2. Fire up a terminal (If your target application is Terminator, you are in luck).
  3. Run the following: wmctrl -l -x | awk '{print $3}'. This will print a list of WM_CLASS of all the windows currently open on your desktop.
  4. Identify the WM_CLASS of your target application. For Terminator, this will be terminator.Terminator.

Bind a key

The next step is to bind a key to wswitch.

  1. Open the keyboard shortcuts settings. This is usually found in System Settings > Keyboard > Shortcuts.

  2. Add a new shortcut and give it a name (like Terminator).

  3. In the command section write the following:

    wswitch <WM_CLASS> <launch_command>

    Here WM_CLASS is what you found in the previous step. The launch_command is the command which can be used to launch a new instance of the application.

    For example, for Terminator, the following can be used:

    wswitch terminator.Terminator terminator

    You can also pass arguments in the launch_command. For example,

    wswitch terminator.Terminator "terminator --layout=my-custom-layout"
  4. Bind your favorite key to this shortcut.

  5. Hit the key and see the magic!

Suggestions?

Create an issue or code it up and send a pull request.

window-switch's People

Contributors

agamagarwal avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.