Git Product home page Git Product logo

snaplayout-for-xmonad's Introduction

SnapLayout for XMonad

Haskell CI

This is not an officially supported Google product

SnapLayout (SnapLayout.hs) is an XMonad LayoutClass that lets the user snap windows to particular edges or corners of the screen, at various fractions of screen width and/or height.

Usage:

You can use this module with the following in your ~/.xmonad/xmonad.hs:

import SnapLayout
import FocusOnTop

Then edit your layoutHook by adding the SnapLayout:

myLayout = focusOnTop snapLayout ||| Full ||| etc..
  where
    snapLayout :: SnapLayout a
    snapLayout = def
main = xmonad def { layoutHook = myLayout }

Or, to customize the fine adjustment increment:

myLayout = focusOnTop snapLayout ||| Full ||| etc..
  where
    snapLayout :: SnapLayout a
    snapLayout = def { adjustmentDelta = 3/100 }
main = xmonad def { layoutHook = myLayout }

For more detailed instructions on editing the layoutHook see:

https://hackage.haskell.org/package/xmonad-contrib-0.17.0/docs/XMonad-Doc-Extending.html#Editing_the_layout_hook

In the key-bindings, do something like:

, ((modm .|. controlMask, xK_KP_End      ), withFocused (sendMessage . Snap BottomLeft))
, ((modm .|. controlMask, xK_KP_Down     ), withFocused (sendMessage . Snap Bottom))
, ((modm .|. controlMask, xK_KP_Page_Down), withFocused (sendMessage . Snap BottomRight))
, ((modm .|. controlMask, xK_KP_Left     ), withFocused (sendMessage . Snap SnapLayout.Left))
, ((modm .|. controlMask, xK_KP_Right    ), withFocused (sendMessage . Snap SnapLayout.Right))
, ((modm .|. controlMask, xK_KP_Home     ), withFocused (sendMessage . Snap TopLeft))
, ((modm .|. controlMask, xK_KP_Up       ), withFocused (sendMessage . Snap Top))
, ((modm .|. controlMask, xK_KP_Page_Up  ), withFocused (sendMessage . Snap TopRight))
, ((modm .|. controlMask, xK_KP_Insert   ), withFocused (sendMessage . Unsnap))

, ((modm .|. controlMask .|. shiftMask, xK_KP_End),
      withFocused (sendMessage . FineAdjustmentMessage BottomLeftAdjustment))
, ((modm .|. controlMask .|. shiftMask, xK_KP_Down),
      withFocused (sendMessage . FineAdjustmentMessage BottomAdjustment))
, ((modm .|. controlMask .|. shiftMask, xK_KP_Page_Down),
      withFocused (sendMessage . FineAdjustmentMessage BottomRightAdjustment))
, ((modm .|. controlMask .|. shiftMask, xK_KP_Left),
      withFocused (sendMessage . FineAdjustmentMessage LeftAdjustment))
, ((modm .|. controlMask .|. shiftMask, xK_KP_Right),
      withFocused (sendMessage . FineAdjustmentMessage RightAdjustment))
, ((modm .|. controlMask .|. shiftMask, xK_KP_Home),
      withFocused (sendMessage . FineAdjustmentMessage TopLeftAdjustment))
, ((modm .|. controlMask .|. shiftMask, xK_KP_Up),
      withFocused (sendMessage . FineAdjustmentMessage TopAdjustment))
, ((modm .|. controlMask .|. shiftMask, xK_KP_Page_Up),
      withFocused (sendMessage . FineAdjustmentMessage TopRightAdjustment))
, ((modm .|. controlMask .|. shiftMask, xK_KP_Insert), withFocused (sendMessage . Unadjust))
...

For detailed instruction on editing the key binding see:

https://hackage.haskell.org/package/xmonad-contrib-0.17.0/docs/XMonad-Doc-Extending.html#Editing_key_bindings

Installing Dependencies

Using Cabal (recommended):

cabal new-install --lib base xmonad xmonad-contrib data-default containers

Running Tests

  1. Install dependencies above, plus the following extra dependency:

    cabal new-install --lib HUnit
  2. Compile test files:

    cabal test

Using with NixOS

Add something like this to the top of your configuration.nix:

{ config, pkgs, ... }:
let
  snaplayout-for-xmonad = (import (fetchTarball {
    url = "https://github.com/google/snaplayout-for-xmonad/archive/refs/tags/v0.0.5.0.tar.gz";
    sha256 = "sha256:0kfxq585f8r9sijsf0mpabhi94260h7qs01h80gsl9za6p2vrlkr";
  })).outputs.packages.${builtins.currentSystem}.snaplayout-for-xmonad;
in
{

And then something like this in the main body:

  services.xserver.enable = true;
  services.xserver.windowManager.xmonad = {
    enableContribAndExtras = true;
    enable = true;
    extraPackages = haskellPackages: [
      snaplayout-for-xmonad
    ];
  };

FocusOnTop

FocusOnTop FocusOnTop.hs is a LayoutModifier that pulls the focused Window to the front of the screen, while preserving the relative order of the rest of the Windows. It's primarily intended for SnapLayout (see config examples above), but it could be used to modify other Layouts as well.

Future Plans

  • use alternative layout (maybe Tall, Tabbed, or Grid?) for windows that aren't snapped
  • maybe add options for snapping windows snapped to "middle cells" rather than just screen edges? (for non-1/2-screen snaps)
  • possibly a single-window full-screen mode

Contributing

See CONTRIBUTING for more.

License

See LICENSE for more.

snaplayout-for-xmonad's People

Contributors

glennhartmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

snaplayout-for-xmonad's Issues

stacking order is weird

The focused window is always on top, as intended. But sometimes switching focus moves other windows around in stacking order, rather than just moving the focused window forward. Ideally, the only effect of changing focus is that the new focus is brought to the front, and the existing relative order of all other windows is preserved.

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.