diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a49ee69 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.teiler.history +.teiler.history.tmp +TODO diff --git a/Makefile b/Makefile index 40373ce..17c11db 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,11 @@ ifndef PREFIX endif install: - install -Dm755 teiler $(DESTDIR)$(PREFIX)/bin/teiler - install -Dm644 config.example $(DESTDIR)$(PREFIX)/share/doc/teiler/config.example - install -Dm644 README.md $(DESTDIR)$(PREFIX)/share/doc/teiler/README.md - install -Dm644 config.example $(DESTDIR)/etc/teiler/teiler.conf - install -Dm755 teiler_helper $(DESTDIR)$(PREFIX)/bin/teiler_helper - install -Dm644 uploader/s3 $(DESTDIR)/etc/teiler/uploader/s3 - install -Dm644 uploader/scp $(DESTDIR)/etc/teiler/uploader/scp - install -Dm644 profiles/mp4-pulse $(DESTDIR)/etc/teiler/profiles/mp4-pulse - install -Dm644 profiles/mp4-noaudio $(DESTDIR)/etc/teiler/profiles/mp4-noaudio - install -Dm644 profiles/webm-noaudio $(DESTDIR)/etc/teiler/profiles/webm-noaudio + install -Dm755 heyteiler $(DESTDIR)$(PREFIX)/bin/heyteiler + install -Dm644 README.md $(DESTDIR)$(PREFIX)/share/doc/heyteiler/README.md + install -Dm644 heyteiler.conf $(DESTDIR)/etc/heyteiler/heyteiler.conf + install -Dm755 heyteiler_helper $(DESTDIR)/etc/heyteiler/heyteiler_helper + install -Dm644 pygmentize_types.txt $(DESTDIR)/etc/heyteiler/pygmentize_types.txt + install -Dm644 targets/local $(DESTDIR)/etc/heyteiler/targets/local + install -Dm644 targets/s3 $(DESTDIR)/etc/heyteiler/targets/s3 + install -Dm644 targets/scp $(DESTDIR)/etc/heyteiler/targets/scp diff --git a/README.md b/README.md index f44fadd..7fb124c 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,109 @@ # heyteiler - a little screenshot tool written in bash -heyteiler (forked from [teiler](https://github.com/carnager/teiler)) uses rofi to draw a menu which lets you -choose between screenshots or screencasts. +heyteiler (forked from [teiler](https://github.com/carnager/teiler)) uses rofi +to draw a menu which lets you choose between screenshots, screencasts, +saveclipboard or recognize text. ## Screenshot -![teiker](screenshot.png "heyteiler in action") +![mainMenu](screenshot.png "heyteiler in action") ## Features -* screenshots fullscreen/monitor/area -* delay of screenshots -* screencasts of monitor/area -* upload screenshots/screencasts - teiler can also upload your files via scp, imgur or filebin, ix (for pastes) and amazon s3. -* History of Images and Videos with support for +* Screenshots fullscreen all/fullscreen/area +* Screencasts of fullscreen/area +* Save clipboard text in file +* Recognize text and put it in clipboard +* Delay screenshots +* Save screenshots in clipboard +* Save filepath of result in clipboard +* Upload your files via: + - imgur (only images, require: [imgurbash2](https://github.com/ram-on/imgurbash2)) + - ix (only text) + - scp (all formats, require: openssh) + - amazon s3 (all formats, require: s3cmd cli tool) +* History of Images,Videos and Text with support for + Viewing - + Editing + Uploading -* Commandline interface for direct access to all features. Useful for hotkeys -* Recognize text and put it in clipboard +* Commandline interface for direct access to all features: useful for hotkeys of + if your don't want to use rofi + +## Configuration + +Default system configuration storied in the `/etc/heytiler` directory. But for +user defined changes i recommend to copy `/etc/heytiler` folder in user +`$HOME/.config/heytiler` directory + +```bash +cp -R /etc/heytiler ~/.config/heyteiler +``` + +Here you find: + - heyteiler.conf - main configuration file + - targets - folder with targets configuration files + +## Choises +Some menus has choises in header. For change values in them use rofi keybinds: Alt+1, +Alt+2, Alt+3 + +![choises](choises.png "heyteiler menu with choises") + +## Targets + +Targets is main feature of heyteiler. In config directory, you may find targets +folder. Every file in this folder describe one target. +You may change exist target or create your own just copy one of existing. +See `targets` files for more options + +Supported `target_type`: 'local', 'scp', 'imgur', 'clipboard' + - Images: local, clipboard, scp, s3, imgur + - Video: local, scp, s3 + - Text: s3, scp, ix.io + +imgur and ix.io target types worked without any additional settings. So, they +haven't special file. But if you want to change local directory for backups you +may copy `local` target and set `target_type=imgur`. + +```bash +cd ~/.config/heyteiler/targets +cp local my_custom_imgur +sed -i 's/target_type=.*/target_type=imgur/' my_custom_imgur +# Change imgur backup directory +sed -i 's/Screenshots/Imgur/' my_custom_imgur +``` + +### Local target + +*DONT REMOVE LOCAL TARGET* + +`local` target is a special target which heyteiler use for saving files before +upload on the resource. So even if you use network resource as a target (ex: +imgur or scp) your file will be available in future in `local` target folders or in +history tab. + +Also `local` target used for openning files from history. + ## Dependencies: -* xininfo (https://github.com/DaveDavenport/xininfo) -* rofi (https://github.com/DaveDavenport/rofi) -* ffmpeg (http://www.ffmpeg.org) +Choose dependencies based on necessary features: + * xclip -* maim (https://github.com/naelstrof/maim) * slop (https://github.com/naelstrof/slop) -* copyq (https://github.com/hluk/CopyQ) - -## Optional Dependencies - -* imgurbash2 (https://github.com/ram-on/imgurbash2) -* filebin (http://git.server-speed.net/users/flo/filebin) -* openssh (http://www.openssh.com) -* ix (http://ix.io) -* s3 cli tools -* tesseract (https://github.com/tesseract-ocr/tesseract) +* xdg-open +* libnotify +* UI dependency: + * rofi (https://github.com/DaveDavenport/rofi) +* Screenshot dependency + * maim (https://github.com/naelstrof/maim) +* Screencasts dependencies: + * xininfo (https://github.com/DaveDavenport/xininfo) + * ffmpeg (http://www.ffmpeg.org) +* Recognize dependencies: + * maim + * tesseract (https://github.com/tesseract-ocr/tesseract) + * ImageMagic (https://imagemagick.org/index.php) +* Uploading dependencies: + * curl + * imgurbash2 (https://github.com/ram-on/imgurbash2) + * openssh (http://www.openssh.com) + * s3 cli tools diff --git a/choises.png b/choises.png new file mode 100644 index 0000000..16860df Binary files /dev/null and b/choises.png differ diff --git a/config.example b/config.example deleted file mode 100644 index d02e5ed..0000000 --- a/config.example +++ /dev/null @@ -1,74 +0,0 @@ -##### teiler configuration file ###### - -# rofi command. Make sure to have "$@" as last argument -_rofi () { - rofi -kb-accept-entry "!Return" "$@" -} - -# general variables - -# the path where images, videos and pastes should be saved -img_path=$HOME/Pictures/Screenshots -vid_path=$HOME/Videos/Screencasts -paste_path=$HOME/Pictures/Paste - -# set viewer for images and videos plus editor for images -viewer=eog -editor=pinta -player=mpv - -# Hitting Enter will upload -always_ul=1 - -# Uploading options -# Possible Choices for img_ul: fb, scp, s3, imgur -# Possible Choices for vid_ul: fb, scp, s3 -# Possible Choices for paste_ul: fb, scp, ix -img_ul=imgur -vid_ul=fb -paste_ul=ix - -# Screencast options -# Resolution to change to when recording in fullscreen -#res=800x600 - -# If you use a custom rate for X, set it here. -# rate=120 - -# Profile to use for screencasts -# profiles are stored in $HOME/.config/teiler/profiles -# teiler ships with 3 profiles atm. mp4-pulse, mp4-noaudio -# and webm-noaudio -# You can create your own profiles, but changes to existing profiles -# will be overwritten on startup -profile="mp4-pulse" - -# hotkeys -upload="Alt+1" -noupload="Alt+2" -delayup="Alt+3" -delaysave="Alt+4" - -view="Alt+1" -historyupload="Alt+2" -edit="Alt+3" -clip="Alt+4" - - -# Normally you don't want to change anything here! -SCREENCAST_PIDFILE=/tmp/$USER-teiler-screencast.pid -namekey=teiler -random_string=$(date +'%Y-%m-%d-%H%M%S') -img_filemask=img-$random_string.png -paste_filemask=txt-$random_string.txt - -# video filemask is without extension, since it gets the extension -# from set profile -vid_filemask=vid-$random_string - -help_color="#0C73C2" -hidecursor=yes -# slop options -slop_border=1 -slop_color="255,0,0" -hidecursor=yes diff --git a/generate_types.sh b/generate_types.sh new file mode 100755 index 0000000..b554aa2 --- /dev/null +++ b/generate_types.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Script for generate pygmentize_types.txt file +echo 'text .txt' > pygmentize_types.txt +pygmentize -L lexers | \ + tail -n +5 |\ + sed -n 'N;s/\n//p' |\ + sed -E -n 's/\* ([^,:]+).*filenames[^*]+\*(\.[^,)]+).*/\1 \2/p' |\ + grep -v 'text' >> pygmentize_types.txt diff --git a/heyteiler b/heyteiler new file mode 100755 index 0000000..7b3bc56 --- /dev/null +++ b/heyteiler @@ -0,0 +1,641 @@ +#!/usr/bin/env bash + +# Source config files +if [[ -f "./heyteiler.conf" ]]; then + source_path='.' +elif [[ -f "$HOME/.config/heyteiler/heyteiler.conf" ]]; then + source_path="$HOME/heyteiler" +elif [[ -f "/etc/heyteiler/heyteiler.conf" ]]; then + source_path="/etc/heyteiler" +else + echo "ERROR: required heyteiler.conf not found" + exit +fi + +if [[ -f "${source_path}/targets/local" ]]; then + source "${source_path}/targets/local" +else + echo "ERROR: required '${source_path}/targets/local' not found" + exit +fi +# Source config after local target +source "${source_path}/heyteiler.conf" + +# Check if video is recording now +if [ -z "$XDG_RUNTIME_DIR" ]; then + TMPDIR=$(mktemp -d) + XDG_RUNTIME_DIR=$TMPDIR + trap 'rm -rf $TMPDIR; exit' INT QUIT HUP TERM 0 +fi + +heyteiler_history_file="${HOME}/.heyteiler.history" + +heyteiler_name_file="${XDG_RUNTIME_DIR}/__heyteiler_video_name" +heyteiler_pid_file="${XDG_RUNTIME_DIR}/__heyteiler_cast_pid" +heyteiler_resolution_file="${XDG_RUNTIME_DIR}/__heyteiler_resolution" +heyteiler_target_file="${XDG_RUNTIME_DIR}/__heyteiler_target" + + +video_recording="no" +if [[ -f "$heyteiler_pid_file" ]]; then + video_recording="yes" +fi + +# Add default rofi options +_rofi () { + rofi "${rofi_options}" "$@" +} + +_heyteiler_helper () { + if [[ -x "${source_path}/heyteiler_helper" ]]; then + "${source_path}/heyteiler_helper" "$@" + else + "heyteiler_helper" "$@" + fi +} + +check_path () { + # Autocreate $2 or ask in console + check_what="$1" + check_filepath="$2" + if [[ ! -d "$check_filepath" ]]; then + read -p "${check_what} path \"${check_filepath}\" does not exist. Create it? (Y/n)" -n 1 -r + echo "REPLY: $REPLY" >> "~/teiler.log" + if [[ $REPLY =~ ^[Yy]$ ]] || [[ $REPLY == "" ]]; then + mkdir -p "${check_filepath}" + elif [[ $REPLY =~ ^[Nn]$ ]]; then + exit + else + # create better than not create ) + mkdir -p "${check_filepath}" + fi + fi +} + +fresh() { + ### Return all custom values to there default + delay=0 + image_target="${default_image_target}" + video_target="${default_video_target}" + text_target="${default_text_target}" + recognize_language="${default_recognize_language}" +} + +showMenu () { + # Show heyteiler menu screen with help + + _menu_name="$1" + shift + function_args=( "${@:1}" ) + + if [[ "${_menu_name}" == "heyteiler" ]]; then + _menu="< Exit\n---" + else + _menu="< Return to Main Menu\n---" + fi + + _menu_help_args='no' + for _menu_arg in "${function_args[@]}"; do + if [[ "$_menu_arg" == "-" ]]; then + _menu_help_args='yes' + _menu_opts=() + continue + fi + if [[ "$_menu_help_args" == "no" ]]; then + # Make menu dmenu string + let "_num=_num+1" + _menu="${_menu}\n${_num} ${_menu_arg}" + elif [[ "$_menu_help_args" == "yes" ]]; then + # Make help dmenu string + if [[ -z "$_menu_opt" ]]; then + _menu_opt="${_menu_arg}" + continue + fi + _menu_value="${_menu_arg}" + if [[ -z "$_menu_help" ]]; then + # If start help message then add span + _menu_help="${_menu_help}${_menu_opt}" + else + _menu_help="${_menu_help} | ${_menu_opt}" + fi + if [[ -n "$_menu_value" ]]; then + _menu_help="${_menu_help}: ${_menu_value}" + fi + _menu_opts+=( "${_menu_opt}" ) + _menu_opt="" + _menu_value="" + fi + done + _menu_help="${_menu_help}" + + if [[ ${_menu_help_args} == "yes" ]]; then + _menu_help_flag="-mesg" + _menu_help="$_menu_help" + else + _menu_help_flag="" + _menu_help="" + fi + _menu_result=$(echo -e "${_menu}" | _rofi "$_menu_help_flag" "$_menu_help" -dmenu -p "${_menu_name} >") + _menu_exit=$? + case "${_menu_exit}" in + 10) if [ -n "${_menu_opts[0]}" ]; then echo -n "${_menu_opts[0]}"; else echo -n "Return"; fi && exit ;; + 11) if [ -n "${_menu_opts[1]}" ]; then echo -n "${_menu_opts[1]}"; else echo -n "Return"; fi && exit ;; + 12) if [ -n "${_menu_opts[2]}" ]; then echo -n "${_menu_opts[2]}"; else echo -n "Return"; fi && exit ;; + 13) if [ -n "${_menu_opts[3]}" ]; then echo -n "${_menu_opts[3]}"; else echo -n "Return"; fi && exit ;; + esac + _num=$(echo -n "$_menu_result" | sed -nE 's/([0-9]+)\s.*/\1/p') + if [[ -n "${_num}" ]]; then + echo -n "${function_args[_num-1]}" + else + echo -n "Return" + fi +} + +mainMenu () { + fresh + + screencast_menu="[ Screencast ]>" + if [[ "$video_recording" == "yes" ]]; then + screencast_menu="[ Stop Recording Screencast ]" + fi + + menu=$( showMenu \ + "heyteiler" \ + "[ Screenshot ]>" \ + "$screencast_menu" \ + "[ SaveClipboard ]>" \ + "[ Recognition ]>" \ + "[ History ]>" + ) + + case "${menu}" in + "[ Screenshot ]>") screenshotMenu && exit;; + "[ Screencast ]>") screencastMenu && exit;; + "[ Stop Recording Screencast ]") screencastMenu && exit;; + "[ SaveClipboard ]>") clipboardMenu && exit;; + "[ Recognition ]>") recognitionMenu && exit;; + "[ History ]>") historyMenu && exit;; + "Return") exit;; + esac +} + +screenshotMenu () { + if [[ "${1}" == "quick" ]]; then + mode="${2}" + targetPrompt Image quick "${3}" + if [[ -n "${4}" ]]; then + delay="${4}" + else + delay=0 + fi + else + menu=$(showMenu Screenshot Area Fullscreen "Fullscreen All" - Target "${image_target}" Delay "${delay}") + case "${menu}" in + "Area") mode="area";; + "Fullscreen") mode="fullscreen";; + "Fullscreen All") mode="fullscreenAll";; + "Target") targetPrompt Image && screenshotMenu && exit;; + "Delay") delayPrompt && screenshotMenu && exit;; + "Return") mainMenu && exit;; + esac + fi + + # Save image to clipboard and exit + if [[ "${target_type}" == "clipboard" ]]; then + maimCmd "${delay}" "-" "${mode}" | xclip -selection clipboard -t image/png + exit + fi + + maimCmd "${delay}" "${image_path}/${image_filename}" "${mode}" + saveInHistory Image "${image_path}/${image_filename}" + if [[ "$target_type" != "local" ]]; then + _heyteiler_helper Image "${image_path}/${image_filename}" "${source_path}" "${image_target}" + elif [[ "$save_filepath" == "yes" ]]; then + echo "${image_path}/${image_filename}" | tr -d '\n' | xclip -selection clipboard + fi +} + +targetPrompt () { + _prompt_type="${1}" + if [[ "$_prompt_type" == "Image" ]]; then + _posible_target_types="local|scp|s3|imgur|clipboard" + # Types allowed without any settings + _default_target_types="imgur|clipboard" + elif [[ "$_prompt_type" == "Video" ]]; then + _posible_target_types="local|scp|s3" + _default_target_types="" + elif [[ "$_prompt_type" == "Text" ]]; then + _posible_target_types="local|scp|ix.io" + _default_target_types="ix.io" + else + exit + fi + + if [[ "${2}" == "quick" ]]; then + result_target="${3}" + else + __sed_added=$(echo -n "${_default_target_types}" | sed "s/|/\\\\n/g") + _targets=$(grep -l -R -E "target_type=(${_posible_target_types})" "${source_path}/targets" |\ + sed "s%${source_path}/targets/%%" + ) + # Ensure that default targets only added only one time + if [[ -n "${__sed_added}" ]]; then + _targets=$(echo "$_targets" |\ + grep -v -E "${_default_target_types}" |\ + sed -e "\$a${__sed_added}" + ) + fi + result_target=$(echo -e "$_targets" | _rofi -dmenu -p "${_prompt_type} Target >") + val=$? + if [[ "$val" != 0 ]]; then + return + fi + fi + + # Source target + if [[ -f "${source_path}/targets/${result_target}" ]]; then + source "${source_path}/targets/${result_target}" + source "${source_path}/heyteiler.conf" + else + target_type="${result_target}" + fi + + if [[ "$_prompt_type" == "Image" ]]; then + image_target="${result_target}" + elif [[ "$_prompt_type" == "Video" ]]; then + video_target="${result_target}" + elif [[ "$_prompt_type" == "Text" ]];then + text_target="${result_target}" + fi +} + +# Recognition +recognitionMenu () { + if [[ "${1}" == "quick" ]] || [[ "${1}" == "q" ]]; then + case "${2}" in + w|white|whiteback) colors="whiteback";; + d|dark|darkback|b|black|blackback) colors="darkback";; + esac + if [[ -n "${3}" ]]; then + recognize_language="${3}" + else + recognize_language="${default_recognize_language}" + fi + if [[ -n "${4}" ]]; then + delay="${4}" + else + delay=0 + fi + else + menu=$(showMenu Colors "Colored on White" "Colored on Dark" - Language "$recognize_language") + case "${menu}" in + "Colored on White") colors="whiteback";; + "Colored on Dark") colors="darkback";; + "Language") languagePrompt && recognitionMenu && exit;; + "Return") mainMenu && exit;; + esac + fi + maimCmd 0 - area | tesseractCmd $colors; +} + +languagePrompt () { + recognize_language=$(tesseract --list-langs | grep -v ' ' | _rofi -dmenu -p "Language >") +} + +test_xrandr () { + if [[ -n $resolution ]]; then + output=$(xininfo -name) + xrandr --output "$output" --mode "$resolution" --dryrun || { + echo "ERROR: Resolution "${resolution}" not available" + exit 1; + } + fi +} + +screencastMenu () { + # Stop recording if it run and exit + if [[ "$video_recording" == "yes" ]]; then + stopRecording + saveInHistory Video "${video_filepath}" + if [[ "$video_target" != "local" ]]; then + _heyteiler_helper Video "$video_filepath" "${source_path}" "${video_target}" + elif [[ "$save_filepath" == "yes" ]]; then + echo "$video_filepath" | tr -d '\n' | xclip -selection clipboard + fi + exit + fi + + if [[ "${1}" == "quick" ]] || [[ "${1}" == "q" ]]; then + mode="${2}" + targetPrompt Video quick "${3}" + else + menu=$(showMenu Screencast Area Fullscreen - Target "$video_target") # TODO: choose audio inputs + case "${menu}" in + "Area") mode="area";; + "Fullscreen") mode="fullscreen";; + "Target") targetPrompt Video && screencastMenu && exit;; + "Return") mainMenu && exit;; + esac + fi + echo "$video_target" > "$heyteiler_target_file" + ffmpegCmd "${video_path}/${video_filename}" $mode +} + +clipboardMenu () { + if [[ -z "$(xclip -o -selection clipboard -t TARGETS | grep 'UTF8_STRING')" ]]; then + echo "Only UTF8_STRING supported" + exit + fi + + _texttypes=$(cat "${source_path}/pygmentize_types.txt" | awk '{print $1}' | sed ':a;N;$!ba;s/\n/ /g') + if [[ "${1}" == "quick" ]] || [[ "${1}" == "q" ]]; then + targetPrompt Text quick "${2}" + if [[ -n "${3}" ]]; then + _filetype="${3}" + else + _filetype="text" + fi + else + menu=$(showMenu "Text Format" $_texttypes - Target "$text_target") + case "${menu}" in + Target) targetPrompt Text && clipboardMenu && exit;; + Return) mainMenu && exit;; + *) _filetype="${menu}";; + esac + fi + _file_extention=$(cat "${source_path}/pygmentize_types.txt" | grep "^${_filetype}\s\+" | awk '{print $2}') + # Replace extention + _text_output=$(echo "${text_path}/${text_filename}" |\ + sed -E "s/(.*)\.[^.]+/\1${_file_extention}/" + ) + clipboardCmd "${_text_output}" + saveInHistory Text "${_text_output}" + if [[ "$target_type" != "local" ]]; then + _heyteiler_helper Text "${_text_output}" "${source_path}" "${text_target}" + # TODO + elif [[ "$save_filepath" == "yes" ]]; then + echo "${_text_output}" | tr -d '\n' | xclip -selection clipboard + fi +} + +clipboardCmd () { + check_path SaveClipboard "$(dirname "$1")" + xclip -o -selection clipboard >> "$1" +} + +historyMenu () { + menu=$(showMenu History Image Video Text) + case "${menu}" in + Image|Video|Text) typeHistoryMenu "${menu}" && exit;; + Return) mainMenu && exit;; + esac +} + +typeHistoryMenu () { + _history_type="${1}" + if [[ "$_history_type" == "Image" ]]; then + history_target="${image_target}" + elif [[ "$_history_type" == "Video" ]]; then + history_target="${video_target}" + elif [[ "$_history_type" == "Text" ]]; then + history_target="${text_target}" + fi + + if [[ "${2}" == "quick" ]] || [[ "${2}" == "q" ]]; then + # Set target + targetPrompt "${_history_type}" "quick" "${3}" + # Set last item + menu=$( grep "${_history_type}" "${heyteiler_history_file}" |\ + sed "s/${_history_type}\s\+//" |\ + head -1 + ) + else + _history_items=$( grep "${_history_type}" "${heyteiler_history_file}" | sed "s/${_history_type}\s\+//" | sed ':a;N;$!ba;s/\n/ /g') + menu=$(showMenu "History ${_history_type}" ${_history_items} - Target "${history_target}") + case "${menu}" in + Target) targetPrompt "${_history_type}" && typeHistoryMenu "${_history_type}" && exit;; + Return) mainMenu && exit;; + *) echo "";; + esac + fi + + if [[ "$target_type" == "local" ]]; then + xdg-open "${menu}" + # Only images has target: clipboard in heyteiler + elif [[ "$target_type" == "clipboard" ]]; then + cat "${menu}" | xclip -selection clipboard -t image/png + else + _heyteiler_helper "${_history_type}" "${menu}" "${source_path}" "${history_target}" + fi +} + +saveInHistory () { + _history_type="${1}" + _item_path="${2}" + _history_tmp_file="${heyteiler_history_file}.tmp" + echo "${_history_type} ${_item_path}" > "${_history_tmp_file}" + if [[ -f "${heyteiler_history_file}" ]]; then + head -199 "${heyteiler_history_file}" >> "${_history_tmp_file}" + fi + mv "${_history_tmp_file}" "${heyteiler_history_file}" +} + +stopRecording () { + video_filepath="$(cat "${heyteiler_name_file}")" + video_pid="$(cat "${heyteiler_pid_file}")" + video_old_resolution="$(cat "${heyteiler_resolution_file}")" + video_target="$(cat "${heyteiler_target_file}")" + if [[ -z "$video_filepath" ]] ||\ + [[ -z "$video_old_resolution" ]] ||\ + [[ -z "$video_target" ]]; then + _witherrors=" with errors" + rm -f "$heyteiler_name_file" + rm -f "$heyteiler_resolution_file" + rm -f "$heyteiler_target_file" + fi + if [[ -f "${heyteiler_pid_file}" ]]; then + if [[ -n "$(pgrep ffmpeg | grep "$video_pid")" ]]; then + kill "$video_pid" + else + _witherrors=" with errors" + fi + rm -f "${heyteiler_pid_file}" + fi + + notify-send -a "heyteiler" -t 1000 "heyteiler" "Stopped recording${_witherrors}" + output=$(xininfo -name); + xrandr --output "$output" --mode "$video_old_resolution"; + rm -f "${heyteiler_resolution_file}"; + +} + +ffmpegCmd () { + round() { + echo $(( ${1:?need one argument} / 2 * 2)) + } + + video_output="${1}" + check_path "Video" "$(dirname ${video_output})"; + [[ -f "${video_output}" ]] && rm "${video_output}" # rewrite file if exist + + # Prepare resolution + resolution_now="$(xininfo -mon-size | sed 's/ /x/')" + echo "$resolution_now" > "${heyteiler_resolution_file}" + if [[ -z "$resolution" ]]; then + resolution="$resolution_now" + fi + + if [[ "$resolution_now" != "$resolution" ]]; then + # Change resolution before start video + test_xrandr + output=$(xininfo -name) + xrandr --output "$output" --mode "$resolution" + sleep 5; + fi + + echo "${video_output}" > "${heyteiler_name_file}" # Safe video name for next time + if [[ "$2" == "fullscreen" ]]; then + ffmpeg_display_opts="-s $resolution -i $(echo $DISPLAY)+$(xininfo -mon-x),$(xininfo -mon-y)" + ffmpeg -f x11grab $ffmpeg_display_opts \ + ${ffmpeg_video_fullscreen} "${video_output}" & + echo "$!" > "${heyteiler_pid_file}" + notify-send -a "heyteiler" -t 1000 "heyteiler" "Screencast started" + elif [[ $2 == "area" ]]; then + read -r X Y W H G ID < <(slop ${slop_options} -f "%x %y %w %h %g %i") + X=$(round $X) + Y=$(round $Y) + W=$(round $W) + H=$(round $H) + ffmpeg_display_opts="-s "$W"x"$H" -i $(echo $DISPLAY)+$X,$Y)" + ffmpeg -show_region 1 -f x11grab $ffmpeg_display_opts \ + ${ffmpeg_video_area} "${video_output}" & + echo "$!" > "${heyteiler_pid_file}" + notify-send -a "heyteiler" -t 1000 "heyteiler" "Screencast started" + fi +} + +tesseractCmd () { + if [[ "$1" == "whiteback" ]]; then + tesseract -l "$recognize_language" - - -c page_separator="" | tr -d '\n' | xclip -selection clipboard + elif [[ "$1" == "darkback" ]]; then + # tesseract always wait colored on white images + convert - -set colorspace Gray -separate -average -negate - | tesseract -l "$recognize_language" - - -c page_separator="" | tr -d '\n' | xclip -selection clipboard + fi + notify-send -a "heyteiler" -t 1000 "heyteiler" "Recognition done!" +} + +maimCmd () { + # maimCmd delay path mode + #Examples: + # maimCmd 0 "/tmp/myimage.png" fullscreen + # maimCmd 5 "-" area + + + # Check settings + maim_cursor="--hidecursor" + + # Check args + if [[ "${1}" == "0" ]]; then + maim_delay="" + else + maim_delay="-d ${1}" + fi + + if [[ ${2} == "-" ]]; then + img_output="/dev/stdout" + else + img_output="${2}" + check_path "Image" "$(dirname ${img_output})"; + fi + + if [[ $3 == "area" ]]; then + maim_mode_options="-s ${slop_options}" + elif [[ $3 == "active" ]]; then + maim_mode_options="-i $(xdotool getactivewindow)" + elif [[ $3 == "fullscreen" ]]; then + maim_mode_options="-g $(xininfo -mon-width)x$(xininfo -mon-height)+$(xininfo -mon-x)+$(xininfo -mon-y)" + elif [[ $3 == "fullscreenAll" ]]; then + maim_mode_options="" + fi + + maim ${maim_mode_options} ${maim_delay} ${maim_cursor} "${img_output}" + if [[ "${1}" != "0" ]]; then + notify-send -a "heyteiler" -t 1000 "heyteiler" "Chick!"; + fi +} + +delayPrompt () { + delay=$(echo -e "$(seq 0 10)" | _rofi -dmenu -p "Choose Delay > ") + if [[ -z "$delay" ]]; then + exit + fi +} + +echo_help () { +targets_names=$(ls -1 "${source_path}/targets" |\ + grep -v 'clipboard|imgur|ix.io' |\ + sed '$aclipboard\nimgur\nix.io' |\ + sed ':a;N;$!ba;s/\n/ /g') +tlangs=$(tesseract --list-langs |\ + grep -v ' ' |\ + sed ':a;N;$!ba;s/\n/ /g') + +cat << EOF +heyteiler - a rofi-driven screen{shot,cast} utility + +screenshot [quick mode target delay] + open screenshots menu/make quick screenshot to target + alias: image i +screencast [quick mode target] + open screencasts menu/quick screencast start or stop + alias: video v +saveclipboard [quick target code] + open clipboard menu/quick save clipboard to target + alias: text t +recognition [quick background language delay] + open recognition menu/quick recognize text to clipboard + alias: r +history [type] [quick target] + open history [type] menu/quick send last [type] item to target + alias: h + +Options: + quick: quick|q + mode: area fullscreen fullscreenAll + delay: any number or skip + target: ${targets_names} + code: text bash python and many more... + background: white|w dark|d + language: ${tlangs} + type: image|i video|v text|t + +Usefull examples: + # Make fullscreen screenshot with delay + heyteiler screenshot quick fullscreen local 3 + # Fast copy area to clipboard + heyteiler screenshot quick area clipboard + + # Put last screenshot image to clipboard + heyteiler history image quick clipboard + # Open last [h]istory [v]ideo [q]uick + heyteiler h v q local +EOF +} + +key="$1" +case "$key" in + screenshot|image|i) shift; screenshotMenu "$@" && exit;; + screencast|video|v) shift; screencastMenu "$@" && exit;; + saveclipboard|text|t) shift; clipboardMenu "$@" && exit;; + recognition|r) shift; recognitionMenu "$@" && exit;; # TODO: quick + history|h) shift; if [[ -z "$1" ]]; then historyMenu; exit; fi;; + -h|--help) echo_help && exit;; + *) mainMenu && exit;; +esac + +key2="$1" +case "$key2" in + i|screenshot|image|Image) shift; typeHistoryMenu Image "$@" && exit;; + v|screencast|video|Video) shift; typeHistoryMenu Video "$@" && exit;; + t|saveclipboard|text|Text) shift; typeHistoryMenu Text "$@" && exit;; +esac diff --git a/heyteiler.conf b/heyteiler.conf new file mode 100644 index 0000000..f30fc4d --- /dev/null +++ b/heyteiler.conf @@ -0,0 +1,39 @@ +##### heyteiler configuration file ###### + +### Screenshots Settings ### +# This destination used as default (One from: ./targets) +# Possible target_type var: local, clipboard, scp, s3, imgur +default_image_target=local +# Filemask for created image files. +image_filename="image-$(date +'%Y-%m-%d-%H%M%S').png" + +### Screencasts Settings ### +# This destination used as default (one from ./targets) +# Possible target_type var: local, scp, s3 +default_video_target=local +# Filemask for created video files. See ~/.config/heyteiler/targets for ${ffmpeg_type} value +video_filename="video-$(date +'%Y-%m-%d-%H%M%S').${ffmpeg_type}" + +### Save Clipboard Settings ### +# This destination used as default (use one from ~/.config/heyteiler/destination) +# Possible Choices for paste: s3, scp, ix.io +default_text_target=local +# Filemask for created text files. See ~/.config/heyteiler/targets for ${ffmpeg_type} value +text_filename="text-$(date +'%Y-%m-%d-%H%M%S').txt" + +### Recognition Settings ### +# tesseract defautl language, from 4.0.0 version is possible to use several +# languages but i'm not recommend it +default_recognize_language="eng" + +### Advanced variables ### +# Save filepath in clipboard +save_filepath=yes +# The color of help messages in rofi headers +help_color="#0C73C2" +# Slop options +slop_options="-b 2 -c 255,0,0" +# TODO: test -r crosshair + +# Add some custom rofi options +#rofi_options='-kb-accept-entry "!Return"' diff --git a/heyteiler_helper b/heyteiler_helper new file mode 100755 index 0000000..e302962 --- /dev/null +++ b/heyteiler_helper @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +# Example +# heyteiler_helper image "${image_path}/${image_filename}" "${source_path}" "${image_target}" +item_type="${1}" +item_path="${2}" +source_path="${3}" +item_target="${4}" + +item_basename="$(basename ${item_path})" + +if [[ -f "${source_path}/${item_target}" ]]; then + source "${source_path}/${item_target}" +else + target_type="${item_target}" +fi +source "${source_path}/heyteiler.conf" + +scpCmd () { + scp "${item_path}" "${scp_options}" "${1}/${item_basename}" + if [[ "${save_filepath}" == "yes" ]]; then + echo "${2}" | sed "s/{filepath}/${item_basename}/" | xclip -selection clipboard + fi + notify-send -a "heyteiler" -t 1000 "Uploaded!" "${2}" +} + +s3cmdCmd () { + s3cmd --no-progress "${s3cmd_options}" put "${item_path}" "${1}/${item_basename}" + if [[ "${save_filepath}" == "yes" ]]; then + echo "${2}" | sed "s/{filepath}/${item_basename}/" | xclip -selection clipboard + fi + notify-send -a "heyteiler" -t 1000 "Uploaded!" "${2}" +} + + +ixioCmd () { + url=$(curl --no-progress-meter -F "f:1=@${item_path}" ix.io) + extention=$(echo "${item_path}" | sed -E 's/^.*\.(\w+)$/\1/') + lang=$(cat "${source_path}/pygmentize_types.txt" | sed -n -E "s/^(.*)\s+\.${extention}\$/\1/p") + # Generated filename: always copy path to clipboard + if [[ "$lang" == "text" ]]; then + url="${url}" + else + url="${url}/${lang}" + fi + echo "${url}" | xclip -selection clipboard + notify-send -a "heyteiler" -t 1000 "Uploaded!" "${url}" +} + +imgurCmd () { + # Generated filename: imgurbash2 save in clipboard itself + url=$(imgurbash2 "${item_path}" | sed -E 's/^(\S+).*$/\1/') + notify-send -a "heyteiler" -t 1000 "Uploaded!" "${url}" +} + +if [[ "$target_type" == "scp" ]]; then + case "$item_type" in + Image) scpCmd "${scp_image_path}" "${scp_image_filepath}"; exit;; + Video) scpCmd "${scp_video_path}" "${scp_video_filepath}"; exit;; + Text) scpCmd "${scp_text_path}" "${scp_text_filepath}"; exit;; + esac + exit +elif [[ "$target_type" == "s3" ]]; then + case "$item_type" in + Image) s3cmdCmd "${s3cmd_image_path}" "${s3cmd_image_filepath}"; exit;; + Video) s3cmdCmd "${s3cmd_video_path}" "${s3cmd_video_filepath}"; exit;; + Text) s3cmdCmd "${s3cmd_text_path}" "${s3cmd_text_filepath}"; exit;; + esac + exit +elif [[ "$target_type" == "imgur" ]]; then + echo "Wtf 4" >> ~/heyteiler.log # debug + case "$item_type" in + Image) imgurCmd; exit;; + esac + exit +elif [[ "$target_type" == "ix.io" ]]; then + case "$item_type" in + Text) ixioCmd; exit;; + esac + exit +fi diff --git a/profiles/mp4-noaudio b/profiles/mp4-noaudio deleted file mode 100644 index f8ab9e9..0000000 --- a/profiles/mp4-noaudio +++ /dev/null @@ -1,8 +0,0 @@ -# do not edit this file. instead make a copy under different name -# teiler will overwrite this file on start - -border="-show_region 1" -encopts="-r 30 -vcodec libx264 -pix_fmt yuv420p -s $res -movflags +faststart -acodec libmp3lame" -rect_encopts="-r 30 -c:v libx264 -preset slow -crf 18 -c:a libvorbis" -ext="mp4" -ffaudio="" diff --git a/profiles/mp4-pulse b/profiles/mp4-pulse deleted file mode 100644 index d2441e7..0000000 --- a/profiles/mp4-pulse +++ /dev/null @@ -1,8 +0,0 @@ -# do not edit this file. instead make a copy under different name -# teiler will overwrite this file on start - -border="-show_region 1" -encopts="-r 30 -vcodec libx264 -pix_fmt yuv420p -s $res -acodec libmp3lame" -rect_encopts="-r 30 -c:v libx264 -preset slow -crf 18 -c:a libvorbis" -ext="mp4" -ffaudio="-f alsa -ac 2 -i pulse" diff --git a/profiles/webm-noaudio b/profiles/webm-noaudio deleted file mode 100644 index 5aad1f0..0000000 --- a/profiles/webm-noaudio +++ /dev/null @@ -1,8 +0,0 @@ -# do not edit this file. instead make a copy under different name -# teiler will overwrite this file on start - -border="-show_region 1" -encopts="-c:v vp8 -threads 2 -pix_fmt yuv420p -crf 30 -b:v 0 -s $res" -rect_encopts="-r 30 -c:v vp8 -threads 4 -pix_fmt yuv420p -crf 30 -b:v 0" -ext="webm" -ffaudio="" diff --git a/pygmentize_types.txt b/pygmentize_types.txt new file mode 100644 index 0000000..cb1670f --- /dev/null +++ b/pygmentize_types.txt @@ -0,0 +1,399 @@ +text .txt +abap .abap +abnf .abnf +ada .adb +adl .adl +agda .agda +aheui .aheui +ahk .ahk +alloy .als +ampl .run +antlr-as .G +antlr-cpp .G +antlr-csharp .G +antlr-java .G +antlr-objc .G +antlr-perl .G +antlr-python .G +antlr-ruby .G +apl .apl +applescript .applescript +arduino .ino +arrow .arw +as .as +as3 .as +aspectj .aj +aspx-cs .aspx +aspx-vb .aspx +asy .asy +at .at +augeas .aug +autoit .au3 +awk .awk +bare .bare +bash .sh +bat .bat +bbcbasic .bbc +bc .bc +befunge .befunge +bib .bib +blitzbasic .bb +blitzmax .bmx +bnf .bnf +boa .boa +boo .boo +boogie .bpl +brainfuck .bf +bst .bst +bugs .bug +c-objdump .c-objdump +c .c +ca65 .s +cadl .cadl +camkes .camkes +capdl .cdl +capnp .capnp +cbmbas .bas +ceylon .ceylon +cfc .cfc +cfengine3 .cf +cfm .cfm +chai .chai +chapel .chpl +charmci .ci +cheetah .tmpl +cirru .cirru +clay .clay +clean .icl +clojure .clj +clojurescript .cljs +cmake .cmake +cobol .cob +cobolfree .cbl +coffee-script .coffee +common-lisp .cl +componentpascal .cp +console .sh-session +coq .v +cpp .cpp +cpp-objdump .cpp-objdump +cpsa .cpsa +cr .cr +crmsh .crmsh +croc .croc +cryptol .cry +csharp .cs +csound .orc +csound-document .csd +csound-score .sco +css+mozpreproc .css.in +css .css +cucumber .feature +cuda .cu +cypher .cyp +cython .pyx +d-objdump .d-objdump +d .d +dart .dart +dasm16 .dasm16 +delphi .pas +devicetree .dts +dg .dg +diff .diff +docker .docker +dpatch .dpatch +dtd .dtd +duel .duel +dylan-console .dylan-console +dylan-lid .lid +dylan .dylan +earl-grey .eg +easytrieve .ezt +ebnf .ebnf +ec .ec +ecl .ecl +eiffel .e +elixir .ex +elm .elm +emacs .el +email .eml +erl .erl-sh +erlang .erl +evoque .evoque +execline .exec +extempore .xtm +ezhil .n +factor .factor +fan .fan +fancy .fy +felix .flx +fennel .fnl +fish .fish +floscript .flo +forth .frt +fortran .f03 +fortranfixed .f +foxpro .PRG +freefem .edp +fsharp .fs +fstar .fst +gap .g +gas .s +gdscript .gd +genshi .kid +glsl .vert +gnuplot .plot +go .go +golo .golo +gooddata-cl .gdc +gosu .gs +groff .[1234567] +groovy .groovy +gst .gst +haml .haml +haskell .hs +haxeml .hxml +hlsl .hlsl +hsail .hsail +html+evoque .html +html+handlebars .handlebars +html+ng2 .ng2 +html+php .phtml +html+twig .twig +html .html +hx .hx +hybris .hy +hylang .hy +i6t .i6t +icon .icon +idl .pro +idris .idr +igor .ipf +inform6 .inf +inform7 .ni +ini .ini +io .io +ioke .ik +irc .weechatlog +isabelle .thy +j .ijs +jags .jag +jasmin .j +java .java +javascript+mozpreproc .js.in +jcl .jcl +js .js +jsgf .jsgf +json .json +jsonld .jsonld +jsp .jsp +julia .jl +juttle .juttle +kal .kal +kmsg .kmsg +koka .kk +kotlin .kt +lagda .lagda +lasso .lasso +lcry .lcry +lean .lean +less .less +lhs .lhs +lidr .lidr +limbo .b +liquid .liquid +live-script .ls +llvm-mir .mir +llvm .ll +logos .x +logtalk .lgt +lsl .lsl +lua .lua +make .mak +mako .mao +mako .mao +maql .maql +mask .mask +mason .m +mathematica .nb +matlab .m +md .md +modelica .mo +modula2 .def +monkey .monkey +monte .mt +moocode .moo +moon .moon +mosel .mos +mql .mq4 +ms .ms +mscgen .msc +mupad .mu +mxml .mxml +myghty .myt +nasm .asm +ncl .ncl +nemerle .n +nesc .nc +newlisp .lsp +newspeak .ns2 +nim .nim +nit .nit +nixos .nix +nsis .nsi +nusmv .smv +objdump-nasm .objdump-intel +objdump .objdump +objective-c++ .mm +objective-c .m +objective-j .j +ocaml .ml +octave .m +odin .odin +ooc .ooc +opa .opa +openedge .p +pan .pan +parasail .psi +pawn .p +peg .peg +perl .pl +perl6 .pl +php .php +pig .pig +pike .pike +pkgconfig .pc +pointless .ptls +pony .pony +postscript .ps +pot .pot +pov .pov +powershell .ps1 +praat .praat +prolog .ecl +promql .promql +properties .properties +protobuf .proto +pug .pug +puppet .pp +py2tb .py2tb +pypylog .pypylog +pytb .pytb +python .py +qbasic .BAS +qml .qml +qvto .qvto +racket .rkt +ragel-c .rl +ragel-cpp .rl +ragel-d .rl +ragel-em .rl +ragel-java .rl +ragel-objc .rl +ragel-ruby .rl +rb .rb +rconsole .Rout +rd .Rd +reason .re +rebol .r +red .red +redcode .cw +registry .reg +rexx .rexx +rhtml .rhtml +ride .ride +rnc .rnc +roboconf-graph .graph +roboconf-instances .instances +robotframework .robot +rql .rql +rsl .rsl +rst .rst +rts .rts +rust .rs +sarl .sarl +sas .SAS +sass .sass +sc .sc +scala .scala +scaml .scaml +scdoc .scd +scheme .scm +scilab .sci +scss .scss +sgf .sgf +shen .shen +shexc .shex +sieve .siv +silver .sil +singularity .def +slash .sla +slim .slim +slurm .sl +smali .smali +smalltalk .st +smarty .tpl +sml .sml +snobol .snobol +snowball .sbl +solidity .sol +sp .sp +sparql .rq +spec .spec +splus .S +sql .sql +sqlite3 .sqlite3-console +ssp .ssp +stan .stan +stata .do +swift .swift +swig .swg +systemverilog .sv +tads3 .t +tap .tap +tasm .asm +tcl .tcl +tcsh .tcsh +tea .tea +terraform .tf +tex .tex +thrift .thrift +tid .tid +tnt .tnt +todotxt .todotxt +toml .toml +treetop .treetop +ts .ts +tsql .sql +ttl .ttl +turtle .ttl +typoscript .typoscript +ucode .u +unicon .icn +urbiscript .u +usd .usd +vala .vala +vb.net .vb +vbscript .vbs +vcl .vcl +velocity .vm +verilog .v +vgl .rpf +vhdl .vhdl +vim .vim +wdiff .wdiff +webidl .webidl +whiley .whiley +x10 .x10 +xml+evoque .xml +xml .xml +xquery .xqy +xslt .xsl +xtend .xtend +xul+mozpreproc .xul.in +yaml+jinja .sls +yaml .yaml +yang .yang +zeek .zeek +zephir .zep +zig .zig diff --git a/screenshot.png b/screenshot.png index cbbb6cc..cc62bdf 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/targets/local b/targets/local new file mode 100644 index 0000000..5991012 --- /dev/null +++ b/targets/local @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +target_type=local + +## Destination settings +image_path="$HOME/Pictures/Screenshots/$(date +'%m.%Y')" +video_path="$HOME/Videos/Screencasts/$(date +'%m.%Y')" +text_path="$HOME/Documents/ClipboardSaves/$(date +'%m.%Y')" + +### Qaulity Screencast settings + +# It may be usefull to change qulity of screencast for diffrent targets +# If you don't care about video size just don't touch this settings :) + +# Only for filename, see video_filemask in ~/.config/heyteiler/config +ffmpeg_type="mp4" +# ffmpeg video capture settings for fullscreen mode (read more in ffmpeg docs) +ffmpeg_video_fullscreen="-f pulse -ac 2 -i default -r 30 -c:v libx264 -preset slow -crf 18 -c:a libvorbis " +# sometimes it is usefull to change settings for area mode +ffmpeg_video_area="${ffmpeg_video_fullscreen}" + +# You may change screen resolution for this target (it will changed back after +# stop recording) +#resolution=800x600 diff --git a/targets/s3 b/targets/s3 new file mode 100755 index 0000000..efbfe38 --- /dev/null +++ b/targets/s3 @@ -0,0 +1,42 @@ +#!/bin/bash + +s3cmd_options="" +# s3 target parametrs +s3cmd_bucket=BUCKET +s3cmd_image_path="s3://${s3cmd_bucket}/Pictures/Screenshots/$(date +'%m.%Y')" +s3cmd_video_path="s3://${s3cmd_bucket}/Videos/Screencasts/$(date +'%m.%Y')" +s3cmd_text_path="s3://${s3cmd_bucket}/Documents/ClipboardSaves/$(date +'%m.%Y')" + +##### Advanced Block ##### + +# Sometimes files put on web-server over s3cmd, so your filepath +# may changed on some http resource. So, here you may set +# what to copy to clipboard when save_filepath=yes +# {filename} replaced by filename +s3cmd_image_filepath="${s3cmd_image_path}/{filename}" +s3cmd_video_filepath="${s3cmd_video_path}/{filename}" +s3cmd_text_filepath="${s3cmd_text_path}/{filename}" + +### Qaulity Screencast settings ### + +# It may be usefull to change qulity of screencast for diffrent targets +# If you don't care about video size just don't touch this settings :) + +# Only for filename, see video_filemask in ~/.config/heyteiler/config +ffmpeg_type="mp4" +# ffmpeg video capture settings for fullscreen mode (read more in ffmpeg docs) +ffmpeg_video_fullscreen="-f pulse -ac 2 -i default -r 30 -c:v libx264 -preset slow -crf 18 -c:a libvorbis " +# sometimes it is usefull to change settings for area mode +ffmpeg_video_area="${ffmpeg_video_fullscreen}" + +# You may change screen resolution for this target (it will changed back after +# stop recording) +#resolution=800x600 + +s3_bucket= +s3_path_img=path/to/images +s3_path_vid=path/to/videos +s3_path_paste=path/to/pastes +s3_http_img=http://S3_DOMAIN/path/to/images +s3_http_vid=http://S3_DOMAIN/path/to/videos +s3_http_paste=http://S3_DOMAIN/path/to/pastes diff --git a/targets/scp b/targets/scp new file mode 100644 index 0000000..e72c009 --- /dev/null +++ b/targets/scp @@ -0,0 +1,34 @@ +#!/bin/bash + +scp_options="-P 22" +# scp target parametrs +scp_host=HOSTNAME +scp_image_path="${scp_host}:Pictures/Screenshots/$(date +'%m.%Y')" +scp_video_path="${scp_host}:Videos/Screencasts/$(date +'%m.%Y')" +scp_text_path="${scp_host}:Documents/ClipboardSaves/$(date +'%m.%Y')" + +##### Advanced Block ##### + +# Sometimes you may want to put files on web-server over scp, so your filepath +# may changed on http resource, so here you may set +# what to copy to clipboard when save_filepath=yes +# {filename} replaced by filename +scp_image_filepath="${scp_image_path}/{filename}" +scp_video_filepath="${scp_video_path}/{filename}" +scp_text_filepath="${scp_text_path}/{filename}" + +### Qaulity Screencast settings ### + +# It may be usefull to change qulity of screencast for diffrent targets +# If you don't care about video size just don't touch this settings :) + +# Only for filename, see video_filemask in ~/.config/heyteiler/config +ffmpeg_type="mp4" +# ffmpeg video capture settings for fullscreen mode (read more in ffmpeg docs) +ffmpeg_video_fullscreen="-f pulse -ac 2 -i default -r 30 -c:v libx264 -preset slow -crf 18 -c:a libvorbis " +# sometimes it is usefull to change settings for area mode +ffmpeg_video_area="${ffmpeg_video_fullscreen}" + +# You may change screen resolution for this target (it will changed back after +# stop recording) +#resolution=800x600 diff --git a/teiler b/teiler deleted file mode 100755 index bd881a6..0000000 --- a/teiler +++ /dev/null @@ -1,491 +0,0 @@ -#!/usr/bin/env bash - -# set default rofi options -_rofi () { - rofi -kb-accept-entry "!Return" "$@" -} - -if [ -z "$XDG_RUNTIME_DIR" ]; then - TMPDIR=$(mktemp -d) - XDG_RUNTIME_DIR=$TMPDIR - trap 'rm -rf $TMPDIR; exit' INT QUIT HUP TERM 0 -fi - -if [[ -d /etc/teiler ]] -then - source /etc/teiler/teiler.conf -fi - -if [[ ! -d $HOME/.config/teiler ]]; then - mkdir $HOME/.config/teiler -fi - -if [[ ! -f $HOME/.config/teiler/config ]]; then - cp /etc/teiler/teiler.conf $HOME/.config/teiler/config -fi - -export ext=${ext}; source $HOME/.config/teiler/config - -if [[ ! -d $HOME/.config/teiler/uploader ]]; then - mkdir $HOME/.config/teiler/uploader - if [[ -d /etc/teiler ]] - then - cp /etc/teiler/uploader/* $HOME/.config/teiler/uploader - fi -fi - - -if [[ ! -d $HOME/.config/teiler/profiles ]]; then - mkdir $HOME/.config/teiler/profiles -fi - -if [[ -d /etc/teiler ]] -then - cd /etc/teiler/profiles - for i in *; do - if [[ ! -f $HOME/.config/teiler/profiles/"$i" ]]; then - cp /etc/teiler/profiles/"$i" $HOME/.config/teiler/profiles - else - cmp "$i" $HOME/.config/teiler/profiles/"$i" || cp -f /etc/teiler/profiles/"$i" $HOME/.config/teiler/profiles - fi - done -fi - -check_img_path () { - if [[ ! -d $img_path ]]; then - read -p "Image path \"${img_path}\" does not exist. Create it? (Y/n) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ || $REPLY == "" ]]; then - mkdir -p "${img_path}" - elif [[ $REPLY =~ ^[Nn]$ ]]; then - exit - else - echo "Please enter y or n" - check_img_path - fi - fi -} - -check_vid_path () { - if [[ ! -d $vid_path ]]; then - read -p "Video path \"${vid_path}\" does not exist. Create it? (Y/n) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ || $REPLY == "" ]]; then - mkdir -p "${vid_path}" - elif [[ $REPLY =~ ^[Nn]$ ]]; then - exit - else - echo "Please enter y or n" - check_vid_path - fi - fi -} - -check_paste_path () { - if [[ ! -d $paste_path ]]; then - read -p "Paste path \"${paste_path}\" does not exist. Create it? (Y/n) " -n 1 -r - echo - if [[ $REPLY =~ ^[Yy]$ || $REPLY == "" ]]; then - mkdir -p "${paste_path}" - elif [[ $REPLY =~ ^[Nn]$ ]]; then - exit - else - echo "Please enter y or n" - check_paste_path - fi - fi -} - -source "$HOME/.config/teiler/profiles/${profile}" - -vid_filemask="${vid_filemask}.${ext}" -save=$noupload - -mainMenu () { - if [[ -f $XDG_RUNTIME_DIR/__teiler_cast_name ]] - then - filename="$(cat $XDG_RUNTIME_DIR/__teiler_cast_name)" - fi - - isRecording && STATE_RECORDING="2 Stop Recording Screencast" - - if [[ "$STATE_RECORDING" == "2 Stop Recording Screencast" ]] - then - HELP="${upload}: Upload | ${save}: No Upload" - menu=$(echo -e "< Exit\n---\n"$STATE_RECORDING"" | _rofi -dmenu -u 2 -p "teiler > ") - val=$? - if [[ $val -eq 1 ]] - then - exit - elif [[ $val -eq 0 ]] - then - askPrompt - fi - elif [[ -z "$STATE_RECORDING" ]] - then - menu=$(echo -e "< Exit\n---\n1 [ Screenshots ]>\n2 [ Screencasts ]>\n3 [ Recognition ]>\n4 [ History ]>\n---\n5 Pastebin Text from Clipboard" | _rofi -dmenu -p "teiler > ") - val=$? - if [[ $val -eq 0 ]] - then - case "${menu}" in - "1 [ Screenshots ]>") screenshotMenu;; - "2 [ Screencasts ]>") askPrompt;; - "3 [ Recognition ]>") recognitionMenu;; - "4 [ History ]>") uploadMenu;; - "5 Pastebin Text from Clipboard") export filename="${paste_filemask}" && clipCmd && teiler_helper --upload text "${filename}";; - "< Exit") exit;; - esac - elif [[ $val -eq 1 ]] - then - exit - fi - fi -} - -screenshotMenu () { - help_text=$(echo -e "Upload: ${upload} - Save: ${save} - Default: Enter" | column -s '-' -t) - line1=$(echo "${help_text}" | head -1) - HELP="${line1}" - export filename="${img_filemask}" - menu=$(echo -e "< Return to Main Menu\n---\n1 Monitor\n2 Fullscreen\n3 Area" | _rofi -dmenu -mesg "${HELP}" -p "Screenshot > ") - rofi_exit=$? - case "${menu}" in - "1 Monitor") mode="fullscreen"; desc="Monitor";; - "2 Fullscreen") mode="fullscreenAll"; desc="Monitor";; - "3 Area") mode="area"; desc="Area";; - "< Return to Main Menu") mainMenu;; - esac - if [[ $rofi_exit -eq 10 ]]; then - delayPrompt - if [[ $delay == "0" ]]; then maimCmd $mode "${filename}" && cd "${img_path}" && teiler_helper --upload image "${filename}" && exit - else notify-send -a "teiler" -t 1000 "teiler" "Taking Screenshot in "$delay" seconds"; maimCmd $mode "${filename}" && cd "${img_path}" && teiler_helper --upload image "${filename}" && exit - fi - elif [[ $rofi_exit -eq 11 ]]; then - delayPrompt - if [[ $delay == "0" ]]; then maimCmd $mode "${filename}" && exit - else notify-send -a "teiler" -t 1000 "teiler" "Taking Screenshot in "$delay" seconds"; maimCmd $mode "${filename}" - fi - elif [[ $rofi_exit -eq 1 ]]; then - exit - elif [[ $rofi_exit -eq 0 ]]; then - delayPrompt - if [[ $always_ul == "1" ]]; then - if [[ $delay == "0" ]]; then maimCmd $mode "${filename}" && cd "${img_path}" && teiler_helper --upload image "${filename}" && exit - else notify-send -a "teiler" -t 1000 "teiler" "Taking Screenshot in "$delay" seconds"; maimCmd $mode "${filename}" && cd "${img_path}" && teiler_helper --upload image "${filename}" && exit - fi - elif [[ $always_ul == "0" ]]; then - if [[ $delay == "0" ]]; then maimCmd $mode "${filename}" && exit - else notify-send -a "teiler" -t 1000 "teiler" "Taking Screenshot in "$delay" seconds"; maimCmd $mode "${filename}" && exit - fi - fi - fi -} - -recognitionMenu () { - mode="area"; desc="Area" - menu=$(echo -e "< Return to Main Menu\n---\n1 Colored on White\n2 Colored on Black" | _rofi -dmenu -p "Colors > ") - case "${menu}" in - "1 Colored on White") colors="whiteback";; - "2 Colored on Black") colors="blackback";; - "< Return to Main Menu") mainMenu;; - esac - delayPrompt - if [[ $delay != "0" ]]; then - notify-send -a "teiler" -t 1000 "teiler" "Recognize in "$delay" seconds"; - fi - maimCmd $mode - | tesseractCmd $colors; -} - -test_xrandr () { - if [[ -n $res ]]; then - output=$(xininfo -name); xrandr --output "$output" --mode "$res" --dryrun || { rofi -kb-move-word-forward '' -mesg "Resolution "${res}" not available"; exit 1; } - fi -} - -screencastMenu () { - filename="$(cat $XDG_RUNTIME_DIR/__teiler_cast_name)" - isRecording && STATE_RECORDING="2 Stop Recording Screencast" - if [[ "$STATE_RECORDING" == "2 Stop Recording Screencast" ]]; then - HELP="${upload}: Upload | ${save}: No Upload" - menu=$(echo -e "< Exit\n---\n"$STATE_RECORDING"" | _rofi -dmenu -u 2 -kb-custom-1 "${upload}" -kb-custom-2 "${save}" -mesg "${HELP}" -p "teiler > ") - val=$? - - if [[ "$menu" == "< Exit" ]]; then - exit - fi - if [[ $val -eq 10 ]]; then isRecording && stopRecording && sleep 2 && cd "${vid_path}" && teiler_helper --upload video "${filename}" && rm -f $XDG_RUNTIME_DIR/__teiler_cast_name; - elif [[ $val -eq 11 ]]; then isRecording && stopRecording; rm -f $XDG_RUNTIME_DIR/__teiler_cast_name; notify-send -a "teiler" -t 1000 "teiler" "Screencast saved"; exit - elif [[ $val -eq 1 ]]; then exit - elif [[ $val -eq 0 ]]; then - if [[ $always_ul ]]; then isRecording && stopRecording && sleep 2 && cd "${vid_path}" && teiler_helper --upload video "${filename}"; - elif [[ $always_ul == "0" ]]; then isRecording && stopRecording; rm -f $XDG_RUNTIME_DIR/__teiler_cast_name; notify-send -a "teiler" -t 1000 "teiler" "Screencast saved"; exit - fi - fi - - elif [[ -z "$STATE_RECORDING" ]]; then - menu=$(echo -e "< Return to Main Menu\n---\n1 Fullscreen\n2 Area" | _rofi -dmenu -p "Screencast > ") - val=$? - filename="${vid_filemask}" - echo "${filename}" > $XDG_RUNTIME_DIR/__teiler_cast_name - - if [[ $menu == "1 Fullscreen" ]]; then isRecording && stopRecording && sleep 2 || ffmpegCmd fullscreen; - elif [[ $menu == "2 Area" ]]; then isRecording && stopRecording && sleep 2 || ffmpegCmd area; - elif [[ $menu == "" ]]; then exit; - elif [[ $menu == "< Return to Main Menu" ]]; then mainMenu; fi - fi -} - -uploadMenu () { - menu=$(echo -e "< Return to Main Menu\n---\n1 Images\n2 Videos" | _rofi -dmenu -p "Uploads > ") - if [[ $menu == "1 Images" ]]; then imageMenu; - elif [[ $menu == "2 Videos" ]]; then videoMenu; - elif [[ $menu == "< Return to Main Menu" ]]; then mainMenu; - elif [[ $menu == "" ]]; then exit - fi -} - -imageMenu () { - cd "${img_path}" - HELP="${view}: View | ${historyupload}: Upload | ${edit}: Edit | ${clip}: Copy to Clipboard" - imagemenu=$(echo -e "< Return to Upload Menu\n---\n$(ls -1 -r)" | _rofi -dmenu -select "${entry}" -kb-custom-1 "${view}" -kb-custom-2 "${historyupload}" -kb-custom-3 "${edit}" -kb-custom-4 "${clip}" -mesg "${HELP}" -p "Choose > ") - val=$? - - imagemenu2="${imagemenu%.*}" - if [[ "${imagemenu}" == "< Return to Upload Menu" ]]; then uploadMenu; fi - if [[ $val -eq 11 ]]; then teiler_helper --upload image $(echo -n "${imagemenu}"); export entry="${imagemenu}"; imageMenu - elif [[ $val -eq 10 || $val -eq 0 ]]; then $viewer "${imagemenu}"; export entry="${imagemenu}"; imageMenu - elif [[ $val -eq 12 ]]; then - cp "${imagemenu}" "${imagemenu2}-mod.png" - $editor "${imagemenu2}-mod.png" - export entry="${imagemenu}" - imageMenu - elif [[ $val -eq 13 ]]; then - copyq & - copyq write image/png - < "${imagemenu}"; copyq \select 0 - elif [[ $val -eq 1 ]]; then exit; - fi -} - -videoMenu () { - cd "${vid_path}" - HELP="${view}: View | ${historyupload}: Upload" - videomenu=$(echo -e "< Return to Upload Menu\n---\n$(ls -1)" | _rofi -dmenu -select "${entry}" -kb-custom-1 "${view}" -kb-custom-2 "${historyupload}" -mesg "${HELP}" -p "Choose > ") - val=$? - videomenu2="${videomenu%.*}" - if [[ "${videomenu}" == "< Return to Upload Menu" ]]; then uploadMenu; fi - if [[ $val -eq 11 ]]; then teiler_helper --upload video "${videomenu}"; - elif [[ $val -eq 10 || $val -eq 0 ]]; then $player "${videomenu}"; export entry="${videomenu}"; videoMenu - elif [[ $val -eq 1 ]]; then exit - fi -} - -isRecording () { [[ -f "$SCREENCAST_PIDFILE" ]] || return 1; } - -stopRecording () { - local pid - if [[ -a $XDG_RUNTIME_DIR/teiler_res ]]; then - res=$(cat $XDG_RUNTIME_DIR/teiler_res) - fi - [[ -f $SCREENCAST_PIDFILE ]] && { pid=$(cat "$SCREENCAST_PIDFILE"); isRecording && kill "$pid"; rm "$SCREENCAST_PIDFILE"; } - notify-send -a "teiler" -t 1000 "teiler" "Stopped recording" - if [[ -z $rate ]]; then - output=$(xininfo -name); xrandr --output "$output" --mode "$res"; rm -f $XDG_RUNTIME_DIR/teiler_res; return 0 - else - if [[ -n $res ]]; then - output=$(xininfo -name); xrandr --output "$output" --mode "$res" --rate "${rate}"; rm -f $XDG_RUNTIME_DIR/teiler_res; return 0 - fi - fi -} - -slopCmd () { - slopString=$(slop -b "$slop_border" -c "$slop_color") - if [[ "$slopString" == *"Cancel=true"* ]]; then - exit - fi - } - -ffmpegCmd () { - round() { - echo $(( ${1:?need one argument} / 2 * 2)) - } - - xres=$(echo "$res" | awk -F 'x' '{ print $1 }') - yres=$(echo "$res" | awk -F 'x' '{ print $2 }') - - if [[ -n $res ]]; then - res_now="$(xininfo -mon-size | sed 's/ /x/')" - else - res="$(xininfo -mon-size | sed 's/ /x/')" - fi - - source "$HOME/.config/teiler/profiles/${profile}" - - echo "${filename}" > $XDG_RUNTIME_DIR/__teiler_cast_name - if [[ $1 == "fullscreen" ]]; then - isRecording && { notify "$time" 'Screencast already in progress'; echo "Already recording Screen"; exit 1; } - ffmpeg_display=$(echo $DISPLAY) - ffmpeg_offset="$(xininfo -mon-x),$(xininfo -mon-y)" - if [[ -n $res_now ]]; then - echo "$res_now" > $XDG_RUNTIME_DIR/teiler_res - fi - if [[ $res_now == $res ]]; then echo " " - else output=$(xininfo -name); xrandr --output "$output" --mode "$res"; sleep 5; fi - [[ -f "${vid_path}/${filename}" ]] && rm "${vid_path}/${filename}" - if [[ -z $ffaudio ]]; then ffmpeg -f x11grab ${border} -s $res -i $ffmpeg_display+$ffmpeg_offset $encopts "${vid_path}/${filename}" & - else ffmpeg -f x11grab ${border} -s $res -i $ffmpeg_display+$ffmpeg_offset $ffaudio $encopts "${vid_path}/${filename}" & - fi - echo "$!" > "$SCREENCAST_PIDFILE" - notify-send -a "teiler" -t 1000 "teiler" "Screencast started" - elif [[ $1 == "area" ]]; then - read -r X Y W H G ID < <(slop -f "%x %y %w %h %g %i") - X=$(round $X) - Y=$(round $Y) - W=$(round $W) - H=$(round $H) - isRecording && { notify "$time" 'Screencast already in progress'; echo "Already recording Screen"; exit 1; } - ffmpeg_display=$(echo $DISPLAY); ffmpeg_offset=$(echo $(xininfo -mon-x),$(xininfo -mon-y)) - [[ -f "${vid_path}/${filename}" ]] && rm "${vid_path}/${filename}" - if [[ -z $ffaudio ]]; then ffmpeg -f x11grab ${border} -s "$W"x"$H" -i $ffmpeg_display+$X,$Y $rect_encopts "${vid_path}/${filename}" & - else ffmpeg -f x11grab ${border} -s "$W"x"$H" -i $ffmpeg_display+$X,$Y $ffaudio $rect_encopts "${vid_path}/${filename}" & - fi - echo "$!" > "$SCREENCAST_PIDFILE" - notify-send -a "teiler" -t 1000 "teiler" "Screencast started" - fi -} - -tesseractCmd () { - if [[ $1 == "whiteback" ]]; then - tesseract - - -c page_separator="" | xclip -selection clipboard - elif [[ $1 == "blackback" ]]; then - # tesseract always wait colored on white images - convert - -set colorspace Gray -separate -average -negate - | tesseract - - -c page_separator="" | xclip -selection clipboard - fi -} - -maimCmd () { - if [[ $hidecursor == "yes" ]]; then - cursor="--hidecursor" - elif [[ $hidecursor == "no" ]]; then - cursor="" - fi - if [[ $slop_color == "" ]]; then - rect_color="" - else - rect_color="-c ${slop_color}" - fi - if [[ $slop_border == "" ]]; then - rect_border="" - else - rect_border="-b ${slop_border}" - fi - - if [[ ! -z $delay && "$delay" != "0" ]]; then - maim_delay="-d ${delay}" - else - maim_delay="" - fi - - if [[ ${2} == "-" ]]; then - img_output="/dev/stdout" - else - img_output="${img_path}/${2}" - fi - - if [[ $1 == "area" ]]; then maim ${maim_delay} $cursor ${rect_border} ${rect_color} -s ${img_output}; - elif [[ $1 == "active" ]]; then maim ${maim_delay} -i $(xdotool getactivewindow) ${img_output}; - elif [[ $1 == "fullscreen" ]]; then maim ${maim_delay} $cursor -g $(xininfo -mon-width)x$(xininf3 -mon-height)+$(xininfo -mon-x)+$(xininfo -mon-y) ${img_output}; - elif [[ $1 == "fullscreenAll" ]]; then maim ${maim_delay} $cursor ${img_output}; - fi - - if [[ ! -z "${delay}" && "${delay}" != "0" ]]; then - notify-send -a "teiler" -t 1000 "teiler" "Chick!"; - fi -} - -askPrompt () { - filename="$(cat $XDG_RUNTIME_DIR/__teiler_cast_name)" - isRecording && STATE_RECORDING="Recording" - if [[ -z "$STATE_RECORDING" ]]; then - filename="${vid_filemask}" - echo "${filename}" > $XDG_RUNTIME_DIR/__teiler_cast_name - menu=$(echo -e "< Exit\n---\n1 Fullscreen\n2 Area" | _rofi -dmenu -p "> ") - if [[ $menu == "1 Fullscreen" ]]; then isRecording && stopRecording && sleep 2 || ffmpegCmd fullscreen; - elif [[ $menu == "2 Area" ]]; then isRecording && stopRecording && sleep 2 || ffmpegCmd area; - elif [[ $menu == "" ]]; then exit - fi - else - filename="$(cat $XDG_RUNTIME_DIR/__teiler_cast_name)" - isRecording && stopRecording && sleep 2 - ask=$(echo -e "1 Yes\n2 No" | _rofi -dmenu -p "Upload? > ") - if [[ $ask == "1 Yes" ]]; then cd "${vid_path}" && teiler_helper --upload video "${filename}" && rm -f $XDG_RUNTIME_DIR/__teiler_cast_name; - elif [[ $ask == "2 No" ]]; then rm -f $XDG_RUNTIME_DIR/__teiler_cast_name; - fi - fi -} - -clipCmd () { - (xclip -o) > "${paste_path}/${paste_filemask}" -} - -delayPrompt () { - delay=$(echo -e "$(seq 0 10)" | _rofi -dmenu -p "Choose Delay > ") - if [[ $delay == "" ]]; then - exit - fi -} - -helpCmd () { - cat << EOF -teiler - a rofi-driven screen{shot,cast} utility -(C) Rasmus Steinke ---screenshot open screenshots menu ---screencast open screencasts menu ---history {images,video} open history menus ---paste upload text from clipboard ---togglecast start/stop screencast ---quick image {area,fullscreen,all,active} quickly create screenshot and upload ---quick video {area,fullscreen} quickly create screenshot and optionally upload ---quickcopy {area,fullscreen,all} quickly create screenshot and copy -EOF -} - - - -if [[ $1 == "--screenshot" ]]; then check_img_path; screenshotMenu -elif [[ $1 == "--screencast" ]]; then check_vid_path; screencastMenu -elif [[ $1 == "--paste" ]]; then check_paste_path; export filename="${paste_filemask}" && clipCmd && teiler_helper --upload text "${filename}" -elif [[ $1 == "--togglecast" ]]; then check_vid_path; askPrompt -elif [[ $1 == "--history" ]]; then - if [[ $2 == "images" ]]; then check_img_path; imageMenu - elif [[ $2 == "videos" ]]; then check_vid_path; videoMenu - fi -elif [[ $1 == "--quick" ]]; then - if [[ $2 == "image" ]]; then - check_img_path - filename="${img_filemask}" - if [[ $3 == "area" ]]; then maimCmd area "${filename}" && cd "${img_path}" && teiler_helper --upload image "${filename}" - elif [[ $3 == "active" ]]; then maimCmd active "${filename}" && cd "${img_path}" && teiler_helper --upload image "${filename}" - elif [[ $3 == "fullscreen" ]]; then maimCmd fullscreen "${filename}" && cd "${img_path}" && teiler_helper --upload image "${filename}" - elif [[ $3 == "all" ]]; then maimCmd fullscreenAll "${filename}" && cd "${img_path}" && teiler_helper --upload image "${filename}" - fi - elif [[ $2 == "video" ]]; then - check_vid_path - filename="${vid_filemask}" - if [[ $3 == "area" ]]; then isRecording && askPrompt && sleep 2 || ffmpegCmd area; - elif [[ $3 == "fullscreen" ]]; then isRecording && askPrompt && sleep 2 || ffmpegCmd fullscreen; - fi - else echo "possible options for \"--quick\": image, video" - fi - -elif [[ $1 == "--quickcopy" ]]; then - check_img_path; - filename="${img_filemask}" - if [[ $2 == "area" ]]; then copyq & maimCmd area "${filename}" && cd "${img_path}" && copyq write image/png - < "${filename}"; copyq select 0 - elif [[ $2 == "fullscreen" ]]; then copyq & maimCmd fullscreen "${filename}" && cd "${img_path}" && copyq write image/png - < "${filename}"; copyq select 0 - elif [[ $2 == "all" ]]; then copyq & maimCmd fullscreenAll "${filename}" && cd "${img_path}" && copyq write image/png - < "${filename}"; copyq select 0 - fi -elif [[ $1 == "--help" || $1 == "-h" ]]; then - helpCmd -else - check_img_path; check_vid_path; mainMenu -fi diff --git a/teiler_helper b/teiler_helper deleted file mode 100755 index fe94f63..0000000 --- a/teiler_helper +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env bash - -source $HOME/.config/teiler/config -if [[ "$img_ul" == "s3" || "$img_ul" == "scp" ]]; then - source $HOME/.config/teiler/uploader/$img_ul -fi -if [[ "$vid_ul" == "s3" || "$vid_ul" == "scp" ]]; then - source $HOME/.config/teiler/uploader/$vid_ul -fi -if [[ "$paste_ul" == "s3" || "$paste_ul" == "scp" ]]; then - source $HOME/.config/teiler/uploader/$paste_ul -fi - -# define uploaders -# images -if [[ $img_ul == "fb" ]]; then - imageUpload () { - if [[ $(echo "$files" | wc -w) -gt 1 ]]; then - cd "${img_path}"; fb -m ${@}; x_clip; notify-send -a "teiler" "Image Uploaded" "$(xclip -o)" - else - cd "${img_path}"; fb ${@}; x_clip; notify-send -a "teiler" "Image Uploaded" "$(xclip -o)"; - fi - } - -elif [[ $img_ul == "scp" ]]; then - imageUpload () { for x in $files; do scpUpload "Image" "${img_path}" "$x" "${scp_host}" "${scp_path_img}" "${http_img}"; done; } -elif [[ $img_ul == "imgur" ]]; then - imageUpload () { cd "${img_path}"; for x in $files; do imgurbash2 "${x}"; x_clip; notify-send -a "teiler" "Image Uploaded" "$(xclip -o)"; done; } -elif [[ $img_ul == "s3" ]]; then - imageUpload () { cd "${img_path}"; s3cmd --no-progress put "${1}" "s3://${s3_bucket}/${s3_path_img}/"; notify-send -a "teiler" "Image Uploaded" "${s3_http_img}/${1}"; echo -n "${s3_http_img}/${1}" | xclip; x_clip; } -else - imageUpload () { echo "No image uploader set. check example config"; } -fi - - -# Videos -if [[ $vid_ul == "fb" ]]; then - videoUpload () { cd "${vid_path}"; fb "${1}"; x_clip; notify-send -a "teiler" "Video Uploaded" "$(xclip -o)"; } -elif [[ $vid_ul == "scp" ]]; then - videoUpload () { scpUpload "Video" "${vid_path}" "$1" "${scp_host}" "${scp_path_vid}" "${http_vid}"; } -elif [[ $vid_ul == "s3" ]]; then - videoUpload () { cd "${vid_path}"; s3cmd --no-progress put "${1}" "s3://${s3_bucket}/${s3_path_vid}/"; notify-send -a "teiler" "Video Uploaded" "${s3_http_vid}/${1}"; echo -n "${s3_http_vid}/${1}" | xclip; x_clip; } -else - videoUpload () { echo "No video uploader set. Check example config"; } -fi - -# text -if [[ $paste_ul == "fb" ]]; then - clipUpload () { cd "${paste_path}"; fb "${1}"; x_clip; notify-send -a "teiler" "Paste Uploaded" "$(xclip -o)"; } -elif [[ $paste_ul == "scp" ]]; then - clipUpload () { scpUpload "Paste" "${paste_path}" "$1" "${scp_host}" "${scp_path_paste}" "${http_paste}"; } -elif [[ $paste_ul == "ix" ]]; then - clipUpload () { xclip -o 2>&1 | curl -F 'f:1=<-' ix.io | tr -d "\n" | xclip; x_clip; notify-send -a "teiler" "Paste Uploaded" "$(xclip -o)"; } -else - clipUpload () { echo "No text uploader set. Check example config"; } -fi - -scpUpload() { - fileType="$1"; - path="$2"; - filename="$3"; - scp_host="$4"; - scp_path="$5"; - http="$6"; - cd "${path}"; - scpResult="$(scp "$filename" "${scp_host}:/${scp_path}/${filename}" 2>&1)"; - if [[ "$?" == 0 ]]; then - notify-send -a "teiler" "${fileType} Uploaded" "${http}/${filename}"; - echo -n "${http}/${filename}" | xclip; - x_clip; - else - notify-send -a "teiler" "${fileType} upload failed" "$scpResult"; - fi; -} - -x_clip () { - if [[ $img_ul == "imgur" ]]; then - (xclip -o -selection clipboard) | xclip - else - (xclip -o) | xclip -selection clipboard - fi -} - -if [[ $1 == "--upload" ]]; then - files=$(echo "$@" | cut -d ' ' -f3-) - if [[ $2 == "image" ]]; then imageUpload "${files}" - elif [[ $2 == "video" ]]; then videoUpload "${files}" - elif [[ $2 == "text" ]]; then clipUpload "${files}" - fi -fi diff --git a/uploader/s3 b/uploader/s3 deleted file mode 100755 index 7f7a02b..0000000 --- a/uploader/s3 +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -s3_bucket= -s3_path_img=path/to/images -s3_path_vid=path/to/videos -s3_path_paste=path/to/pastes -s3_http_img=http://S3_DOMAIN/path/to/images -s3_http_vid=http://S3_DOMAIN/path/to/videos -s3_http_paste=http://S3_DOMAIN/path/to/pastes diff --git a/uploader/scp b/uploader/scp deleted file mode 100755 index c53584d..0000000 --- a/uploader/scp +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -scp_host=HOSTNAME -scp_path_img=/path/to/images -scp_path_vid=/path/to/videos -scp_path_paste=/path/to/pastes -http_img=https://YOUR_DOMAIN/path/to/images -http_vid=https://YOUR_DOMAIN/path/to/videos -http_paste=https://YOUR_DOMAIN/path/to/pastes