feat(hypr): add new hyprshot options

code extracted from https://github.com/Gustash/Hyprshot/pull/68
This commit is contained in:
Sergio Laín 2024-09-20 14:53:22 +02:00
parent 78ff7b3010
commit 0b328fb64d
No known key found for this signature in database
GPG key ID: 8429B2EE312F8150

View file

@ -26,6 +26,9 @@ Options:
-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)
--border-width width of the selection border in pixels (default 0)
--border-color color of the selection border (default #181926)
--background-color color around the selection (default #8087a25a)
--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
@ -150,6 +153,7 @@ function checkRunning() {
function begin_grab() {
if [ $FREEZE -eq 1 ] && [ "$(command -v "hyprpicker")" ] >/dev/null 2>&1; then
sleep 0.2
hyprpicker -r -z &
sleep 0.2
HYPRPICKER_PID=$!
@ -204,7 +208,7 @@ function grab_selected_output() {
}
function grab_region() {
slurp -d
slurp -d -b $BACKGROUND_COLOR -c $BORDER_COLOR -w $BORDER_WIDTH
}
function grab_window() {
@ -216,7 +220,7 @@ function grab_window() {
# 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"
slurp -r -b $BACKGROUND_COLOR -c $BORDER_COLOR -w $BORDER_WIDTH <<<"$boxes"
}
function grab_active_window() {
@ -244,7 +248,7 @@ function parse_mode() {
}
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: -- "$@")
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:,border-color:,background-color:,border-width: -- "$@")
eval set -- "$options"
while true; do
@ -288,6 +292,18 @@ function args() {
shift
NOTIF_TIMEOUT=$1
;;
--border-color)
shift
BORDER_COLOR=$1
;;
--background-color)
shift
BACKGROUND_COLOR=$1
;;
--border-width)
shift
BORDER_WIDTH=$1
;;
--)
shift # Skip -- argument
COMMAND=${@:2}
@ -315,6 +331,9 @@ RAW=0
NOTIF_TIMEOUT=5000
CURRENT=0
FREEZE=0
BORDER_COLOR=\#181926
BACKGROUND_COLOR=\#8087a25a
BORDER_WIDTH=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}