From 7fdd733b1369346a28a2a9ab6c715a971c0ba440 Mon Sep 17 00:00:00 2001 From: Simon Cornet Date: Mon, 25 Mar 2024 13:51:31 +0100 Subject: [PATCH] [screenshot] improved --- apps/screenshot/screenshot.sh | 76 +++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 25 deletions(-) diff --git a/apps/screenshot/screenshot.sh b/apps/screenshot/screenshot.sh index a1d1fb9..2a8f113 100755 --- a/apps/screenshot/screenshot.sh +++ b/apps/screenshot/screenshot.sh @@ -1,35 +1,61 @@ -#!/usr/bin/env zsh +#!/usr/bin/env bash -# screenshot function for an area -screenshot_area () { - grimblast \ - --notify save area - | \ - satty \ - --filename - \ - --fullscreen \ - --output-filename ~/Pictures/Screenshots/satty-$(date '+%Y%m%d-%H:%M:%S').png +# commands +wofi_command="wofi -l 5" +grimblast="grimblast --notify" +satty="satty --filename - --fullscreen --output-filename ~/Pictures/Screenshots/satty-$(date '+%Y%m%d-%H:%M:%S').png" + + +# buttons +area="🖥️ Capture area" +infive="🖥️ Capture area in 5 seconds" +inten="🖥️ Capture area in 10 seconds" +screen="🖥️ Capture whole screen" +window="🖥️ Capture active window" + + +# take shots +screenshot_area() { + $grimblast save area - | $satty } -# screenshot function for full screen -screenshot_screen () { - grimblast \ - --notify save screen - | \ - satty \ - --filename - \ - --fullscreen \ - --output-filename ~/Pictures/Screenshots/satty-$(date '+%Y%m%d-%H:%M:%S').png +screenshot_window() { + $grimblast save active - | $satty } -# main function -case $1 in - area) +screenshot_full_now() { + $grimblast save screen - | $satty +} + +screenshot_full_5() { + sleep 5 + $grimblast save screen - | $satty +} + +screenshot_full_10() { + sleep 10 + $grimblast save screen - | $satty +} + + +# start wofi +options="$area\n$infive\n$inten\n$screen\n$window" +chosen="$(echo -e "$options" | $wofi_command -p 'Say cheese ...' -dmenu --no-action --width=400 --height=302 -selected-row 0 --style=/home/simon/.dotfiles/apps/wofi/style.css)" +sleep 1 +case $chosen in + $area) screenshot_area ;; - screen) - screenshot_screen + $infive) + screenshot_full_5 ;; - *) - echo "Usage: $0 {area|screen}" - exit 1 + $inten) + screenshot_full_10 + ;; + $screen) + screenshot_full_now + ;; + $window) + screenshot_window ;; esac