### Ferrishot Default Configuration (KDL) Source: https://github.com/nik-rev/ferrishot/blob/main/CHANGELOG.md Example of Ferrishot's configuration file format using KDL. Customize settings like size indicators, selection icons, keybindings, and themes. ```kdl // Show the size indicator size-indicator #true // Show icons around the selection selection-icons #true keys { // Leave the app exit key= // Copies selected region to clipboard, exiting copy-to-clipboard mod=ctrl key=c copy-to-clipboard key= } theme { // color of the frame around the selection selection-frame 0xab_61_37 // background color of the region that is not selected non-selected-region 0x00_00_00 opacity=0.5 } ``` -------------------------------- ### Set up shell alias for instant copy Source: https://github.com/nik-rev/ferrishot/blob/main/CHANGELOG.md Example of a shell alias to set Ferrishot to instantly copy selections to the clipboard by default. ```bash alias ferrishot=ferrishot --accept-on-select=copy ``` -------------------------------- ### Peashot Region Syntax Examples Source: https://context7.com/nik-rev/ferrishot/llms.txt Define screenshot regions using absolute pixel values or relative screen dimensions. Supports various formats for precise selection, including centering and mixed units. ```bash ferrishot --region 400x300+50+75 ``` ```bash ferrishot --region 0.5x0.5+0.25+0.25 ``` ```bash ferrishot --region 100x1.0+0.5+0-50% ``` ```bash ferrishot --region 200x200+0.5+0.5-50%-50% ``` ```bash ferrishot --region full ``` -------------------------------- ### Dump default configuration to file Source: https://github.com/nik-rev/ferrishot/blob/main/CHANGELOG.md Command to generate the default Ferrishot configuration file, which can then be edited for customization. ```bash ferrishot --dump-default-config ``` -------------------------------- ### Replace --instant flag with --accept-on-select Source: https://github.com/nik-rev/ferrishot/blob/main/CHANGELOG.md Demonstrates the updated command-line usage for instantly copying a selection to the clipboard, replacing the deprecated --instant flag. ```bash ferrishot --accept-on-select copy ``` -------------------------------- ### Parse Configuration with `Config::parse` Source: https://context7.com/nik-rev/ferrishot/llms.txt Reads the user's KDL configuration file, merging it with defaults. Handles missing files gracefully and surfaces errors with `miette` diagnostics. ```rust use peashot::Config; fn main() -> miette::Result<()> { // Parse from the default path; an absent file is silently ignored let config = Config::parse("/home/user/.config/ferrishot.kdl")?; println!("size_indicator : {}", config.size_indicator); println!("selection_icons : {}", config.selection_icons); // Access compiled keybindings // config.keys is a KeyMap (HashMap<(KeySequence, KeyMods), Command>) // Access theme colours (iced::Color) let sel = config.theme.selection_frame; println!("selection frame rgba: {:?}", sel); Ok(()) } ``` -------------------------------- ### Run Ferrishot Project Source: https://github.com/nik-rev/ferrishot/blob/main/CONTRIBUTING.md Use this command to run the Ferrishot application. Ensure you have built the project first. ```sh cargo run ``` -------------------------------- ### Basic Screenshot Selection and Actions Source: https://github.com/nik-rev/ferrishot/blob/main/CHANGELOG.md Core functionalities for selecting a screen region and performing actions like copying to clipboard or saving. ```bash `Esc` closes the app ``` ```bash `Enter` or `Ctrl c` copy region to clipboard ``` ```bash `Ctrl s` save region as an image to path ``` ```bash Instantly copy region to clipboard with `--instant` flag ``` -------------------------------- ### Generate Documentation Source: https://github.com/nik-rev/ferrishot/blob/main/CONTRIBUTING.md Command to generate documentation for the Ferrishot project, including private items. This is used for files in the `completions/` directory. ```sh cargo docgen ``` -------------------------------- ### Ferrishot Command-Line Options Source: https://github.com/nik-rev/ferrishot/blob/main/CHANGELOG.md Overview of various command-line options for controlling Ferrishot's behavior, including delay, region selection, save path, and instant acceptance. ```bash --delay wait some time before taking a screenshot ``` ```bash --region open program with a custom region ``` ```bash --save-path choose a file to save the image to, instead of opening file picker (when using `ctrl + s`) ``` ```bash --accept-on-select instantly save, upload or copy image to clipboard as soon as you create the first selection. ``` -------------------------------- ### Upload Image Concurrently Source: https://context7.com/nik-rev/ferrishot/llms.txt Uploads a PNG file to multiple free hosting services concurrently and returns the first successful result. Requires the `peashot::image::upload` module. ```rust use peashot::image::upload::{upload, ImageUploadService}; use std::path::Path; #[tokio::main] async fn main() { let path = Path::new("/tmp/screenshot.png"); match upload(path).await { Ok(result) => { println!("Uploaded to : {}", result.link); println!("Expires in : {}", result.expires_in); } Err(errors) => { eprintln!("All upload services failed:"); for e in errors { eprintln!(" - {e}"); } } } // Upload to a single service directly let result = ImageUploadService::Litterbox .upload_image(path) .await .expect("Upload failed"); println!("Litterbox link: {}", result.link); // result.expires_in => "3 days" } ``` -------------------------------- ### Basic Screenshot Capture with Peashot CLI Source: https://context7.com/nik-rev/ferrishot/llms.txt Invoke Peashot to open an interactive screenshot overlay. Use options to pre-select regions, set delays, or define immediate actions like copy or save. ```bash ferrishot ``` ```bash ferrishot --region 800x600+100+200 ``` ```bash ferrishot --region 0.5x1.0+0.5+0 ``` ```bash ferrishot --region full ``` ```bash ferrishot --last-region ``` ```bash ferrishot --delay 2000 ``` ```bash ferrishot --accept-on-select copy ``` ```bash ferrishot --region 800x600+0+0 --accept-on-select copy ``` ```bash ferrishot --region full --accept-on-select save --save-path /tmp/shot.png ``` ```bash ferrishot --region full --accept-on-select upload --json ``` ```bash ferrishot --save-path ~/Pictures/shot.png ``` ```bash ferrishot --accept-on-select upload --json # => {"link":"https://...","expires_in":"3 days","width":1920,"height":1080,"file_size":45678} ``` ```bash ferrishot --silent --accept-on-select copy ``` -------------------------------- ### Shell Completions Source: https://context7.com/nik-rev/ferrishot/llms.txt Provides shell completion scripts for Bash, Fish, Nushell, Zsh, and PowerShell. ```bash # Bash source completions/ferrishot.bash ``` ```fish # Fish cp completions/ferrishot.fish ~/.config/fish/completions/ ``` ```nushell # Nushell source completions/ferrishot.nu ``` ```zsh # Zsh (oh-my-zsh / fpath) cp _ferrishot ~/.zsh/completions/ ``` ```powershell # PowerShell . completions/_ferrishot.ps1 ``` -------------------------------- ### KDL Configuration for Ferrishot Source: https://context7.com/nik-rev/ferrishot/llms.txt Defines settings for Ferrishot, including UI elements, keybindings, and color themes. User configurations merge with built-in defaults. ```kdl // ferrishot.kdl – full working example // Show pixel dimensions of the current selection size-indicator #true // Show action icons around the selection rectangle selection-icons #true keys { // Built-in defaults (can be overridden or extended) exit key= copy-to-clipboard mod=ctrl key=c copy-to-clipboard key= save-screenshot mod=ctrl key=s upload-screenshot mod=ctrl key=u select-region "full" key= clear-selection mod=ctrl key=x // Super-select: place TL corner with 8 key-strokes pick-top-left-corner key=t pick-bottom-right-corner key=b open-keybindings-cheatsheet key=? // Vim-style movement (1 px at a time) move left 1 key=h move down 1 key=j move up 1 key=k move right 1 key=l // Large movement (125 px) with Alt move left 125 mod=alt key=h move down 125 mod=alt key=j move up 125 mod=alt key=k move right 125 mod=alt key=l // Extend / shrink edges extend left 1 key=H extend down 1 key=J extend up 1 key=K extend right 1 key=L shrink left 1 mod=ctrl key=h shrink down 1 mod=ctrl key=j shrink up 1 mod=ctrl key=k shrink right 1 mod=ctrl key=l // Jump to corners / center goto top-left key=gg goto bottom-right key=G goto center key=gc goto x-center key=gx goto y-center key=gy } theme { // Define a reusable palette palette \ accent = 0xab_61_37 \ fg = 0xff_ff_ff \ bg = 0x00_00_00 // Reference palette entries by name selection-frame accent non-selected-region bg opacity=0.5 drop-shadow bg opacity=0.5 // Use an explicit hex colour error-bg 0xff_00_00 opacity=0.6 error-fg fg size-indicator-fg fg size-indicator-bg bg opacity=0.5 icon-fg fg icon-bg accent success 0x00_ff_00 } ``` -------------------------------- ### Parse Region Syntax with `LazyRectangle` Source: https://context7.com/nik-rev/ferrishot/llms.txt Parses flexible region strings (e.g., WxH+X+Y, relative percentages) and resolves them against a screen's dimensions into an `iced::Rectangle`. Results are clamped to screen bounds. ```rust use peashot::lazy_rect::LazyRectangle; use iced::Rectangle; fn main() { let screen = Rectangle { x: 0.0, y: 0.0, width: 1920.0, height: 1080.0 }; // Absolute region let r = "800x600+100+200".parse::().unwrap().init(screen); assert_eq!(r, Rectangle { x: 100.0, y: 200.0, width: 800.0, height: 600.0 }); // Relative: centre half of the screen let r = "0.5x0.5+0.25+0.25".parse::().unwrap().init(screen); assert_eq!(r, Rectangle { x: 480.0, y: 270.0, width: 960.0, height: 540.0 }); // Full-screen alias let r = "full".parse::().unwrap().init(screen); assert_eq!(r, screen); // Nudged: 200×200, top-left corner centred on screen let r = "200x200+0.5+0.5-50%-50%".parse::().unwrap().init(screen); assert_eq!(r, Rectangle { x: 860.0, y: 440.0, width: 200.0, height: 200.0 }); // Result is always clamped to the container bounds let r = "9999x9999+0+0".parse::().unwrap().init(screen); assert_eq!(r.width, 1920.0); assert_eq!(r.height, 1080.0); } ``` -------------------------------- ### Copy Image to Clipboard Source: https://context7.com/nik-rev/ferrishot/llms.txt Copies an image to the clipboard using RGBA byte data. On Linux, a background daemon is spawned to keep clipboard contents alive. Requires the `peashot::clipboard` module. ```rust use peashot::clipboard; use arboard::ImageData; use std::borrow::Cow; fn copy_image_to_clipboard(rgba_bytes: Vec, width: usize, height: usize) { let data = ImageData { width, height, bytes: Cow::Owned(rgba_bytes), }; match clipboard::set_image(data) { Ok(tmp_path) => println!("Copied. Temp buffer at {:?}", tmp_path), Err(e) => eprintln!("Clipboard error: {e}"), } } ``` -------------------------------- ### Ferrishot Debugging CLI Options Source: https://github.com/nik-rev/ferrishot/blob/main/CONTRIBUTING.md Available command-line options for debugging Ferrishot. These options control logging levels, output destinations, and enable debug mode. ```sh Debug: --log-level Choose a minimum level at which to log. [error, warn, info, debug, trace, off] [default: error] --log-stderr Log to standard error instead of file --log-file Path to the log file [default: /home/e/.cache/ferrishot.log] --log-filter Filter for specific Rust module or crate, instead of showing logs from all crates --debug Launch in debug mode (F12) ``` -------------------------------- ### Copy Text to Clipboard Source: https://context7.com/nik-rev/ferrishot/llms.txt Copies a string slice to the clipboard. On Linux, a background daemon is spawned to keep clipboard contents alive. Requires the `peashot::clipboard` module. ```rust use peashot::clipboard; fn copy_link_to_clipboard(url: &str) { if let Err(e) = clipboard::set_text(url) { eprintln!("Failed to copy text: {e}"); } } ``` -------------------------------- ### Peashot Configuration Management Source: https://context7.com/nik-rev/ferrishot/llms.txt Manage Peashot's configuration files using the CLI. Dump default configurations or specify a custom configuration file for a specific invocation. ```bash ferrishot --dump-default-config # => Wrote the default config file to /home/user/.config/ferrishot.kdl ``` ```bash ferrishot --config-file ~/dotfiles/ferrishot.kdl ``` -------------------------------- ### Declare Custom Commands with `declare_commands!` Macro Source: https://context7.com/nik-rev/ferrishot/llms.txt Use the `declare_commands!` macro in Rust to generate both a runtime `Command` enum and a KDL-deserializable `KeymappableCommand` from a single definition. ```rust use peashot::declare_commands; // Declare custom commands for a module declare_commands! { enum Command { /// Copy image to the clipboard CopyToClipboard, /// Save image to a file SaveScreenshot, /// Upload image to the internet UploadScreenshot, } } // Each variant generates KDL like: // copy-to-clipboard key= // save-screenshot mod=ctrl key=s // upload-screenshot mod=ctrl key=u ``` -------------------------------- ### Persist and Read Last Region Source: https://context7.com/nik-rev/ferrishot/llms.txt Writes the last used selection rectangle to the platform cache directory and reads it back on the next invocation. Requires the `peashot::last_region` module. ```rust use peashot::last_region; use iced::Rectangle; fn main() { let screen = Rectangle { x: 0.0, y: 0.0, width: 1920.0, height: 1080.0 }; // Write a region after a successful capture let captured = Rectangle { x: 200.0, y: 100.0, width: 800.0, height: 600.0 }; last_region::write(captured).expect("Failed to persist last region"); // On the next run, restore it match last_region::read(screen) { Ok(Some(region)) => println!("Restored region: {:?}", region), Ok(None) => println!("No previous region saved"), Err(e) => eprintln!("Could not read last region: {e}"), } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.