-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rofi-screenshot-menu & screenshot utilities
- Loading branch information
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/sh | ||
|
||
# Take a screenshot | ||
|
||
DEFAULT_FOLDER="$HOME/screenshots" | ||
|
||
save() { | ||
SAVEAS=$(printf "Copy to clipboard\nOverwrite screenshot.png\nDon't save" | rofi -dmenu -p "Save as: " -lines 3) | ||
case $SAVEAS in | ||
# Default: Copy to clipboard | ||
"" | "Copy to clipboard") | ||
xclip -selection c < /tmp/temp-screenshot.png | ||
;; | ||
"Overwrite screenshot.png") | ||
cp /tmp/temp-screenshot.png "$DEFAULT_FOLDER"/screenshot.png | ||
notify-send -u low -i "screenshot" "Screenshot taken" "Saved as ${DEFAULT_FOLDER}/screenshot.png" | ||
;; | ||
"Don't save") | ||
exit | ||
;; | ||
*) | ||
if [ "$(echo "$SAVEAS" | tail -c 5)" != ".png" ] | ||
then | ||
cp /tmp/temp-screenshot.png "$DEFAULT_FOLDER"/"$SAVEAS".png | ||
notify-send -u low -i "screenshot" "Screenshot taken" "Saved as ${DEFAULT_FOLDER}/${SAVEAS}.png" | ||
else | ||
cp /tmp/temp-screenshot.png "$DEFAULT_FOLDER"/"$SAVEAS" | ||
notify-send -u low -i "screenshot" "Screenshot taken" "Saved as ${DEFAULT_FOLDER}/${SAVEAS}" | ||
fi | ||
;; | ||
esac | ||
} | ||
|
||
|
||
OPTION=$(printf "Cursor select\nCurrent window\nAll screens\nClose" | rofi -dmenu -p "Select an option: " -lines 4) | ||
case $OPTION in | ||
# Default: Cursor select | ||
"" | "Cursor select") | ||
maim -s /tmp/temp-screenshot.png | ||
;; | ||
"Current window") | ||
maim -i "$(xdotool getactivewindow)" /tmp/temp-screenshot.png | ||
;; | ||
"All screens") | ||
maim /tmp/temp-screenshot.png | ||
;; | ||
"Close") | ||
exit 0 | ||
;; | ||
*) | ||
echo "Error"; exit 1 | ||
;; | ||
esac | ||
|
||
# Save the screenshot | ||
save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters