summaryrefslogtreecommitdiff
path: root/screenshots.sh
blob: 73b64f6722da16e79f712fc4e7e83ac4d66de0c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

# Wal colors dmenu
. "${HOME}/.cache/wal/colors.sh"

# Alias dmenu
alias give_to_dmenu='dmenu -c -nf "$color15" -nb "$color0" -sb "$color3" -sf "$color15" -fn "Iosevka-11"'

# Vars
number_of_displays=$(xrandr | grep " connected" | wc -l)
main_menu_selection=$(printf "Fullscreen\nRegion" | give_to_dmenu -l 2 -p Capture:)

# Menu
case $main_menu_selection in
    "Fullscreen")
    display_selection=$(xrandr | grep " connected" | awk '{print $1}' | give_to_dmenu -l $number_of_displays -p Display:)
    screenshot_res=$(xrandr | grep "$display_selection" | grep -o '[[:digit:]]\+x[[:digit:]]\++[[:digit:]]\++[[:digit:]]\+')
    screenshot_name=$(: | give_to_dmenu -p Name:)
    maim -g $screenshot_res -d 1 ~/stf/ss/"$screenshot_name.png" && dunstify " Screenshot taken" || dunstify "ERROR: Screenshot not taken"
    ;;
    "Region")
    destination_selection=$(printf "SS\nShitposter" | give_to_dmenu -l 2 -p Destination:)
    screenshot_name=$(echo "" | give_to_dmenu -p Name:)
    [[ $destination_selection == SS ]] && destination=$SS_DIR || destination=$SHIT_DIR
    maim -d 1 -s $destination/"$screenshot_name.png" && dunstify " Region screenshot taken" || dunstify "ERROR: Screenshot not taken"
    ;;
esac