diff --git a/README.md b/README.md index 5c640ec..754364e 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ - `qutebrowser_search.sh`: script that finds all the search engines defined in the qutebrowser `config.py` configuration file and makes them available for searching via dmenu, i.e. allow web searching with qutebrowser without having to wait for it to start up before you start your search. - `repos_checker.sh`: script to find all of the Git repositories in the current directory & its sub-directories and display each found repository's `git status`. + - `screenshot.sh`: screenshot script for both Xorg and Wayland with selection that both saves the image file and adds the image to the clipboard, and notifies the user via `notify-send`. - `stdin_to_notis.sh`: scripts that reads from `stdin` and sends each line as a system notification. Intended for use when a program that outputs to `stdout` is called from a non-terminal or graphical program, making the `stdout` output inaccessible. The output can instead be piped into this script to make it readable as a system notification. @@ -35,8 +36,6 @@ laptop to my phone. - `webcam.sh`: one-line script that uses the video viewer program `mpv` as a webcam by using `/dev/video0` as its video file source. - `wifi_dmenu.sh`: script to connect to an available WiFi network with a dmenu prompt. - - `wl_screenshot.sh`: screenshot script for Wayland with selection using `grim` & `slurp` that both saves the image file and adds the image to the `wl-copy` clipboard, and notifies the user of the screenshot via `notify-send`. - `wl_vimshot.sh`: Wayland script to take a wait a few seconds before taking a screenshot to the filepath in the clipboard, for use as part of my LaTeX note-taking workflow in Vim: create the figure environment, copy the file name, invoke this script, and select the region in the source material to be screenshotted. - - `x11_screenshot.sh`: screenshot script for X11 with selection using `maim` that both saves the image file and adds the image to the `xclip` clipboard, and notifies the user of the screenshot via `notify-send`. - `x11_vimshot.sh`: X11 script to take a wait a few seconds before taking a screenshot to the filepath in the clipboard, for use as part of my LaTeX note-taking workflow in Vim: create the figure environment, copy the file name, invoke this script, and select the region in the source material to be screenshotted. diff --git a/src/wl_screenshot.sh b/src/screenshot.sh similarity index 62% rename from src/wl_screenshot.sh rename to src/screenshot.sh index 6d83e1f..98b64ec 100755 --- a/src/wl_screenshot.sh +++ b/src/screenshot.sh @@ -1,8 +1,13 @@ #!/bin/sh -# Screenshot script with selection using grim and slurp. -# +# Script to take a selection screenshot on both Xorg and Wayland + filepath="$HOME/media/images/screenshots/$(date +%Y-%m-%d\ %H:%M:%S).png" -grim -g "$(slurp)" - | tee "$filepath" | wl-copy + +if [ $(pgrep -x "Xorg") ]; then + maim --select --hidecursor | tee "$filepath" | xclip -selection clipboard -target image/png +else + grim -g "$(slurp)" - | tee "$filepath" | wl-copy +fi # if screenshot is cancelled, tee will create an empty file, so checking if the file is empty if [ -s "$filepath" ]; then diff --git a/src/x11_screenshot.sh b/src/x11_screenshot.sh deleted file mode 100755 index 61a19bd..0000000 --- a/src/x11_screenshot.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -# Screenshot script with selection using maim and notification. -filepath="$HOME/media/images/screenshots/$(date +%Y-%m-%d\ %H:%M:%S).png" -maim --select --hidecursor | tee "$filepath" | xclip -selection clipboard -target image/png - -# if maim is cancelled, tee will create an empty file, so checking if the file is empty -if [ -s "$filepath" ]; then - # send notification with a thumbnail of the screenshot taken, the name of the script, and the filepath - notify-send --icon "$filepath" "$(basename "$0")" "Screenshot saved to: $filepath" -else - rm "$filepath" -fi