Skip to content

Commit

Permalink
feat: added silent arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustash committed Nov 10, 2022
1 parent 5d65f15 commit e668726
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions hyprshot
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Options:
-o, --output-folder directory in which to save screenshot
-f, --filename the file name of the resulting screenshot
-d, --debug print debug information
-s, --silent don't send notification when screenshot is saved
--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
Expand All @@ -30,6 +31,14 @@ function Print() {
[ $DEBUG -eq 1 ] && printf "$@" >&2
}

function send_notification() {
[ $SILENT -eq 0 ] && {
notify-send "Screenshot saved" \
"Image saved in <i>${1}</i> and copied to the clipboard." \
-i "${1}"
}
}

function save_geometry() {
[ -z "${1}" ] && Print "no geometry\n" && exit 1;

Expand All @@ -41,9 +50,7 @@ function save_geometry() {
# outside the monitor
convert $output -trim +repage $output
wl-copy < "$output"
notify-send "Screenshot saved" \
"Image saved in <i>$output</i> and copied to the clipboard." \
-i "$output"
send_notification $output
[ -z "$COMMAND" ] || {
"$COMMAND" "$output"
}
Expand Down Expand Up @@ -81,7 +88,7 @@ function grab_window() {
}

function args() {
local options=$(getopt -o hf:o:m:d --long help,filename:,output-folder:,mode:,clipboard-only,debug -- "$@")
local options=$(getopt -o hf:o:m:ds --long help,filename:,output-folder:,mode:,clipboard-only,debug,silent -- "$@")
[ $? -eq 0 ] || {
Print "Invalid option provided\n"
exit 2
Expand Down Expand Up @@ -116,6 +123,9 @@ function args() {
-d | --debug)
DEBUG=1
;;
-s | --silent)
SILENT=1
;;
--)
shift # Skip -- argument
COMMAND=${@:2}
Expand All @@ -137,6 +147,7 @@ function args() {

CLIPBOARD=0
DEBUG=0
SILENT=0
FILENAME="$(date +'%Y-%m-%d-%H%M%S_hyprshot.png')"
[ -z "$HYPRSHOT_DIR" ] && SAVEDIR=${XDG_PICTURES_DIR:=~} || SAVEDIR=${HYPRSHOT_DIR}

Expand Down

0 comments on commit e668726

Please sign in to comment.