2023-02-22 00:02:06 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Screenshot directory
|
|
|
|
screenshot_directory="$HOME/Pictures/Screenshots"
|
2023-02-25 20:58:19 +00:00
|
|
|
mkdir -p $screenshot_directory
|
2023-02-22 00:02:06 +00:00
|
|
|
|
|
|
|
countdown() {
|
2023-02-25 16:12:09 +00:00
|
|
|
notify-send "Screenshot" "Executing in 3 seconds" -t 1000
|
2023-02-22 00:02:06 +00:00
|
|
|
sleep 1
|
2023-02-25 16:12:09 +00:00
|
|
|
notify-send "Screenshot" "Executing in 2 seconds" -t 1000
|
2023-02-22 00:02:06 +00:00
|
|
|
sleep 1
|
2023-02-25 16:12:09 +00:00
|
|
|
notify-send "Screenshot" "Executing in 1 seconds" -t 1000
|
|
|
|
sleep 2
|
2023-02-22 00:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
crtf() {
|
|
|
|
notify-send "Screenshot" "Select a region to capture"
|
|
|
|
dt=$(date '+%d-%m-%Y %H:%M:%S')
|
|
|
|
grim -g "$(slurp)" "$screenshot_directory/$dt.png"
|
|
|
|
notify-send "Screenshot" "Region saved to $screenshot_directory"
|
|
|
|
}
|
|
|
|
|
|
|
|
cstf() {
|
2023-02-22 02:09:45 +00:00
|
|
|
countdown
|
2023-02-22 00:02:06 +00:00
|
|
|
dt=$(date '+%d-%m-%Y %H:%M:%S')
|
|
|
|
grim "$screenshot_directory/$dt.png"
|
|
|
|
notify-send "Screenshot" "Screenshot saved to $screenshot_directory"
|
|
|
|
}
|
|
|
|
|
|
|
|
rvrtf() {
|
|
|
|
notify-send "Screenshot" "Select a region to record"
|
|
|
|
dt=$(date '+%d-%m-%Y %H:%M:%S')
|
|
|
|
wf-recorder -g "$(slurp)" rec "$screenshot_directory/$dt.mp4"
|
|
|
|
notify-send "Screenshot" "Recording saved to $screenshot_directory"
|
|
|
|
}
|
|
|
|
|
|
|
|
rvstf() {
|
|
|
|
countdown
|
|
|
|
dt=$(date '+%d-%m-%Y %H:%M:%S')
|
|
|
|
wf-recorder -f "$screenshot_directory/$dt.mp4"
|
|
|
|
notify-send "Screenshot" "Recording saved to $screenshot_directory"
|
|
|
|
}
|
|
|
|
|
|
|
|
get_options() {
|
2023-02-22 02:09:45 +00:00
|
|
|
echo " Capture Region"
|
|
|
|
echo " Capture Screen"
|
|
|
|
echo " Record Region"
|
|
|
|
echo " Record Screen"
|
2023-02-22 00:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
check_deps() {
|
|
|
|
if ! hash $1 2>/dev/null; then
|
|
|
|
echo "Error: This script requires $1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
# check dependencies
|
|
|
|
check_deps slurp
|
|
|
|
check_deps grim
|
2023-02-22 02:09:45 +00:00
|
|
|
check_deps rofi
|
2023-02-22 00:02:06 +00:00
|
|
|
check_deps wf-recorder
|
|
|
|
|
|
|
|
if [[ $1 == '--help' ]] || [[ $1 = '-h' ]]
|
|
|
|
then
|
2023-02-22 02:09:45 +00:00
|
|
|
echo ### rofi-screenshot
|
|
|
|
echo USAGE: rofi-screenshot [OPTION]
|
2023-02-22 00:02:06 +00:00
|
|
|
echo \(no option\)
|
|
|
|
echo " show the screenshot menu"
|
|
|
|
echo -s, --stop
|
|
|
|
echo " stop recording"
|
|
|
|
echo -h, --help
|
|
|
|
echo " this screen"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $1 = '--stop' ]] || [[ $1 = '-s' ]]
|
|
|
|
then
|
|
|
|
killall -s SIGINT wf-recorder
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Get choice from rofi
|
2023-02-22 02:09:45 +00:00
|
|
|
choice=$( (get_options) | rofi -dmenu -p " Screenshot " )
|
2023-02-22 00:02:06 +00:00
|
|
|
|
|
|
|
# If user has not picked anything, exit
|
|
|
|
if [[ -z "${choice// }" ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# run the selected command
|
|
|
|
case $choice in
|
2023-02-22 02:09:45 +00:00
|
|
|
' Capture Region')
|
2023-02-22 00:02:06 +00:00
|
|
|
crtf
|
|
|
|
;;
|
2023-02-22 02:09:45 +00:00
|
|
|
' Capture Screen')
|
2023-02-22 00:02:06 +00:00
|
|
|
cstf
|
|
|
|
;;
|
2023-02-22 02:09:45 +00:00
|
|
|
' Record Region')
|
2023-02-22 00:02:06 +00:00
|
|
|
rvrtf
|
|
|
|
;;
|
2023-02-22 02:09:45 +00:00
|
|
|
' Record Screen')
|
2023-02-22 00:02:06 +00:00
|
|
|
rvstf
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# done
|
|
|
|
set -e
|
|
|
|
}
|
|
|
|
|
|
|
|
main $1 &
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
!/bin/bash
|