Make close menu entry in scripts more functional

master
Miles Alan 5 years ago
parent f4aea53ad1
commit 34cd1fd5bb
  1. 9
      scripts/appscripts/sxmo_reddit.sh
  2. 2
      scripts/appscripts/sxmo_websearch.sh
  3. 11
      scripts/appscripts/sxmo_youtube.sh

@ -4,10 +4,11 @@
menu() { menu() {
pidof svkbd-sxmo || svkbd-sxmo & pidof svkbd-sxmo || svkbd-sxmo &
SUBREDDIT="$( SUBREDDIT="$(
printf %b "$(echo "$SXMO_SUBREDDITS" | tr " " '\n')" | printf %b "Close Menu\n$(echo "$SXMO_SUBREDDITS" | tr " " '\n')" |
dmenu -p "Subreddit:" -c -l 10 -fn Terminus-20 dmenu -p "Subreddit:" -c -l 10 -fn Terminus-20
)" )"
pkill svkbd-sxmo pkill svkbd-sxmo
[ "Close Menu" = "$SUBREDDIT" ] && exit 0
REDDITRESULTS="$( REDDITRESULTS="$(
reddit-cli "$SUBREDDIT" | reddit-cli "$SUBREDDIT" |
@ -16,16 +17,16 @@ menu() {
tr -d '\n' | tr -d '\n' |
sed 's/===/\n/g' | sed 's/===/\n/g' |
sed 's/^\t//g' | sed 's/^\t//g' |
sort -rk3,3 | sort -t$'\t' -rnk4 |
awk -F'\t' '{ printf "↑%4s", $3; print " " $4 " " $1 " " $2 }' awk -F'\t' '{ printf "↑%4s", $3; print " " $4 " " $1 " " $2 }'
)" )"
RESULT="$( RESULT="$(
echo "$REDDITRESULTS" | printf %b "Close Menu\n$REDDITRESULTS" |
dmenu -c -l 10 -fn Terminus-20 dmenu -c -l 10 -fn Terminus-20
)" )"
[ "CLOSE_MENU" = "$RESULT" ] && exit 0 [ "Close Menu" = "$RESULT" ] && exit 0
URL=$(echo "$RESULT" | awk -F " " '{print $NF}') URL=$(echo "$RESULT" | awk -F " " '{print $NF}')
$BROWSER "$URL" $BROWSER "$URL"

@ -4,6 +4,8 @@ SEARCHQUERY="$(
echo "Close Menu" | dmenu -t -p "Search Query:" -c -fn "Terminus-20" -l 20 echo "Close Menu" | dmenu -t -p "Search Query:" -c -fn "Terminus-20" -l 20
)" )"
pkill svkbd-sxmo pkill svkbd-sxmo
[ "Close Menu" = "$SEARCHQUERY" ] && exit 0
echo "$SEARCHQUERY" | grep . || exit 0 echo "$SEARCHQUERY" | grep . || exit 0
$BROWSER "https://duckduckgo.com/?q=${SEARCHQUERY}" $BROWSER "https://duckduckgo.com/?q=${SEARCHQUERY}"

@ -2,23 +2,28 @@
menu() { menu() {
pidof svkbd-sxmo || svkbd-sxmo & pidof svkbd-sxmo || svkbd-sxmo &
SEARCHTERMS="$( SEARCHTERMS="$(
echo "Search term" | echo "Close Menu\n" |
dmenu -p "Yt Search" -c -l 10 -fn Terminus-20 dmenu -p "Yt Search" -c -l 10 -fn Terminus-20
)" )"
pkill svkbd-sxmo pkill svkbd-sxmo
[ "CLOSE_MENU" = "$SEARCHTERMS" ] && exit 0
IDIOTRESULTS="$(youtube-cli "$SEARCHTERMS")" IDIOTRESULTS="$(youtube-cli "$SEARCHTERMS")"
RESULT="$( FMTRESULTS="$(
echo "$IDIOTRESULTS" | echo "$IDIOTRESULTS" |
grep -Ev '^(Channelid|Atom feed|Channel title|Published|Viewcount|Userid):' | grep -Ev '^(Channelid|Atom feed|Channel title|Published|Viewcount|Userid):' |
sed -E 's/^(URL|Duration):\s+/\t/g' | sed -E 's/^(URL|Duration):\s+/\t/g' |
tr -d '\n' | tr -d '\n' |
sed 's/===/\n/g' | sed 's/===/\n/g' |
gawk -F'\t' '{ print $3 " " $1 " " $2}' | gawk -F'\t' '{ print $3 " " $1 " " $2}' |
dmenu -c -l 10 -fn Terminus-20
)" )"
URL="$(
printf %b "Close Menu\n$FMTRESULTS" |
dmenu -c -l 10 -fn Terminus-20
)"
[ "CLOSE_MENU" = "$RESULT" ] && exit 0 [ "CLOSE_MENU" = "$RESULT" ] && exit 0
URL=$(echo "$RESULT" | awk -F " " '{print $NF}') URL=$(echo "$RESULT" | awk -F " " '{print $NF}')
} }

Loading…
Cancel
Save