
What is Swappy?
Swappy is a user-friendly screenshot editing tool designed for quick modifications and annotations. With its simple interface, you can enhance your images without needing complicated software.
It caters especially to users looking to improve their screenshot editing process effortlessly.
With Swappy, you can perform a variety of basic edits, including cropping, drawing, and adding text. For instance, some users have improved their presentation quality simply by using clear annotations on their screenshots.
It’s an ideal solution for anyone who frequently shares visual content and needs it to be both informative and visually appealing.
Swappy should effortlessy run both in Sway and Hyprland compositors.
Using Hyprshot with Swappy
The solution I prefer is to use Swappy after taking a screenshot with hyprshot.
You can keybind the following snippets to a specific key in the configuration file of your wayland compositor (wayland or sway) or use them in a bash script.
Requirements
wl-clipboard
if you are using sway or Hyprland, this package should be installed on your system.
If not, use your package manager to install it.
Here you are few code examples that can be improved according to your needs.
Screenshot of the Active (focused) Window
The following snippet:
takes a screenshot of the active window with hyprshot and copies it in the system clipboard.
(Warning: make sure to have wl-clipboard installed. It can be found in your distro's repo.)
pastes the clipboard content into swappy
after you edit the screenshot with swappy, press the 'save surface button'
close swappy
the output of the edited file is saved into ~/Pictures/Screenshots
(the output folder name can be changed)
The screenshot image is saved with the name "screenshot-" followed by the current date and time (this can be changed as per your needs)
hyprshot -m window -m active --clipboard-only; wl-paste | swappy -f - -o $HOME/Pictures/Screenshots/screenshot-$(date)
Screenshot of the Active (focused) Output (Screen)
Similarly the following snippet takes a screenshot of the whole active (focused) screen.
hyprshot -m output -m active --clipboard-only; wl-paste | swappy -f - -o $HOME/Pictures/Screenshots/screenshot-$(date)
The screenshot image is saved with the name "screenshot-" followed by the current date and time (this can be changed as per your needs)
Screenshot of the selected area
The following snippet allows you to select a specific region of your screen.
The mouse cursor will turn into a cross and you can select a specific region of your screen.
Once the mouse key is released, swappy will open, allowing you to edit or annotate the screenshot.
hyprshot -m region --clipboard-only; $timeout_cmd; wl-paste | swappy -f - -o $HOME/Pictures/Screenshots/screenshot-$(date)
The screenshot image is saved with the name "screenshot-" followed by the current date and time (this can be changed as per your needs)
Setting Up Keybindings in Hyprland
To boost your productivity, set specific keybindings in Hyprland for various screenshot types: the active window, the entire screen, and a selected area.
Here’s how to set up a "Print Screen" keybinding for each action:
Open the Configuration File: Locate your Hyprland configuration file, usually found at `~/.config/hypr/hyprland.conf`.
Add Keybindings: Insert these lines to define keybindings for different screenshot functionalities.
In this snippet below the "PrintScr" key is mapped to execute a code snippet.
bind=XKB_KEY_Print, exec [ insert one of the code snippet above ]
Save and Reload: After saving the configuration file, reload your Hyprland session to apply the changes.
Suggestions:
You can insert each of the above snippets in a single or in multiple scripts that can be executed by the keybinding(s)
Conclusion
Hyprshot and Swappy can do much more than what I described in this post.
For further information it is strongly advised to check the documentation.
You can do so in your terminal window by running;
hyprshot --help
and
man swappy
Hyprland wikis can be found at https://wiki.hyprland.org/
Related posts
Check the my previous post "Taking a screenshot in Hyprland using Hyprshot", here
Comments