diff --git a/bookmark.sh b/bookmark.sh index 9152853..8df9753 100755 --- a/bookmark.sh +++ b/bookmark.sh @@ -83,7 +83,9 @@ fi if [ ! -z "$GUI" ];then posters=$(yad --width=400 --height=400 --center --window-icon=gtk-network --borders 3 --skip-taskbar --title="Choose outputs for $link" --text="${title}" --checklist --list --column=Use:RD --column=metadata:text $( /usr/bin/ls -A "$SCRIPT_DIR/out_enabled" | sed 's/.sh//g' | grep -v ".keep" | sed 's/^/false /' ) | awk -F '|' '{ print $2 }' | sed 's/$/.sh&/p' | awk '!_[$0]++' ) else - posters=$(/usr/bin/ls -A "$SCRIPT_DIR/out_enabled" | sed 's/.sh//g' | grep -v ".keep" | fzf --multi | sed 's/$/.sh&/p' | awk '!_[$0]++' ) + header_text=$(echo -e "Title: ${title} \n Link: ${link}") + prompt_text="Choose your outputs!" + posters=$(/usr/bin/ls -A "$SCRIPT_DIR/out_enabled" | sed 's/.sh//g' | grep -v ".keep" | fzf --multi --header="$header_text" --header-lines=0 --prompt="$prompt_text" | sed 's/$/.sh&/p' | awk '!_[$0]++' ) fi for p in $posters;do @@ -98,6 +100,11 @@ for p in $posters;do done # TODO: add preview function to each of the modules for fzf --preview giving a quick explanation of what it does +# CHECK FOR THIS by checking for the preview string which will contain the path of the posters!!!!!!!!!!!!! so +# bookmarker_preview=$(ps aux | grep fzf | grep -v "grep" | grep -c ${SCRIPT_DIR}/out_enabled") +# so if that's > 0 then.... yup. # TODO: modules for each possible browser? # TODO: Allow calling an editor with multiselect capabilities of fzf? # TODO: Preview current values (and allow editing of) with fzf selection screen + + diff --git a/out_avail/add_to_todo.sh b/out_avail/add_to_todo.sh index 77c8501..fbb6155 100644 --- a/out_avail/add_to_todo.sh +++ b/out_avail/add_to_todo.sh @@ -10,12 +10,20 @@ function add_to_todo_send { - + # todo-cli binary=$(which todo-txt) if [ -f ${binary} ];then outstring=$(printf "%s : %s" "$title" "$link") outstring=$(echo "$binary a \"$outstring\"") eval ${outstring} + else + # todoman python package + binary=$(which todo) + if [ -f ${binary} ];then + outstring=$(printf "%s : %s" "$title" "$link") + outstring=$(echo "$binary new \"${outstring}\"") + eval ${outstring} + fi fi } ############################################################################## diff --git a/out_avail/facebook.sh b/out_avail/chromium.sh similarity index 58% rename from out_avail/facebook.sh rename to out_avail/chromium.sh index 8bbe50f..6fd7fd3 100644 --- a/out_avail/facebook.sh +++ b/out_avail/chromium.sh @@ -1,22 +1,13 @@ #!/bin/bash -############################################################################## -# -# sending script -# (c) Steven Saus 2024 -# Licensed under the MIT license -# -# REQUIRES URLENCODE which is in package gridsite-clients on Debian -# REQUIRES sensible-browser to be set up -############################################################################## +function chromium_send { + + /usr/bin/chromium/firefox --new-tab "$link" -function facebook_send { - tmp=$(urlencode "${link}") - link="https://www.facebook.com/sharer/sharer.php?u=${tmp}" - outstring=$(echo "sensible-browser ${link} ") - eval ${outstring} > /dev/null } + + ############################################################################## # Are we sourced? # From http://stackoverflow.com/questions/2683279/ddg#34642589 @@ -40,6 +31,6 @@ else if [ ! -z "$2" ];then title="$2" fi - facebook_send + gui_browser_send fi fi diff --git a/out_avail/firefox.sh b/out_avail/firefox.sh new file mode 100644 index 0000000..920451d --- /dev/null +++ b/out_avail/firefox.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +function firefox_send { + + /usr/bin/firefox --new-tab "$link" + +} + + + +############################################################################## +# Are we sourced? +# From http://stackoverflow.com/questions/2683279/ddg#34642589 +############################################################################## + +# Try to execute a `return` statement, +# but do it in a sub-shell and catch the results. +# If this script isn't sourced, that will raise an error. +$(return >/dev/null 2>&1) + +# What exit code did that give? +if [ "$?" -eq "0" ];then + echo "[info] Function ready to go." + OUTPUT=0 +else + OUTPUT=1 + if [ "$#" = 0 ];then + echo -e "Please call this as a function or with \nthe url as the first argument and optional \ndescription as the second." + else + link="${1}" + if [ ! -z "$2" ];then + title="$2" + fi + gui_browser_send + fi +fi diff --git a/out_avail/gui_browser.sh b/out_avail/gui_browser.sh index a3d6071..207f793 100644 --- a/out_avail/gui_browser.sh +++ b/out_avail/gui_browser.sh @@ -2,9 +2,12 @@ function gui_browser_send { - /home/steven/apps/firefox/firefox --new-tab "$link" + /home/steven/apps/waterfox/waterfox --new-tab "$link" } + + + ############################################################################## # Are we sourced? # From http://stackoverflow.com/questions/2683279/ddg#34642589 diff --git a/out_avail/work_browser.sh b/out_avail/work_browser.sh new file mode 100644 index 0000000..b2523ce --- /dev/null +++ b/out_avail/work_browser.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +function work_browser_send { + + /home/steven/apps/waterfox/waterfox -P work -no-remote --class workWaterfoxProfile "$link" + +} + + + +############################################################################## +# Are we sourced? +# From http://stackoverflow.com/questions/2683279/ddg#34642589 +############################################################################## + +# Try to execute a `return` statement, +# but do it in a sub-shell and catch the results. +# If this script isn't sourced, that will raise an error. +$(return >/dev/null 2>&1) + +# What exit code did that give? +if [ "$?" -eq "0" ];then + echo "[info] Function ready to go." + OUTPUT=0 +else + OUTPUT=1 + if [ "$#" = 0 ];then + echo -e "Please call this as a function or with \nthe url as the first argument and optional \ndescription as the second." + else + link="${1}" + if [ ! -z "$2" ];then + title="$2" + fi + gui_browser_send + fi +fi diff --git a/urlportal.sh b/urlportal.sh new file mode 100644 index 0000000..42333b2 --- /dev/null +++ b/urlportal.sh @@ -0,0 +1,395 @@ +#!/bin/bash +# +# _ _ _ _ +# __ _ ___ | |_| |__ | | ___| |_ _ _ +# / _` |/ _ \| __| '_ \| |/ _ \ __| | | | +#| (_| | (_) | |_| |_) | | __/ |_| |_| | +# \__, |\___/ \__|_.__/|_|\___|\__|\__,_| +# |___/ +# https://www.youtube.com/user/gotbletu +# https://twitter.com/gotbletu +# https://github.com/gotbletu +# gotbletu@gmail.com + +# _ _ _ +# _ _ _ __| |_ __ ___ _ __| |_ __ _| | +# | | | | '__| | '_ \ / _ \| '__| __/ _` | | +# | |_| | | | | |_) | (_) | | | || (_| | | +# \__,_|_| |_| .__/ \___/|_| \__\__,_|_| +# |_| +# DESC: custom way to handle url (similar idea to xdg-open, mailcap) +# works with just about all programs (e.g w3m, rtv, newsboat, urlview ...etc) +# DEMO: https://www.youtube.com/watch?v=2jyfrmBYzVQ +# install: lynx youtube-dl task-spooler newsboat rtv w3m mpv urlview tmux feh plowshare streamlink curl coreutils + +# Originally from https://github.com/gotbletu/shownotes/blob/master/urlportal.sh +# Edited by Steven Saus +# * -g switch to use GUI instead of CLI +# * -c switch to use CLI instead of GUI +# * Configurable default of the above +# * Switched references to rtv to tuir + +# newsboat: +# vim ~/.newsboat/config +# browser ~/.scripts/urlportal.sh + +# tuir: +# vim ~/.bashrc +# export TUIR_BROWSER=~/.scripts/urlportal.sh + +# w3m: +# vim ~/.w3m/keymap +# open url under cursor (default: Esc+Shift+M); e.g 2+Esc+Shift+M +# keymap e EXTERN_LINK ~/.scripts/urlportal.sh + +# urlview: +# vim ~/.urlview +# COMMAND ~/.scripts/urlportal.sh + +# references: +# cirrusuk http://arza.us/paste/piper +# obosob https://github.com/michael-lazar/rtv/issues/78#issuecomment-125507472 +# budlabs - mpv queue https://www.youtube.com/watch?v=-vbr3-mHoRs +# https://github.com/budlabs/youtube/blob/master/letslinux/032-queue-files-in-mpv/openvideo +# ji99 - mpv queue script https://www.reddit.com/r/commandline/comments/920p5d/bash_script_for_queueing_youtube_links_in_mpv/ + +############################################################################## +# +# Define your helper applications here. These are the ones I use, but edit +# however you like. +# +############################################################################## +BROWSERCLI="elinks" +BROWSERGUI="xdg-open" +DEFAULT="$BROWSERCLI" +## long videos like youtube +VIDEO_QUEUE="tsp mpv --ontop --no-border --force-window --autofit=900x600 --geometry=-15-53" +## short videos/animated gif clips +VIDEO_CLIP="mpv --loop --quiet --ontop --no-border --force-window --autofit=900x600 --geometry=-15+60" +IMAGEGUI="feh -. -x -B black -g --insecure --keep-http --output-dir /home/steven/tmp --geometry=600x600+15+60" +# IMAGECLI="w3m /usr/lib/w3m/cgi-bin/treat_as_url.cgi -o display_image=1 -o imgdisplay=/usr/lib/w3m/w3mimgdisplay" +# IMAGECLI="chafa --colors=256 --dither=diffusion" +IMAGECLI="/usr/local/bin/image" +TORRENTCLI="transmission-remote --add" +# LIVEFEED='streamlink -p "mpv --cache 2048 --ontop --no-border --force-window --autofit=500x280 --geometry=-15-60"' +LIVEFEED="tsp streamlink" +DDL_PATH=~/Downloads/plowshare +DDL_QUEUE_FAST=~/.config/plowshare/queuefast.txt + +############################################################################## +#Change to false if you want to have it be GUI only by default +############################################################################## +CliOnly="true" + + +display_help (){ + echo "Configure the script with the helper programs you like. " + echo "Call with -g to use graphical options" + exit +} + +# Addition of command line switch for GUI/CLI +# Because that URL should be escaped, we should be okay leaving it as $1 + while [ $# -gt 0 ]; do + option="$1" + case $option in + -h) display_help + exit + shift ;; + -c) CliOnly="true" + shift ;; + -g) CliOnly="false" + shift ;; + *) url="$1" + shift;; + esac + done + + + +# enable case-insensitive matching +shopt -s nocasematch + + +case "$url" in + *gfycat.com/*|*streamable.com/*) + nohup $VIDEO_CLIP "${url/.gifv/.webm}" > /dev/null 2>&1 & + ;; + *v.redd.it/*|*video.twimg.com/*|*dailymotion.com*) + nohup $VIDEO_CLIP "$url" > /dev/null 2>&1 & + ;; + *youtube.com/watch*|*youtu.be/*|*clips.twitch.tv/*) + $VIDEO_QUEUE "$url" + ;; + *twitch.tv/*) + $LIVEFEED "$url" + ;; + *pornhub.com/*|*xvideos.com/*) + # $VIDEO_QUEUE "$url" + nohup $VIDEO_CLIP "$url" > /dev/null 2>&1 & + ;; + ########################################################################## + # Added by Steven Saus + # For Subreddits where it's just an image post + ########################################################################## + i.redd.it/*) + if [ "${CliOnly}" = "false" ];then + CommandLine=$(echo "nohup ${IMAGEGUI} ${cleanurl} &") + eval "${CommandLine}" + else + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + fi + ;; + + *r/dndmemes/*|*r/memes/*|*r/reactiongifs/*|*r/quotesporn/*|*r/spaceporn/*|*r/detailcraft/*|*r/minecraftinventions/*|*r/gonemildplus/*|*r/kink/*|*r/gonewild/*|*r/realgirls/*) + cleanurl="$(wget --load-cookies $HOME/vault/cookies.txt -q "$url" -O - | grep -oP '"media":{"obfuscated":null,"content":"\K[^"]+')" + if [ "${CliOnly}" = "false" ];then + CommandLine=$(echo "nohup ${IMAGEGUI} ${cleanurl} &") + eval "${CommandLine}" + else + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + fi + ;; + *reddit.com/r/*) + tmux new-window -n rtv && tmux send-keys "rtv -l $url && tmux kill-pane" 'Enter' + ;; + *glodls.to/*|*eogli.org/*|*limetorrents.io/*|*limetorrents.cc/*|*pornoshara.tv/item*|*rustorrents.net/details*|*xxx-tracker.com/*) + tmux new-window -n browse && tmux send-keys "$BROWSERCLI '$url' && tmux kill-pane" 'Enter' + ;; + *thepiratebay.org/*|*torrentdownloads.me/*|*yourbittorrent2.com/*|*torlock2.com/*|*bt-scene.cc/*|*rarbg.to/*|*ettorrent.xyz/*) + tmux new-window -n browse && tmux send-keys "$BROWSERCLI '$url' && tmux kill-pane" 'Enter' + ;; + *22pixx.xyz/ia-i/*) + cleanurl="$(printf $url | sed 's/ia-i/i/g' | sed 's/\.html//g')" + if [ "${CliOnly}" = "false" ];then + CommandLine=$(echo "nohup ${IMAGEGUI} ${cleanurl} &") + eval "${CommandLine}" + else + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + fi + ;; + *freebunker.com/*) + cleanurl="$(printf $url | sed 's@img\/@tn\/i@')" + if [ "${CliOnly}" = "false" ];then + CommandLine=$(echo "nohup ${IMAGEGUI} ${cleanurl} &") + eval "${CommandLine}" + else + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + fi + ;; + *imagerar.com/t/*) + cleanurl="$(printf $url | sed 's@/t@/u@')" + if [ "${CliOnly}" = "false" ];then + CommandLine=$(echo "nohup ${IMAGEGUI} ${cleanurl} &") + eval "${CommandLine}" + else + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + fi + ;; + *imagerar.com/imgy-u/*) + cleanurl="$(printf $url | sed 's/imgy-u/u/g' | sed 's/.html//g')" + if [ "${CliOnly}" = "false" ];then + CommandLine=$(echo "nohup ${IMAGEGUI} ${cleanurl} &") + eval "${CommandLine}" + else + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + fi + ;; + *imageshtorm.com/upload/small/*|*hotimage.uk/upload/small/*|*hdmoza.com//upload/small/*|*nikapic.ru/upload/small/*|*imagedecode.com/upload/small/*|*trans.firm.in//upload/small/*) + cleanurl="$(printf $url | sed 's/small/big/')" + if [ "${CliOnly}" = "false" ];then + CommandLine=$(echo "nohup ${IMAGEGUI} ${cleanurl} &") + eval "${CommandLine}" + else + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$cleanurl' && tmux kill-pane" 'Enter' + fi + ;; + *imageshtorm.com/img*) + cleanurl="$(curl -s "$url" | grep onclick | grep -oP ' /dev/null 2>&1 & + ;; + *i.imgur.com/*| *imgur.com/*.*) + # nohup $IMAGEGUI "$url" > /dev/null 2>&1 & + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$url' && tmux kill-pane" 'Enter' + ;; + *imgur.com/*) + # tmux split-window && tmux send-keys "lynx -source "$url" | grep post-image-container | grep -oP '
/dev/null 2>&1 & + else + tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$url' ; read && tmux kill-pane" 'Enter' + fi + #tmux new-window -n pixcli && tmux send-keys "$IMAGECLI '$url' && tmux kill-pane" 'Enter' + ;; + *.gif) + nohup $VIDEO_CLIP "${url/.gifv/.webm}" > /dev/null 2>&1 & + ;; + *zippyshare.com/*|*mediafire.com/file/*|*sendspace.com/file/*) + if pgrep -f $DDL_QUEUE_FAST > /dev/null + then + echo "$url" >> $DDL_QUEUE_FAST + else + echo "$url" >> $DDL_QUEUE_FAST + cat $DDL_QUEUE_FAST | awk '!x[$0]++' | sponge $DDL_QUEUE_FAST + tmux split-window -fv -p 20 && tmux send-keys "until [[ \$(cat $DDL_QUEUE_FAST | grep -v '#' | wc -l) -eq 0 ]]; do mkdir -p $DDL_PATH && cd $DDL_PATH && plowdown -m $DDL_QUEUE_FAST -o $DDL_PATH ; done" 'Enter' + fi + ;; + *.mp4|*.mkv|*.avi|*.wmv|*.m4v|*.mpg|*.mpeg|*.flv|*.ogm|*.ogv|*.gifv) + $VIDEO_QUEUE "$url" + ;; + *.mp3|*.m4a|*.wav|*.ogg|*.oga|*.flac) + # create queue fifo files if it does not exist + if [[ ! -p /tmp/mpvinput ]]; then + mkfifo /tmp/mpvinput + fi + + # check if process mpv exist (e.g mpv --input-file=/tmp/mpvinput filename.mp3) + if pgrep -f mpvinput > /dev/null + then + # if mpv is already running then append new url/files to queue + # echo loadfile \"${url/'/\\'}\" append-play > /tmp/mpvinput + echo loadfile \"$url\" append-play > /tmp/mpvinput + # nohup $VIDEO_CLIP "${url/.gifv/.webm}" > /dev/null 2>&1 & + else + # if mpv is not running then start it (initial startup) + # mpv --no-video --input-file=/tmp/mpvinput "$1" + tmux split-window -fv -p 20 && tmux send-keys "mpv --no-video --input-file=/tmp/mpvinput \"$url\" && exit" 'Enter' + fi + # Note: use "<" or ">" hotkeys to skip between songs/audio queue list on mpv + ;; + *|*.html) + # $DEFAULT "$url" + tmux new-window -n browse && tmux send-keys "$DEFAULT '$url' && tmux kill-pane" 'Enter' + ;; +esac +