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:
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:
Using Cabal (recommended):
cabal new-install --lib base xmonad xmonad-contrib data-default containers
-
Install dependencies above, plus the following extra dependency:
cabal new-install --lib HUnit
-
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.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 Window
s. It's primarily intended for SnapLayout (see config examples above), but it could be used to modify other Layouts as well.
- 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
See CONTRIBUTING for more.
See LICENSE for more.