diff options
| author | Don Williams <don.e.williams@gmail.com> | 2026-02-23 18:47:47 -0500 |
|---|---|---|
| committer | Don Williams <don.e.williams@gmail.com> | 2026-02-23 18:47:47 -0500 |
| commit | 59e87cbf4482efb6d7c8ff766f80b0286a20732b (patch) | |
| tree | 7b2bdf7ae6c399a54e154896b78dfef9ec0dd2b7 /config/hypr/scripts/hyprshot.sh | |
| parent | c8767dfaa8c9efbeeec0293ffe4287a40c02b34c (diff) | |
| parent | c1ae43efc9196eca55c59cc43dd8f85975d84206 (diff) | |
Merge branch 'development'
Conflicts:
README.md
config/fastfetch/config-compact.jsonc
config/fastfetch/config.jsonc
config/hypr/scripts/Tak0-Per-Window-Switch.sh
i18n/README/README.de.md
i18n/README/README.jp.md
i18n/README/README.ro.md
i18n/README/README.ru.md
i18n/README/README.ua.md
It looks like you may be committing a merge.
If this is not correct, please run
git update-ref -d MERGE_HEAD
and try again.
Please enter the commit message for your changes. Lines starting
with '#' will be ignored, and an empty message aborts the commit.
On branch main
Your branch is up to date with 'origin/main'.
All conflicts fixed but you are still merging.
Changes to be committed:
modified: CHANGELOG.md
modified: README.md
renamed: update-dots.sh -> archive/update-dots.sh
new file: assets/waybar-weather.gz
new file: config/fastfetch/config-compact-legacy.jsonc
modified: config/fastfetch/config-compact.jsonc
modified: config/fastfetch/config.jsonc
new file: config/fastfetch/config.legacy.jsonc
modified: config/hypr/UserConfigs/WindowRules.conf
new file: config/hypr/UserScripts/RainbowBorders-low-cpu.sh
modified: config/hypr/configs/ENVariables.conf
modified: config/hypr/configs/Keybinds.conf
modified: config/hypr/configs/Startup_Apps.conf
modified: config/hypr/configs/WindowRules-config-v3.conf
modified: config/hypr/configs/WindowRules.conf
modified: config/hypr/monitors.conf
modified: config/hypr/scripts/Kitty_themes.sh
modified: config/hypr/scripts/Kool_Quick_Settings.sh
new file: config/hypr/scripts/PortalHyprlandUbuntu2604.sh
modified: config/hypr/scripts/Refresh.sh
modified: config/hypr/scripts/Tak0-Per-Window-Switch.sh
new file: config/hypr/scripts/Toggle-Active-Window-Audio.sh
new file: config/hypr/scripts/Toggle-weather-waybar-units.sh
modified: config/hypr/scripts/WallustSwww.sh
modified: config/hypr/scripts/WaybarCava.sh
new file: config/hypr/scripts/dots-tui
new file: config/hypr/scripts/dots-tui-ubuntu-2404
new file: config/hypr/scripts/hyprshot.sh
new file: config/hypr/scripts/install-uv.sh
renamed: config/hypr/v2.3.20 -> config/hypr/v2.3.21
modified: config/hypr/wallpaper_effects/.wallpaper_current
modified: config/kitty/kitty.conf
new file: config/rofi/00-terminal.rasi
modified: config/rofi/config.rasi
modified: config/wallust/templates/colors-waybar.css
new file: config/wallust/wallust-kitty.toml
modified: config/wallust/wallust.toml
new file: config/waybar-weather/cityname.txt
new file: config/waybar-weather/config.toml
new file: config/waybar-weather/geolocation.txt
modified: config/waybar/ModulesCustom
modified: config/waybar/config
renamed: config/waybar/configs/[BOT & Left] SouthWest -> config/waybar/configs/BOT-&-Left-SouthWest
renamed: config/waybar/configs/[BOT & Right] SouthEast -> config/waybar/configs/BOT-&-Right-SouthEast
renamed: config/waybar/configs/[BOT] Camellia -> config/waybar/configs/BOT-Camellia
renamed: config/waybar/configs/[BOT] Chrysanthemum -> config/waybar/configs/BOT-Chrysanthemum
renamed: config/waybar/configs/[BOT] Default -> config/waybar/configs/BOT-Default
renamed: config/waybar/configs/[BOT] Default Laptop -> config/waybar/configs/BOT-Default-Laptop
renamed: config/waybar/configs/[BOT] Gardenia -> config/waybar/configs/BOT-Gardenia
renamed: config/waybar/configs/[BOT] Peony -> config/waybar/configs/BOT-Peony
renamed: config/waybar/configs/[BOT] Simple -> config/waybar/configs/BOT-Simple
renamed: config/waybar/configs/[BOT] Sleek -> config/waybar/configs/BOT-Sleek
renamed: config/waybar/configs/[LEFT] WestWing -> config/waybar/configs/LEFT-WestWing
renamed: config/waybar/configs/[LEFT] WestWing v2 -> config/waybar/configs/LEFT-WestWing-v2
renamed: config/waybar/configs/[RIGHT] EastWing -> config/waybar/configs/RIGHT-EastWing
renamed: config/waybar/configs/[RIGHT] EastWing v2 -> config/waybar/configs/RIGHT-EastWing-v2
renamed: config/waybar/configs/[TOP & BOT] SummitSplit -> config/waybar/configs/TOP-&-BOT-SummitSplit
renamed: config/waybar/configs/[TOP & BOT] SummitSplit-glass -> config/waybar/configs/TOP-&-BOT-SummitSplit-glass
renamed: config/waybar/configs/[TOP & BOT] SummitSplit v2 -> config/waybar/configs/TOP-&-BOT-SummitSplit-v2
new file: config/waybar/configs/TOP-&-BOT-SummitSplit-v3
renamed: config/waybar/configs/[TOP & Left] NorthWest -> config/waybar/configs/TOP-&-Left-NorthWest
renamed: config/waybar/configs/[TOP & Right] NorthEast -> config/waybar/configs/TOP-&-Right-NorthEast
renamed: config/waybar/configs/[TOP] 0-Ja-0 -> config/waybar/configs/TOP-0-Ja-0
renamed: config/waybar/configs/[TOP] Arrow -> config/waybar/configs/TOP-Arrow
renamed: config/waybar/configs/[TOP] Camellia -> config/waybar/configs/TOP-Camellia
renamed: config/waybar/configs/[TOP] Chrysanthemum -> config/waybar/configs/TOP-Chrysanthemum
renamed: config/waybar/configs/[TOP] Default -> config/waybar/configs/TOP-Default
renamed: config/waybar/configs/[TOP] Default Laptop -> config/waybar/configs/TOP-Default-Laptop
renamed: config/waybar/configs/[TOP] Default Laptop-glass -> config/waybar/configs/TOP-Default-Laptop-glass
renamed: config/waybar/configs/[TOP] Default Laptop (old v1) -> config/waybar/configs/TOP-Default-Laptop-old-v1
renamed: config/waybar/configs/[TOP] Default Laptop (old v2) -> config/waybar/configs/TOP-Default-Laptop-old-v2
renamed: config/waybar/configs/[TOP] Default Laptop (old v3) -> config/waybar/configs/TOP-Default-Laptop-old-v3
renamed: config/waybar/configs/[TOP] Default Laptop (old v4) -> config/waybar/configs/TOP-Default-Laptop-old-v4
renamed: config/waybar/configs/[TOP] Default Laptop (old v5) -> config/waybar/configs/TOP-Default-Laptop-old-v5
renamed: config/waybar/configs/[TOP] Default (old v1) -> config/waybar/configs/TOP-Default-old-v1
renamed: config/waybar/configs/[TOP] Default (old v2) -> config/waybar/configs/TOP-Default-old-v2
renamed: config/waybar/configs/[TOP] Default (old v3) -> config/waybar/configs/TOP-Default-old-v3
renamed: config/waybar/configs/[TOP] Default (old v4) -> config/waybar/configs/TOP-Default-old-v4
renamed: config/waybar/configs/[TOP] Everforest -> config/waybar/configs/TOP-Everforest
renamed: config/waybar/configs/[TOP] Everforest-glass -> config/waybar/configs/TOP-Everforest-glass
renamed: config/waybar/configs/[TOP] Gardenia -> config/waybar/configs/TOP-Gardenia
renamed: config/waybar/configs/[TOP] Minimal - Long -> config/waybar/configs/TOP-Minimal-Long
renamed: config/waybar/configs/[TOP] Minimal - Short -> config/waybar/configs/TOP-Minimal-Short
renamed: config/waybar/configs/[TOP] Peony -> config/waybar/configs/TOP-Peony
renamed: config/waybar/configs/[TOP] Simple -> config/waybar/configs/TOP-Simple
renamed: config/waybar/configs/[TOP] Simpliest -> config/waybar/configs/TOP-Simpliest
renamed: config/waybar/configs/[TOP] Sleek -> config/waybar/configs/TOP-Sleek
new file: config/waybar/configs/TOP-ddubs-simple-bar
modified: config/waybar/style.css
renamed: config/waybar/style/[0 VERTICAL] [Catpuccin] Mocha.css -> config/waybar/style/0-VERTICAL-Catpuccin-Mocha.css
renamed: config/waybar/style/[0 VERTICAL] Golden Noir.css -> config/waybar/style/0-VERTICAL-Golden-Noir.css
renamed: config/waybar/style/[0 VERTICAL] Oglo Chicklets.css -> config/waybar/style/0-VERTICAL-Oglo-Chicklets.css
renamed: config/waybar/style/[Black & White] Monochrome.css -> config/waybar/style/Black-&-White-Monochrome.css
renamed: config/waybar/style/[Catppuccin] Frappe.css -> config/waybar/style/Catppuccin-Frappe.css
renamed: config/waybar/style/[Catppuccin] Latte.css -> config/waybar/style/Catppuccin-Latte.css
renamed: config/waybar/style/[Catppuccin] Mocha.css -> config/waybar/style/Catppuccin-Mocha.css
renamed: config/waybar/style/[Colored] Chroma Glow.css -> config/waybar/style/Colored-Chroma-Glow.css
renamed: config/waybar/style/[Colored] Translucent.css -> config/waybar/style/Colored-Translucent.css
renamed: config/waybar/style/[Colorful] Aurora Blossom.css -> config/waybar/style/Colorful-Aurora-Blossom.css
renamed: config/waybar/style/[Colorful] Aurora.css -> config/waybar/style/Colorful-Aurora.css
renamed: config/waybar/style/[Colorful] Oglo Chicklets.css -> config/waybar/style/Colorful-Oglo-Chicklets.css
renamed: config/waybar/style/[Colorful] Rainbow Spectrum.css -> config/waybar/style/Colorful-Rainbow-Spectrum.css
renamed: config/waybar/style/[Colorful] stolen-style.css -> config/waybar/style/Colorful-stolen-style.css
renamed: config/waybar/style/Crystal Clear Glass.css -> config/waybar/style/Crystal-Clear-Glass.css
renamed: config/waybar/style/[Dark] Golden Eclipse.css -> config/waybar/style/Dark-Golden-Eclipse.css
renamed: config/waybar/style/[Dark] Golden Noir.css -> config/waybar/style/Dark-Golden-Noir.css
renamed: config/waybar/style/[Dark] Half-Moon.css -> config/waybar/style/Dark-Half-Moon.css
renamed: config/waybar/style/[Dark] Latte-Wallust combined v2.css -> config/waybar/style/Dark-Latte-Wallust-combined-v2.css
renamed: config/waybar/style/[Dark] Latte-Wallust combined.css -> config/waybar/style/Dark-Latte-Wallust-combined.css
renamed: config/waybar/style/[Dark] Purpl.css -> config/waybar/style/Dark-Purpl.css
renamed: config/waybar/style/[Dark] Wallust Obsidian Edge.css -> config/waybar/style/Dark-Wallust-Obsidian-Edge.css
renamed: config/waybar/style/[Extra] Arrow.css -> config/waybar/style/Extra-Arrow.css
renamed: config/waybar/style/[Extra] Crimson.css -> config/waybar/style/Extra-Crimson.css
renamed: config/waybar/style/[Extra] EverForest.css -> config/waybar/style/Extra-EverForest.css
renamed: config/waybar/style/[Extra] ML4W starter.css -> config/waybar/style/Extra-ML4W-starter.css
renamed: config/waybar/style/[Extra] Mauve.css -> config/waybar/style/Extra-Mauve.css
renamed: config/waybar/style/[Extra] Modern-Combined - Transparent.css -> config/waybar/style/Extra-Modern-Combined-Transparent.css
renamed: config/waybar/style/[Extra] Modern-Combined.css -> config/waybar/style/Extra-Modern-Combined.css
renamed: config/waybar/style/[Extra] Neon Circuit.css -> config/waybar/style/Extra-Neon-Circuit.css
renamed: config/waybar/style/[Extra] Prismatic Glow.css -> config/waybar/style/Extra-Prismatic-Glow.css
renamed: config/waybar/style/[Extra] Rose Pine.css -> config/waybar/style/Extra-Rose-Pine.css
renamed: config/waybar/style/[Extra] Simple Pink.css -> config/waybar/style/Extra-Simple-Pink.css
renamed: config/waybar/style/[Light] Monochrome Contrast.css -> config/waybar/style/Light-Monochrome-Contrast.css
renamed: config/waybar/style/[Light] Obsidian Glow.css -> config/waybar/style/Light-Obsidian-Glow.css
renamed: config/waybar/style/ML4W Glass-3d.css -> config/waybar/style/ML4W-Glass-3d.css
renamed: config/waybar/style/ML4W Glass.css -> config/waybar/style/ML4W-Glass.css
renamed: config/waybar/style/[Rainbow] RGB Bordered.css -> config/waybar/style/Rainbow-RGB-Bordered.css
renamed: config/waybar/style/[Retro] Simple Style.css -> config/waybar/style/Retro-Simple-Style.css
renamed: config/waybar/style/[Transparent] Crystal Clear.css -> config/waybar/style/Transparent-Crystal-Clear.css
renamed: config/waybar/style/[VERTICAL] [Catpuccin] Mocha.css -> config/waybar/style/VERTICAL-Catpuccin-Mocha.css
renamed: config/waybar/style/[Wallust Bordered] Chroma Fusion Edge.css -> config/waybar/style/Wallust-Bordered-Chroma-Fusion-Edge.css
renamed: config/waybar/style/[Wallust Bordered] Chroma Simple.css -> config/waybar/style/Wallust-Bordered-Chroma-Simple.css
renamed: config/waybar/style/[Wallust] Box type.css -> config/waybar/style/Wallust-Box-type.css
renamed: config/waybar/style/[Wallust] Chroma Edge.css -> config/waybar/style/Wallust-Chroma-Edge.css
renamed: config/waybar/style/[Wallust] Chroma Fusion.css -> config/waybar/style/Wallust-Chroma-Fusion.css
renamed: config/waybar/style/[Wallust] Chroma Tally V2.css -> config/waybar/style/Wallust-Chroma-Tally-V2.css
renamed: config/waybar/style/[Wallust] Chroma Tally.css -> config/waybar/style/Wallust-Chroma-Tally.css
renamed: config/waybar/style/[Wallust] Colored.css -> config/waybar/style/Wallust-Colored.css
renamed: config/waybar/style/[WALLUST] ML4W-modern-mixed.css -> config/waybar/style/Wallust-ML4W-modern-mixed.css
renamed: config/waybar/style/[WALLUST] ML4W-modern.css -> config/waybar/style/Wallust-ML4W-modern.css
renamed: config/waybar/style/[Wallust] Simple.css -> config/waybar/style/Wallust-Simple.css
renamed: config/waybar/style/[Wallust Transparent] Crystal Clear.css -> config/waybar/style/Wallust-Transparent-Crystal-Clear.css
modified: config/waybar/wallust/colors-waybar.css
modified: copy.sh
renamed: CODE_OF_CONDUCT.es.md -> i18n/CODE_OF_CONDUCT/CODE_OF_CONDUCT.es.md
new file: i18n/CODE_OF_CONDUCT/CODE_OF_CONDUCT.fr.md
renamed: COMMIT_MESSAGE_GUIDELINES.es.md -> i18n/COMMIT_MESSAGE_GUIDELINES/COMMIT_MESSAGE_GUIDELINES.es.md
new file: i18n/COMMIT_MESSAGE_GUIDELINES/COMMIT_MESSAGE_GUIDELINES.fr.md
renamed: CONTRIBUTING.es.md -> i18n/CONTRIBUTING/CONTRIBUTING.es.md
new file: i18n/CONTRIBUTING/CONTRIBUTING.fr.md
renamed: i18n/README.de.md -> i18n/README/README.de.md
new file: i18n/README/README.fr.md
renamed: i18n/README.jp.md -> i18n/README/README.jp.md
renamed: i18n/README.ro.md -> i18n/README/README.ro.md
renamed: i18n/README.ru.md -> i18n/README/README.ru.md
renamed: i18n/README.ua.md -> i18n/README/README.ua.md
modified: scripts/lib_apps.sh
modified: scripts/lib_copy.sh
modified: scripts/lib_prompts.sh
Diffstat (limited to 'config/hypr/scripts/hyprshot.sh')
| -rwxr-xr-x | config/hypr/scripts/hyprshot.sh | 317 |
1 files changed, 317 insertions, 0 deletions
diff --git a/config/hypr/scripts/hyprshot.sh b/config/hypr/scripts/hyprshot.sh new file mode 100755 index 00000000..0fb976fa --- /dev/null +++ b/config/hypr/scripts/hyprshot.sh @@ -0,0 +1,317 @@ +#!/usr/bin/env bash + +set -e + +function Help() { + cat <<EOF +Usage: hyprshot [options ..] [-m [mode] ..] -- [command] + +Hyprshot is an utility to easily take screenshot in Hyprland using your mouse. + +It allows taking screenshots of windows, regions and monitors which are saved to a folder of your choosing and copied to your clipboard. + +Examples: + capture a window \`hyprshot -m window\` + capture active window to clipboard \`hyprshot -m window -m active --clipboard-only\` + capture selected monitor \`hyprshot -m output -m DP-1\` + +Options: + -h, --help show help message + -m, --mode one of: output, window, region, active, OUTPUT_NAME + -o, --output-folder directory in which to save screenshot + -f, --filename the file name of the resulting screenshot + -D, --delay how long to delay taking the screenshot after selection (seconds) + -z, --freeze freeze the screen on initialization + -d, --debug print debug information + -s, --silent don't send notification when screenshot is saved + -r, --raw output raw image data to stdout + -t, --notif-timeout notification timeout in milliseconds (default 5000) + --clipboard-only copy screenshot to clipboard and don't save image in disk + -- [command] open screenshot with a command of your choosing. e.g. hyprshot -m window -- mirage + +Modes: + output take screenshot of an entire monitor + window take screenshot of an open window + region take screenshot of selected region + active take screenshot of active window|output + (you must use --mode again with the intended selection) + OUTPUT_NAME take screenshot of output with OUTPUT_NAME + (you must use --mode again with the intended selection) + (you can get this from \`hyprctl monitors\`) +EOF +} + +function Print() { + if [ $DEBUG -eq 0 ]; then + return 0 + fi + + 1>&2 printf "$@" +} + +function send_notification() { + if [ $SILENT -eq 1 ]; then + return 0 + fi + + local message=$([ $CLIPBOARD -eq 1 ] && \ + echo "Image copied to the clipboard" || \ + echo "Image saved in <i>${1}</i> and copied to the clipboard.") + notify-send "Screenshot saved" \ + "${message}" \ + -t "$NOTIF_TIMEOUT" -i "${1}" -a Hyprshot +} + +function trim() { + Print "Geometry: %s\n" "${1}" + local geometry="${1}" + local xy_str=$(echo "${geometry}" | cut -d' ' -f1) + local wh_str=$(echo "${geometry}" | cut -d' ' -f2) + local x=`echo "${xy_str}" | cut -d',' -f1` + local y=`echo "${xy_str}" | cut -d',' -f2` + local width=`echo "${wh_str}" | cut -dx -f1` + local height=`echo "${wh_str}" | cut -dx -f2` + + local max_width=`hyprctl monitors -j | jq -r '[.[] | if (.transform % 2 == 0) then (.x + .width) else (.x + .height) end] | max'` + local max_height=`hyprctl monitors -j | jq -r '[.[] | if (.transform % 2 == 0) then (.y + .height) else (.y + .width) end] | max'` + + local min_x=`hyprctl monitors -j | jq -r '[.[] | (.x)] | min'` + local min_y=`hyprctl monitors -j | jq -r '[.[] | (.y)] | min'` + + local cropped_x=$x + local cropped_y=$y + local cropped_width=$width + local cropped_height=$height + + if ((x + width > max_width)); then + cropped_width=$((max_width - x)) + fi + if ((y + height > max_height)); then + cropped_height=$((max_height - y)) + fi + + if ((x < min_x)); then + cropped_x="$min_x" + cropped_width=$((cropped_width + x - min_x)) + fi + if ((y < min_y)); then + cropped_y="$min_y" + cropped_height=$((cropped_height + y - min_y)) + fi + + local cropped=`printf "%s,%s %sx%s\n" \ + "${cropped_x}" "${cropped_y}" \ + "${cropped_width}" "${cropped_height}"` + Print "Crop: %s\n" "${cropped}" + echo ${cropped} +} + +function save_geometry() { + local geometry="${1}" + local output="" + + if [ $RAW -eq 1 ]; then + grim -g "${geometry}" - + return 0 + fi + + if [ $CLIPBOARD -eq 0 ]; then + mkdir -p "$SAVEDIR" + grim -g "${geometry}" "$SAVE_FULLPATH" + output="$SAVE_FULLPATH" + wl-copy --type image/png < "$output" + [ -z "$COMMAND" ] || { + "$COMMAND" "$output" + } + else + wl-copy --type image/png < <(grim -g "${geometry}" -) + fi + + send_notification $output +} + +function checkRunning() { + sleep 1 + while [[ 1 == 1 ]]; do + if [[ $(pgrep slurp | wc -m) == 0 ]]; then + pkill hyprpicker + exit + fi + done +} + +function begin_grab() { + if [ $FREEZE -eq 1 ] && [ "$(command -v "hyprpicker")" ] >/dev/null 2>&1; then + hyprpicker -r -z & + sleep 0.2 + HYPRPICKER_PID=$! + fi + local option=$1 + case $option in + output) + if [ $CURRENT -eq 1 ]; then + local geometry=`grab_active_output` + elif [ -z $SELECTED_MONITOR ]; then + local geometry=`grab_output` + else + local geometry=`grab_selected_output $SELECTED_MONITOR` + fi + ;; + region) + local geometry=`grab_region` + ;; + window) + if [ $CURRENT -eq 1 ]; then + local geometry=`grab_active_window` + else + local geometry=`grab_window` + fi + geometry=`trim "${geometry}"` + ;; + esac + if [ ${DELAY} -gt 0 ] 2>/dev/null; then + sleep ${DELAY} + fi + save_geometry "${geometry}" +} + +function grab_output() { + slurp -or +} + +function grab_active_output() { + local active_workspace=`hyprctl -j activeworkspace` + local monitors=`hyprctl -j monitors` + Print "Monitors: %s\n" "$monitors" + Print "Active workspace: %s\n" "$active_workspace" + local current_monitor="$(echo $monitors | jq -r 'first(.[] | select(.activeWorkspace.id == '$(echo $active_workspace | jq -r '.id')'))')" + Print "Current output: %s\n" "$current_monitor" + echo $current_monitor | jq -r '"\(.x),\(.y) \(.width/.scale|round)x\(.height/.scale|round)"' +} + +function grab_selected_output() { + local monitor=`hyprctl -j monitors | jq -r '.[] | select(.name == "'$(echo $1)'")'` + Print "Capturing: %s\n" "${1}" + echo $monitor | jq -r '"\(.x),\(.y) \(.width/.scale|round)x\(.height/.scale|round)"' +} + +function grab_region() { + slurp -d +} + +function grab_window() { + local monitors=`hyprctl -j monitors` + local clients=`hyprctl -j clients | jq -r '[.[] | select(.workspace.id | contains('$(echo $monitors | jq -r 'map(.activeWorkspace.id) | join(",")')'))]'` + Print "Monitors: %s\n" "$monitors" + Print "Clients: %s\n" "$clients" + # Generate boxes for each visible window and send that to slurp + # through stdin + local boxes="$(echo $clients | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1]) \(.title)"' | cut -f1,2 -d' ')" + Print "Boxes:\n%s\n" "$boxes" + slurp -r <<< "$boxes" +} + +function grab_active_window() { + local active_window=`hyprctl -j activewindow` + local box=$(echo $active_window | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"' | cut -f1,2 -d' ') + Print "Box:\n%s\n" "$box" + echo "$box" +} + +function parse_mode() { + local mode="${1}" + + case $mode in + window | region | output) + OPTION=$mode + ;; + active) + CURRENT=1 + ;; + *) + hyprctl monitors -j | jq -re '.[] | select(.name == "'$(echo $mode)'")' &>/dev/null + SELECTED_MONITOR=$mode + ;; + esac +} + +function args() { + local options=$(getopt -o hf:o:m:D:dszr:t: --long help,filename:,output-folder:,mode:,delay:,clipboard-only,debug,silent,freeze,raw,notif-timeout: -- "$@") + eval set -- "$options" + + while true; do + case "$1" in + -h | --help) + Help + exit + ;; + -o | --output-folder) + shift; + SAVEDIR=$1 + ;; + -f | --filename) + shift; + FILENAME=$1 + ;; + -D | --delay) + shift; + DELAY=$1 + ;; + -m | --mode) + shift; + parse_mode $1 + ;; + --clipboard-only) + CLIPBOARD=1 + ;; + -d | --debug) + DEBUG=1 + ;; + -z | --freeze) + FREEZE=1 + ;; + -s | --silent) + SILENT=1 + ;; + -r | --raw) + RAW=1 + ;; + -t | --notif-timeout) + shift; + NOTIF_TIMEOUT=$1 + ;; + --) + shift # Skip -- argument + COMMAND=${@:2} + break;; + esac + shift + done + + if [ -z $OPTION ]; then + Print "A mode is required\n\nAvailable modes are:\n\toutput\n\tregion\n\twindow\n" + exit 2 + fi +} + +if [ -z $1 ]; then + Help + exit +fi + +CLIPBOARD=0 +DEBUG=0 +SILENT=0 +RAW=0 +NOTIF_TIMEOUT=5000 +CURRENT=0 +FREEZE=0 +[ -z "$XDG_PICTURES_DIR" ] && type xdg-user-dir &> /dev/null && XDG_PICTURES_DIR=$(xdg-user-dir PICTURES) +FILENAME="$(date +'%Y-%m-%d-%H%M%S_hyprshot.png')" +[ -z "$HYPRSHOT_DIR" ] && SAVEDIR=${XDG_PICTURES_DIR:=~} || SAVEDIR=${HYPRSHOT_DIR} + +args $0 "$@" + +SAVE_FULLPATH="$SAVEDIR/$FILENAME" +[ $CLIPBOARD -eq 0 ] && Print "Saving in: %s\n" "$SAVE_FULLPATH" +begin_grab $OPTION & checkRunning |
