Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fn3x/sneemok

Repository files navigation

sneemok

Wayland screenshot annotation tool in Zig.

The main repository is on codeberg, which is where the issue tracker may be found and where contributions are accepted.

Read-only mirrors exist on github.

Dependencies

  • wayland (compositor)
  • wlroots (compositor)
  • cairo (drawing)
  • D-Bus (communication with portal and sneemok daemon)
  • XDG Desktop Portal (for screenshot capture)

Installation

Convenient script:

wget https://codeberg.org/fn3x/sneemok/raw/branch/main/scripts/install.sh
chmod +x install.sh
./install.sh

Arch:

yay -S sneemok
# or
yay -S sneemok-git

Nix

Option 1: Home Manager (Recommended for single user)

In your Home Manager configuration:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    home-manager.url = "github:nix-community/home-manager";
    sneemok.url = "git+https://codeberg.org/fn3x/sneemok.git";
  };

  outputs = { nixpkgs, home-manager, sneemok, ... }: {
    homeConfigurations.youruser = home-manager.lib.homeManagerConfiguration {
      pkgs = nixpkgs.legacyPackages.x86_64-linux;
      modules = [
        sneemok.homeManagerModules.default
        {
          services.sneemok = {
            enable = true;
          };
        }
      ];
    };
  };
}

Then rebuild:

home-manager switch --flake .#youruser

Option 2: NixOS (System-wide)

In your NixOS configuration:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    sneemok.url = "git+https://codeberg.org/fn3x/sneemok.git";
  };

  outputs = { nixpkgs, sneemok, ... }: {
    nixosConfigurations.yourhostname = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        sneemok.nixosModules.default
        {
          services.sneemok = {
            enable = true;
          };
        }
      ];
    };
  };
}

Then rebuild:

sudo nixos-rebuild switch --flake .#yourhostname

Managing the Service

Start/Stop/Status

systemctl --user start sneemok
systemctl --user stop sneemok
systemctl --user status sneemok
systemctl --user restart sneemok

View logs:

journalctl --user -u sneemok -f

Taking Screenshots

Once the service is running:

# Trigger a screenshot
sneemok --screenshot

# Or just
sneemok

Keybindings

Add to your compositor config (e.g., Hyprland):

bind = $mainMod, P, exec, sneemok
bind = $mainMod SHIFT, P, exec, sneemok --screenshot

Or in sway:

bindsym $mod+p exec sneemok
bindsym $mod+Shift+p exec sneemok --screenshot

Troubleshooting

Service won't start:

# Check logs
journalctl --user -u sneemok -n 50

# Check if D-Bus session bus is available
echo $DBUS_SESSION_BUS_ADDRESS

# Check if compositor is running
echo $WAYLAND_DISPLAY

Screenshots not triggering:

# Test D-Bus connection manually
dbus-send --session --print-reply \
  --dest=org.sneemok.Service \
  /org/sneemok/service \
  org.sneemok.Service.Screenshot

Service keeps restarting:

# Check what's failing
systemctl --user status sneemok
journalctl --user -u sneemok -f

Common issues:

  • XDG Desktop Portal not available → Install xdg-desktop-portal-hyprland or equivalent
  • Compositor not running → Service requires graphical session
  • D-Bus session bus not available → Check session setup

Disabling the Service

Manually:

systemctl --user disable --now sneemok

Home Manager:

services.sneemok.enable = false;

NixOS:

services.sneemok.enable = false;

Build from source

With Nix:

nix build

Without Nix:

zig build

Keys

  • s - Selection tool
  • a - Arrow
  • r - Rectangle
  • c - Circle
  • l - Line
  • Ctrl+C - Copy to clipboard
  • ESC - Change current tool to selection or exit
  • Mouse wheel up - Increase thickness of the current tool
  • Mouse wheel down - Decrease thickness of the current tool

Mouse

  • Drag to create selection/draw
  • Resize handles on selection
  • Click inside to move

Architecture

src/
├── main.zig        # Events, signals and threading of the D-Bus handler
├── state.zig       # Application state
├── wayland.zig     # Wayland-related objects
├── dbus.zig        # Dbus struct with connection initialization, requesting and parsing screenshot from portal
├── output.zig      # Rendering
├── canvas/         # Image + elements
└── tools/          # Selection + drawing tools

Rendering: Screenshot → Overlay → Selection → Elements → Tool UI

Format: BGRA internally, RGBA PNG export

Clipboard: Native Wayland

License

MIT

About

[mirror] D-bus wl-roots based screenshot tool written in Zig

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published