feat(scripts): ocr area
This commit is contained in:
parent
1638d24687
commit
ce2c9655e0
3 changed files with 16 additions and 31 deletions
|
|
@ -133,7 +133,6 @@ bind = , A, exec, hyprctl dispatch submap reset; ctl audio out
|
|||
bind = , C, exec, hyprctl dispatch submap reset; sh -lc 'cliphist list | fuzzel --dmenu --prompt="clip: " | cliphist decode | wl-copy'
|
||||
bind = , I, exec, hyprctl dispatch submap reset; ctl idle
|
||||
bind = , K, exec, hyprctl dispatch submap reset; ctl keyboard next
|
||||
bind = , O, exec, hyprctl dispatch submap reset; ctl ocr
|
||||
bind = , M, exec, hyprctl dispatch submap reset; ctl media
|
||||
bind = , P, exec, hyprctl dispatch submap reset; ctl power
|
||||
bind = , S, exec, hyprctl dispatch submap reset; ctl screenshot
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@
|
|||
createDirectories = false;
|
||||
download = "${config.home.homeDirectory}/Downloads";
|
||||
pictures = "${config.home.homeDirectory}/Pictures";
|
||||
# desktop = "${config.home.homeDirectory}/Desktop";
|
||||
# documents = "${config.home.homeDirectory}/Documents";
|
||||
# music = "${config.home.homeDirectory}/Music";
|
||||
# publicShare = "${config.home.homeDirectory}/Public";
|
||||
# templates = "${config.home.homeDirectory}/Templates";
|
||||
# videos = "${config.home.homeDirectory}/Videos";
|
||||
desktop = "${config.home.homeDirectory}/Desktop";
|
||||
documents = "${config.home.homeDirectory}/Documents";
|
||||
music = "${config.home.homeDirectory}/Music";
|
||||
publicShare = "${config.home.homeDirectory}/Public";
|
||||
templates = "${config.home.homeDirectory}/Templates";
|
||||
videos = "${config.home.homeDirectory}/Videos";
|
||||
};
|
||||
home.sessionVariables = lib.mkIf hostConfig.isLinux {
|
||||
XDG_DOWNLOAD_DIR = config.xdg.userDirs.download;
|
||||
|
|
|
|||
34
scripts/ctl
34
scripts/ctl
|
|
@ -22,27 +22,6 @@ screenshot)
|
|||
maim -s "$file" && xclip -selection clipboard -t image/png -i "$file" &
|
||||
fi
|
||||
;;
|
||||
ocr)
|
||||
require tesseract
|
||||
dir="${XDG_PICTURES_DIR:-$HOME/Pictures}/Screenshots"
|
||||
mkdir -p "$dir"
|
||||
file="$dir/$(openssl rand -hex 10)-$(date +'%Y-%m-%d_%H-%M-%S').png"
|
||||
if [ "${XDG_SESSION_TYPE:-}" = "wayland" ]; then
|
||||
require grim slurp wl-copy
|
||||
(
|
||||
region="$(slurp)"
|
||||
[ -n "$region" ] || exit 0
|
||||
grim -g "$region" "$file" &&
|
||||
tesseract -l eng "$file" - 2>/dev/null | wl-copy
|
||||
) </dev/null >/dev/null 2>&1 &
|
||||
else
|
||||
require maim xclip
|
||||
(
|
||||
maim -s "$file" &&
|
||||
tesseract -l eng "$file" - 2>/dev/null | xclip -selection clipboard -in
|
||||
) </dev/null >/dev/null 2>&1 &
|
||||
fi
|
||||
;;
|
||||
keyboard)
|
||||
case "$2" in
|
||||
next)
|
||||
|
|
@ -203,7 +182,7 @@ media)
|
|||
exit 0
|
||||
fi
|
||||
pkill -x fuzzel 2>/dev/null && exit 0
|
||||
require fuzzel grim slurp wl-copy wf-recorder hyprctl jq
|
||||
require fuzzel grim slurp wl-copy wf-recorder hyprctl jq tesseract
|
||||
ss_dir="${XDG_PICTURES_DIR:-$HOME/Pictures}/Screenshots"
|
||||
rec_dir="${XDG_VIDEOS_DIR:-$HOME/Videos}"
|
||||
mkdir -p "$ss_dir" "$rec_dir"
|
||||
|
|
@ -213,7 +192,8 @@ media)
|
|||
rec_desktop=" Record Screen"
|
||||
rec_area=" Record Area"
|
||||
rec_window=" Record Window"
|
||||
chosen="$(printf '%s\n' "$cap_desktop" "$cap_area" "$cap_window" "$rec_desktop" "$rec_area" "$rec_window" | fuzzel --dmenu --hide-prompt --lines=6 --width=25 --no-icons 2>/dev/null)"
|
||||
ocr_area=" OCR Area"
|
||||
chosen="$(printf '%s\n' "$cap_desktop" "$cap_area" "$cap_window" "$rec_desktop" "$rec_area" "$rec_window" "$ocr_area" | fuzzel --dmenu --hide-prompt --lines=7 --width=25 --no-icons 2>/dev/null)"
|
||||
case "$chosen" in
|
||||
"$cap_desktop")
|
||||
file="$ss_dir/$(date +'%Y-%m-%d_%H-%M-%S').png"
|
||||
|
|
@ -247,6 +227,12 @@ media)
|
|||
notify-send -a ctl -t 2500 "Recording started"
|
||||
wf-recorder -g "$geom" -f "$file" &
|
||||
;;
|
||||
"$ocr_area")
|
||||
file="$ss_dir/$(date +'%Y-%m-%d_%H-%M-%S').png"
|
||||
region="$(slurp)" || exit 0
|
||||
[ -n "$region" ] || exit 0
|
||||
grim -g "$region" "$file" && tesseract -l eng "$file" - 2>/dev/null | wl-copy
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
wallpaper)
|
||||
|
|
@ -424,7 +410,7 @@ idle)
|
|||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ctl {screenshot|ocr|keyboard|audio|wifi|brightness|volume|media|wallpaper|power|idle}" >&2
|
||||
echo "Usage: ctl {screenshot|keyboard|audio|wifi|brightness|volume|media|wallpaper|power|idle}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue