Skip to content

Commit e668726

Browse files
committed
feat: added silent arg
1 parent 5d65f15 commit e668726

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

hyprshot

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Options:
1616
-o, --output-folder directory in which to save screenshot
1717
-f, --filename the file name of the resulting screenshot
1818
-d, --debug print debug information
19+
-s, --silent don't send notification when screenshot is saved
1920
--clipboard-only copy screenshot to clipboard and don't save image in disk
2021
-- [command] open screenshot with a command of your choosing. e.g. hyprshot -m window -- mirage
2122
@@ -30,6 +31,14 @@ function Print() {
3031
[ $DEBUG -eq 1 ] && printf "$@" >&2
3132
}
3233

34+
function send_notification() {
35+
[ $SILENT -eq 0 ] && {
36+
notify-send "Screenshot saved" \
37+
"Image saved in <i>${1}</i> and copied to the clipboard." \
38+
-i "${1}"
39+
}
40+
}
41+
3342
function save_geometry() {
3443
[ -z "${1}" ] && Print "no geometry\n" && exit 1;
3544

@@ -41,9 +50,7 @@ function save_geometry() {
4150
# outside the monitor
4251
convert $output -trim +repage $output
4352
wl-copy < "$output"
44-
notify-send "Screenshot saved" \
45-
"Image saved in <i>$output</i> and copied to the clipboard." \
46-
-i "$output"
53+
send_notification $output
4754
[ -z "$COMMAND" ] || {
4855
"$COMMAND" "$output"
4956
}
@@ -81,7 +88,7 @@ function grab_window() {
8188
}
8289

8390
function args() {
84-
local options=$(getopt -o hf:o:m:d --long help,filename:,output-folder:,mode:,clipboard-only,debug -- "$@")
91+
local options=$(getopt -o hf:o:m:ds --long help,filename:,output-folder:,mode:,clipboard-only,debug,silent -- "$@")
8592
[ $? -eq 0 ] || {
8693
Print "Invalid option provided\n"
8794
exit 2
@@ -116,6 +123,9 @@ function args() {
116123
-d | --debug)
117124
DEBUG=1
118125
;;
126+
-s | --silent)
127+
SILENT=1
128+
;;
119129
--)
120130
shift # Skip -- argument
121131
COMMAND=${@:2}
@@ -137,6 +147,7 @@ function args() {
137147

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

0 commit comments

Comments
 (0)