Skip to content

Commit

Permalink
Add rofi-screenshot-menu & screenshot utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
Wrench56 committed Jul 17, 2023
1 parent 1043b82 commit 45c1b91
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
1 change: 1 addition & 0 deletions dunst/dunst-icons/screenshot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion i3/config
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,7 @@ for_window [class="fm"] floating enable
for_window [class="fm"] resize set 960 640
for_window [class="fm"] move scratchpad
for_window [class="fm"] border pixel 3
exec --no-startup-id alacritty --class fm,fm -e mc
exec --no-startup-id alacritty --class fm,fm -e mc

# Screenshot
bindsym $mod+Shift+s exec --no-startup-id ~/.local/bin/rofi/rofi-screenshot-menu
56 changes: 56 additions & 0 deletions rofi/menus/rofi-screenshot-menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh

# Take a screenshot

DEFAULT_FOLDER="$HOME/screenshots"

save() {
SAVEAS=$(printf "Copy to clipboard\nOverwrite screenshot.png\nDon't save" | rofi -dmenu -p "Save as: " -lines 3)
case $SAVEAS in
# Default: Copy to clipboard
"" | "Copy to clipboard")
xclip -selection c < /tmp/temp-screenshot.png
;;
"Overwrite screenshot.png")
cp /tmp/temp-screenshot.png "$DEFAULT_FOLDER"/screenshot.png
notify-send -u low -i "screenshot" "Screenshot taken" "Saved as ${DEFAULT_FOLDER}/screenshot.png"
;;
"Don't save")
exit
;;
*)
if [ "$(echo "$SAVEAS" | tail -c 5)" != ".png" ]
then
cp /tmp/temp-screenshot.png "$DEFAULT_FOLDER"/"$SAVEAS".png
notify-send -u low -i "screenshot" "Screenshot taken" "Saved as ${DEFAULT_FOLDER}/${SAVEAS}.png"
else
cp /tmp/temp-screenshot.png "$DEFAULT_FOLDER"/"$SAVEAS"
notify-send -u low -i "screenshot" "Screenshot taken" "Saved as ${DEFAULT_FOLDER}/${SAVEAS}"
fi
;;
esac
}


OPTION=$(printf "Cursor select\nCurrent window\nAll screens\nClose" | rofi -dmenu -p "Select an option: " -lines 4)
case $OPTION in
# Default: Cursor select
"" | "Cursor select")
maim -s /tmp/temp-screenshot.png
;;
"Current window")
maim -i "$(xdotool getactivewindow)" /tmp/temp-screenshot.png
;;
"All screens")
maim /tmp/temp-screenshot.png
;;
"Close")
exit 0
;;
*)
echo "Error"; exit 1
;;
esac

# Save the screenshot
save
3 changes: 3 additions & 0 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ sudo pacman -S --noconfirm mc
# Download Firefox
sudo pacman -S --noconfirm firefox

# Download maim (snipping tool)
sudo pacman -S --noconfirm maim xdotool

# System update
sudo pacman -Syu --noconfirm

Expand Down

0 comments on commit 45c1b91

Please sign in to comment.