Skip to content

Instantly share code, notes, and snippets.

@KargJonas
Last active March 25, 2024 12:40
Show Gist options
  • Select an option

  • Save KargJonas/62fe078683f99421360159db47f2902e to your computer and use it in GitHub Desktop.

Select an option

Save KargJonas/62fe078683f99421360159db47f2902e to your computer and use it in GitHub Desktop.
### all of these bind the "print" key to take screenshots with slection area using scrot
# use datetime as filename
bindsym --release Print exec --no-startup-id scrot $HOME/Pictures/Screenshots/`date +%Y-%m-%d_%H:%M:%S`.png --select
# ask for filename using dmenu and fall back to datetime if no name provided
bindsym --release Print exec --no-startup-id $HOME/bin/take_screenshot.sh $HOME/Pictures/Screenshots
### take_screenshot.sh
#!/bin/bash
if [ -z $1 ]; then
exit 1
fi
# preliminary filename from datetime
filename="$1/$(date +%Y-%m-%d_%H:%M:%S).png"
# take screenshot
scrot $filename --select
# ask use for custom filename
custom_filename="$1/$(dmenu -p 'Enter file name (optional):').png"
# rename file to custom name if user entered something
if [ -n "$custom_filename" ]; then
echo "test" >> /home/jonas/Pictures/Screenshots/test.txt
mv $filename $custom_filename
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment