Sweets

Installation

Install sweetshot and bind it to keys

On FreeBSD, see FreeBSD.

Arch Linux

yay -S sweetshot-bin

Use sweetshot-git for the development branch.

NixOS

Add the flake to your inputs and its overlay to nixpkgs:

{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-26.05";
    sweetshot = {
      url = "github:SweetWM/sweetshot";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { nixpkgs, sweetshot, ... }: {
    nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        ./configuration.nix
        { nixpkgs.overlays = [ sweetshot.overlays.default ]; }
      ];
    };
  };
}

Then add pkgs.sweetshot to your packages.

Build from source

Requirements:

  • Meson, Ninja, and a C11 compiler
  • wayland-client, wayland-protocols, wayland-scanner
  • zlib
git clone https://github.com/SweetWM/sweetshot.git
cd sweetshot
meson setup build --buildtype=release
meson compile -C build
sudo meson install -C build

Bind keys

Add bindings to your Sweets config:

sweets.bind("Print", "spawn", { "sweetshot", "region" })
sweets.bind("Ctrl+Print", "spawn", { "sweetshot", "output" })
sweets.bind("Alt+Print", "spawn", { "sweetshot", "window" })

-- No open animation for the selector and editor
sweets.layer_rule({ namespace = "sweetshot", animation = false })

output and window find the focused window with sweets msg, so sweets must be on PATH.

Notifications

sweetshot prints the saved path. Wrap the binding to show a notification. A cancelled shot shows nothing.

sweets.bind("Print", "spawn", { "sh", "-c",
    'f=$(sweetshot region) && notify-send -a sweetshot -i "$f" "Screenshot saved" "$f"'
    .. ' || [ $? -eq 3 ] || notify-send -a sweetshot -u critical "Screenshot failed"' })

Permissions

With sweets.permissions({ enforce = true }), allow sweetshot to capture the screen and set the clipboard:

sweets.permission({
    program = { suffix = "/bin/sweetshot" },
    protocol = { "screencopy", "data_control" },
    mode = "allow",
})

On this page