Skip to content

Commit

Permalink
feat (Hyde show screencap): Internal fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kRHYME7 committed Jun 27, 2024
1 parent 28f6da1 commit 1903d08
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Hyde
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ run() { #? Executable utilities
--record-focus ? Record focused monitor
--print-snip ? Drag to manually snip an area
--record-snip ? Drag to manually snip an area to screen record it
-freeze ? Frozen screen, drag to manually snip an area
--freeze ? Frozen screen, drag to manually snip an area
--print-monitor ? Print focused monitor
--scan ? Use 'tesseract' to scan image then add to clipboard
--stop ? Stop every instance of Screencap
Expand Down
50 changes: 29 additions & 21 deletions Scripts/Run-Screencap
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/env bash

#TODO revise this to not use grimblast
enable_package grimblast swappy

if [ -z "${XDG_PICTURES_DIR}" ]; then
Expand All @@ -19,7 +20,7 @@ STOP() {

#variables
OPTION="${1}"
PASS="${@:2}"
PASS="${*:2}"
logFile="${HYDE_RUNTIME_DIR}/screencap.log"
cacheFile="${cacheDir}/screecap.meta"
vid_dir="${XDG_VIDEOS_DIR}/Recordings"
Expand All @@ -35,6 +36,13 @@ mkdir -p "${swpy_dir}"
echo -e "[Default]\nsave_dir=${img_dir}\nsave_filename_format=${img_file}" >"${swpy_dir}"/config

focus_monitor=$(hyprctl activeworkspace -j | jq -r '.monitor')
#! This is a workaround for now. Will revise this whole script because hyprland and wlscreenrec works better now!
if [[ "${PASS}" = *"--cursor"* ]]; then
PASS="${PASS//--cursor/}"
curStat=$(hyprctl getoption cursor:no_hardware_cursors -j | jq .int)
hyprctl keyword cursor:no_hardware_cursors 1
trap 'hyprctl keyword cursor:no_hardware_cursors "${curStat}"' EXIT
fi

first_setup() {
if [ ! -f "${cacheFile}" ]; then
Expand Down Expand Up @@ -131,10 +139,29 @@ if [ "${OPTION}" = "--stop" ]; then
fi

case ${OPTION} in
-pa | --print-all) #? 󰄀 Print all outputs
-pa | --print-all) #? 󰄀 Print all screen
grimblast copysave screen "${temp_screenshot}" && swappy -f "${temp_screenshot}"
clearNotify
;;
-f | --freeze) #? 󰄀 Frozen screen, drag to manually snip an area
grimblast --freeze copysave area "${temp_screenshot}" && swappy -f "${temp_screenshot}" ;;
-pm | --print-monitor) #? 󰄀 Print focused monitor
grimblast copysave output "${temp_screenshot}" && swappy -f "${temp_screenshot}"
clearNotify
;;
-ps | --print-snip) #? 󰄀 Drag to manually snip an area
grimblast copysave area "${temp_screenshot}" && swappy -f "${temp_screenshot}"
clearNotify
;;
-sc | --scan) #? 󱉶 Use 'tesseract' to scan image then add to clipboard
enable_package tesseract-data-eng tesseract
GEOM=$(slurp)
grim -g "${GEOM}" "${temp_screenshot}"
pkg_installed imagemagick && convert "${temp_screenshot}" -sigmoidal-contrast 10,50% "${temp_screenshot}"
tesseract "${temp_screenshot}" - | wl-copy
notify-send -a "Screencap" "OCR preview" -i "${temp_screenshot}" -e
rm -f "${temp_screenshot}"
;;
-ra | --record-all) notify-send -a "ScreenCap" "'--record-all' is deprecated please use --record-focus instead" ;;
-rf | --record-focus) #? 󰃽 Record focused monitor
grim -o "${focus_monitor}" "${temp_screenshot}"
Expand All @@ -148,10 +175,6 @@ case ${OPTION} in
"${screen_recorder}" -f "${vid_dir}/${vid_file}" -o "${focus_monitor}" ${PASS}
clearNotify
;;
-ps | --print-snip) #? 󰄀 Drag to manually snip an area
grimblast copysave area "${temp_screenshot}" && swappy -f "${temp_screenshot}"
clearNotify
;;
-rs | --record-snip) #? 󰃽 Drag to manually snip an area to screen record it
GEOM=$(slurp)
grim -g "${GEOM}" "${temp_screenshot}"
Expand All @@ -165,21 +188,6 @@ case ${OPTION} in
"${screen_recorder}" -f "${vid_dir}/${vid_file}" -g "${GEOM}" ${PASS}
clearNotify
;;
-f | --freeze) #? 󰄀 Frozen screen, drag to manually snip an area
grimblast --freeze copysave area "${temp_screenshot}" && swappy -f "${temp_screenshot}" ;;
-pm | --print-monitor) #? 󰄀 Print focused monitor
grimblast copysave output "${temp_screenshot}" && swappy -f "${temp_screenshot}"
clearNotify
;;
-sc | --scan) #? 󱉶 Use 'tesseract' to scan image then add to clipboard
enable_package tesseract-data-eng tesseract
GEOM=$(slurp)
grim -g "${GEOM}" "${temp_screenshot}"
pkg_installed imagemagick && convert "${temp_screenshot}" -sigmoidal-contrast 10,50% "${temp_screenshot}"
tesseract "${temp_screenshot}" - | wl-copy
notify-send -a "Screencap" "OCR preview" -i "${temp_screenshot}" -e
rm -f "${temp_screenshot}"
;;
--stop) #?  Stop every instance of Screencap
:
;;
Expand Down

0 comments on commit 1903d08

Please sign in to comment.