Skip to content

Latest commit

 

History

History
199 lines (161 loc) · 6.35 KB

README.md

File metadata and controls

199 lines (161 loc) · 6.35 KB

focal

focal is a rofi menu for capturing and copying screenshots or videos on hyprland / sway.

main menu delay menu selection selection
Wallpaper made by the awesome Rosuuri

Features

  • rofi menu to select area / window / entire screen to capture
  • rofi menu to select delay before capture
  • image / video is automatically copied to clipboard, ready for pasting into other programs
  • notifications that open captured file when clicked
  • all options are also available via the CLI
  • supports either hyprland or sway
  • OCR support to select text from captured image (CLI only)

Installation

NixOS

{
  inputs.focal = {
    url = "github:iynaix/focal";
    inputs.nixpkgs.follows = "nixpkgs"; # override this repo's nixpkgs snapshot
  };
}

Then, include it in your environment.systemPackages or home.packages by referencing the input:

# for hyprland
inputs.focal.packages.${pkgs.system}.default
# for sway
inputs.focal.packages.${pkgs.system}.focal-sway

Alternatively, it can also be run directly:

# for hyprland
nix run github:iynaix/focal
# for sway
nix run github:iynaix/focal#focal-sway

OCR support can be optionally disabled through the use of an override:

(inputs.focal.packages.${pkgs.system}.default.override { ocr = false; })

Arch Linux

Arch Linux users can install from the AUR or AUR-git.

# for hyprland
paru -S focal-hyprland-git
# for sway
paru -S focal-sway-git

Usage

$ focal --help
focal is a rofi menu for capturing and copying screenshots or videos on hyprland / sway.

Usage: focal image [OPTIONS] <--rofi|--area <AREA>|--selection|--monitor|--all> [FILE]
       focal video [OPTIONS] <--rofi|--area <AREA>|--selection|--monitor|--stop> [FILE]
       focal help [COMMAND]...

Options:
  -h, --help     Print help
  -V, --version  Print version

focal image:
Captures a screenshot.
  -a, --area <AREA>         Type of area to capture [aliases: capture] [possible values: monitor, selection, all]
      --selection
      --monitor
      --all
      --freeze              Freezes the screen before selecting an area.
  -t, --delay <DELAY>       Delay in seconds before capturing
  -s, --slurp <SLURP>       Options to pass to slurp
      --no-rounded-windows  Do not show rounded corners when capturing a window. (Hyprland only)
      --no-notify           Do not show notifications
      --no-save             Do not save the file permanently
      --rofi                Display rofi menu for selection options
      --no-icons            Do not show icons for rofi menu
      --theme <THEME>       Path to a rofi theme
  -e, --edit <COMMAND>      Edit screenshot using COMMAND
                            The image path will be passed as $IMAGE
      --ocr [<LANG>]        Runs OCR on the selected text
  -h, --help                Print help (see more with '--help')
  [FILE]                Files are created in XDG_PICTURES_DIR/Screenshots if not specified

focal video:
Captures a video.
  -a, --area <AREA>         Type of area to capture [aliases: capture] [possible values: monitor, selection]
      --selection
      --monitor
  -t, --delay <DELAY>       Delay in seconds before capturing
  -s, --slurp <SLURP>       Options to pass to slurp
      --no-rounded-windows  Do not show rounded corners when capturing a window. (Hyprland only)
      --no-notify           Do not show notifications
      --no-save             Do not save the file permanently
      --rofi                Display rofi menu for selection options
      --no-icons            Do not show icons for rofi menu
      --theme <THEME>       Path to a rofi theme
      --stop                Stops any previous video recordings
      --audio [<DEVICE>]    Capture video with audio, optionally specifying an audio device
      --duration <SECONDS>  Duration in seconds to record
  -h, --help                Print help (see more with '--help')
  [FILE]                Files are created in XDG_VIDEOS_DIR/Screencasts if not specified

focal help:
Print this message or the help of the given subcommand(s)
  [COMMAND]...  Print help for the subcommand(s)

Tip

Invoking focal video a second time stops any currently recording videos.

Example usage as a hyprland keybinding:

bind=$mainMod, backslash, exec, focal image --area selection

Similarly, for a sway keybinding:

bindsym $mod+backslash exec "focal image --area selection"

Optional Waybar Module

An optional focal-waybar script is available for waybar to indicate when a recording is in progress.

$ focal-waybar --help
Updates waybar module with focal's recording status.

Usage: focal-waybar [OPTIONS]

Options:
      --recording <MESSAGE>  Message to display in waybar module when recording [default: REC]
      --stopped <MESSAGE>    Message to display in waybar module when not recording [default: ]
  -h, --help                 Print help
  -V, --version              Print version

Create a custom waybar module similar to the following:

{
  "custom/focal": {
    "exec": "focal-waybar --recording 'REC'",
    "format": "{}",
    // interval to poll for updated recording status
    "interval": 1,
    "on-click": "focal video --stop",
  },
}

focal video recordings can then be started / stopped using keybindings such as:

hyprland:

bind=$mainMod, backslash, exec, focal video --rofi --audio

sway:

bindsym $mod+backslash exec "focal video --rofi --audio"

Packaging

To build focal from source

Hacking

Just use nix develop