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 = , 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 = , I, exec, hyprctl dispatch submap reset; ctl idle
|
||||||
bind = , K, exec, hyprctl dispatch submap reset; ctl keyboard next
|
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 = , M, exec, hyprctl dispatch submap reset; ctl media
|
||||||
bind = , P, exec, hyprctl dispatch submap reset; ctl power
|
bind = , P, exec, hyprctl dispatch submap reset; ctl power
|
||||||
bind = , S, exec, hyprctl dispatch submap reset; ctl screenshot
|
bind = , S, exec, hyprctl dispatch submap reset; ctl screenshot
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,12 @@
|
||||||
createDirectories = false;
|
createDirectories = false;
|
||||||
download = "${config.home.homeDirectory}/Downloads";
|
download = "${config.home.homeDirectory}/Downloads";
|
||||||
pictures = "${config.home.homeDirectory}/Pictures";
|
pictures = "${config.home.homeDirectory}/Pictures";
|
||||||
# desktop = "${config.home.homeDirectory}/Desktop";
|
desktop = "${config.home.homeDirectory}/Desktop";
|
||||||
# documents = "${config.home.homeDirectory}/Documents";
|
documents = "${config.home.homeDirectory}/Documents";
|
||||||
# music = "${config.home.homeDirectory}/Music";
|
music = "${config.home.homeDirectory}/Music";
|
||||||
# publicShare = "${config.home.homeDirectory}/Public";
|
publicShare = "${config.home.homeDirectory}/Public";
|
||||||
# templates = "${config.home.homeDirectory}/Templates";
|
templates = "${config.home.homeDirectory}/Templates";
|
||||||
# videos = "${config.home.homeDirectory}/Videos";
|
videos = "${config.home.homeDirectory}/Videos";
|
||||||
};
|
};
|
||||||
home.sessionVariables = lib.mkIf hostConfig.isLinux {
|
home.sessionVariables = lib.mkIf hostConfig.isLinux {
|
||||||
XDG_DOWNLOAD_DIR = config.xdg.userDirs.download;
|
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" &
|
maim -s "$file" && xclip -selection clipboard -t image/png -i "$file" &
|
||||||
fi
|
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)
|
keyboard)
|
||||||
case "$2" in
|
case "$2" in
|
||||||
next)
|
next)
|
||||||
|
|
@ -203,7 +182,7 @@ media)
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
pkill -x fuzzel 2>/dev/null && exit 0
|
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"
|
ss_dir="${XDG_PICTURES_DIR:-$HOME/Pictures}/Screenshots"
|
||||||
rec_dir="${XDG_VIDEOS_DIR:-$HOME/Videos}"
|
rec_dir="${XDG_VIDEOS_DIR:-$HOME/Videos}"
|
||||||
mkdir -p "$ss_dir" "$rec_dir"
|
mkdir -p "$ss_dir" "$rec_dir"
|
||||||
|
|
@ -213,7 +192,8 @@ media)
|
||||||
rec_desktop=" Record Screen"
|
rec_desktop=" Record Screen"
|
||||||
rec_area=" Record Area"
|
rec_area=" Record Area"
|
||||||
rec_window=" Record Window"
|
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
|
case "$chosen" in
|
||||||
"$cap_desktop")
|
"$cap_desktop")
|
||||||
file="$ss_dir/$(date +'%Y-%m-%d_%H-%M-%S').png"
|
file="$ss_dir/$(date +'%Y-%m-%d_%H-%M-%S').png"
|
||||||
|
|
@ -247,6 +227,12 @@ media)
|
||||||
notify-send -a ctl -t 2500 "Recording started"
|
notify-send -a ctl -t 2500 "Recording started"
|
||||||
wf-recorder -g "$geom" -f "$file" &
|
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
|
esac
|
||||||
;;
|
;;
|
||||||
wallpaper)
|
wallpaper)
|
||||||
|
|
@ -424,7 +410,7 @@ idle)
|
||||||
fi
|
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
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue