Code Monkey home page Code Monkey logo

snap's Introduction

snap

Window Snapping Utility for Openbox

I could not find a Window snapping utility for Openbox that I was happy with, so I wrote my own.

Installation

  • Place snap in your path.
  • Add Keybindings to Openbox via your Openbox rc.xml.
<!-- Keybindings for snap: Example using Super+Arrow -->
<keybind key="W-Left">
    <action name="Execute">
        <command>snap -sl</command>
    </action>
</keybind>
<keybind key="W-Right">
    <action name="Execute">
        <command>snap -sr</command>
    </action>
</keybind>
<keybind key="W-Up">
    <action name="Execute">
        <command>snap -su</command>
    </action>
</keybind>
<keybind key="W-Down">
    <action name="Execute">                                                                   
        <command>snap -sd</command>
    </action>
</keybind>
<keybind key="W-C-Left">
    <action name="Execute">
        <command>snap -ml</command>
    </action>
</keybind>
<keybind key="W-C-Right">
    <action name="Execute">
        <command>snap -mr</command>
    </action>
</keybind>

How it works

Usage: snap [-s <l|r|u|d>] [-m <l|r>]
 -s     snap direction
        supports left, right, up, and down
 -m     move direction
        supports left and rught

Think of each monitor as a 3x3 grid, with a special case of maximized...

               ________________
               |              |
               |   maximized  |
               |     0,2      |
_______________|______________|_______________
|              |              |              |
|   top-left   |   full top   |   top-right  |
|     -1,1     |     0,1      |     1,1      |
|______________|______________|______________|
|              |              |              |
|  full left   |   original   |  full right  |
|     -1,0     |     0,0      |     1,0      |
|______________|______________|______________|
|              |              |              |
|  bottom-left | full bottom  | bottom right |
|    -1,-1     |     0,-1     |     1,-1     |
|______________|______________|______________|
  • Each window, regardless of its starting position, is initially in its original, unsnapped position at (0,0).
  • Moving a window using snap -s <direction> will snap the window to the appropriate grid position, with each of the 4 full grid positions taking up the entire half of the screen.
  • After being snapped to a full position, a window can be snapped further to a corner position.
  • To return a window to its original position, simply snap it back to the original (0,0) grid location.
  • Additionally, manually moving a window from its snapped position (dragging, for example) will remove its stored snapped state.
  • You can move a window from one monitor to another using snap -m <direction>. Doing so will mvoe the original position to that monitor.

Limitations

For multi-monitor setups, the following assumptions are made:

  • Only 2 monitors are present.
  • Monitors are arranged horizontally.
  • Monitors all have the same resolution.
  • Panels are present on every monitor, in the same location, and of the same size.

Future Improvements

  • Support more than 2 monitors.
  • Support monitors of differring sizes.
  • Support monitors of differring resolutions.
  • Support for varying panel sizes and locations.
  • Automated installer.
  • Ability to resize/snap to thirds, rather than halfs.

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.