2023-02-22 00:02:06 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-04-27 22:58:55 +00:00
|
|
|
# ***This script was made by Clay Gomera (Drake)***
|
|
|
|
# - Description: A simple screenshot menu rofi script
|
|
|
|
# - Dependencies: rofi, grim, slurp, wf-recorder
|
|
|
|
#
|
|
|
|
|
|
|
|
# screenshot directory
|
|
|
|
scrdir="$HOME/Pictures/Screenshots"
|
|
|
|
mkdir -p "$scrdir"
|
|
|
|
cd "$scrdir" || exit 1
|
|
|
|
filename=$(date "+%d-%m-%Y_%H:%M:%S")
|
|
|
|
|
|
|
|
# options array
|
|
|
|
option1=" Capture the screen"
|
|
|
|
option2=" Capture region"
|
|
|
|
option3=" Record the screen"
|
|
|
|
option4=" Record region"
|
|
|
|
option5=" Record the screen and audio"
|
|
|
|
option6="Exit"
|
|
|
|
options="$option1\n$option2\n$option3\n$option4\n$option5\n$option6"
|
|
|
|
|
|
|
|
# countdown function
|
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
|
|
|
}
|
|
|
|
|
2023-04-27 22:58:55 +00:00
|
|
|
# show the help output with --help or -h arguments
|
|
|
|
if [[ $1 == '--help' ]] || [[ $1 = '-h' ]]
|
2023-02-22 00:02:06 +00:00
|
|
|
then
|
2023-04-27 22:58:55 +00:00
|
|
|
echo ### rofi-screenshot
|
|
|
|
echo USAGE: rofi-screenshot [OPTION]
|
|
|
|
echo \(no option\)
|
|
|
|
echo " show the screenshot menu"
|
|
|
|
echo -s, --stop
|
|
|
|
echo " stop recording"
|
|
|
|
echo -h, --help
|
|
|
|
echo " this screen"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# stop recording with -s or --stop arguments
|
|
|
|
if [[ $1 = '--stop' ]] || [[ $1 = '-s' ]]
|
|
|
|
then
|
|
|
|
killall -s SIGINT wf-recorder
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# run the selected command
|
|
|
|
choice=$(echo -e "$options" | rofi -dmenu -p " Screenshot " )
|
|
|
|
case $choice in
|
|
|
|
$option1)
|
|
|
|
countdown
|
|
|
|
grim "$filename.jpg"
|
|
|
|
notify-send "Screenshot" "Screenshot saved to $scrdir"
|
|
|
|
;;
|
|
|
|
$option2)
|
|
|
|
notify-send "Screenshot" "Select a region to capture"
|
|
|
|
grim -g "$(slurp)" "$filename.jpg"
|
|
|
|
notify-send "Screenshot" "Region saved to $scrdir"
|
|
|
|
;;
|
|
|
|
$option3)
|
|
|
|
countdown
|
|
|
|
wf-recorder --codec=h264_vaapi -d /dev/dri/renderD128 -f "$filename.mp4"
|
|
|
|
notify-send "Screenshot" "Recording saved to $scrdir"
|
|
|
|
;;
|
|
|
|
$option4)
|
|
|
|
notify-send "Screenshot" "Select a region to record"
|
|
|
|
wf-recorder --codec=h264_vaapi -d /dev/dri/renderD128 -g "$(slurp)" -f "$filename.mp4"
|
|
|
|
notify-send "Screenshot" "Recording saved to $scrdir"
|
|
|
|
;;
|
|
|
|
$option5)
|
|
|
|
devices=$(pactl list sources | grep "Name" | awk '{print $2}')
|
|
|
|
chosendevice=$(echo -e "$devices" | rofi -dmenu -p " Select audio input ")
|
|
|
|
if [ "$chosendevice" ]; then
|
|
|
|
device="$chosendevice"
|
|
|
|
countdown
|
|
|
|
wf-recorder --audio="$device" --codec=h264_vaapi -d /dev/dri/renderD128 -f "$filename.mp4"
|
|
|
|
else
|
|
|
|
notify-send "Please select an audio input device"
|
2023-02-22 00:02:06 +00:00
|
|
|
exit 1
|
2023-04-27 22:58:55 +00:00
|
|
|
fi
|
|
|
|
notify-send "Screenshot" "Recording saved to $scrdir"
|
|
|
|
;;
|
|
|
|
$option6)
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|