From f4aea53ad11f56f1e8e5b1b08b5612e72be05a78 Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Sat, 20 Jun 2020 10:05:08 -0500 Subject: [PATCH] Add reddit script --- scripts/appscripts/sxmo_reddit.sh | 34 +++++++++++++++++++++++++++++++ scripts/core/sxmo_appmenu.sh | 1 + 2 files changed, 35 insertions(+) create mode 100755 scripts/appscripts/sxmo_reddit.sh diff --git a/scripts/appscripts/sxmo_reddit.sh b/scripts/appscripts/sxmo_reddit.sh new file mode 100755 index 0000000..a49cae2 --- /dev/null +++ b/scripts/appscripts/sxmo_reddit.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env sh +[ -z "$SXMO_SUBREDDITS" ] && SXMO_SUBREDDITS="pine64official pinephoneofficial unixporn postmarketos linux" + +menu() { + pidof svkbd-sxmo || svkbd-sxmo & + SUBREDDIT="$( + printf %b "$(echo "$SXMO_SUBREDDITS" | tr " " '\n')" | + dmenu -p "Subreddit:" -c -l 10 -fn Terminus-20 + )" + pkill svkbd-sxmo + + REDDITRESULTS="$( + reddit-cli "$SUBREDDIT" | + grep -E '^((created_utc|ups|title|url):|===)' | + sed -E 's/^(created_utc|ups|title|url):\s+/\t/g' | + tr -d '\n' | + sed 's/===/\n/g' | + sed 's/^\t//g' | + sort -rk3,3 | + awk -F'\t' '{ printf "↑%4s", $3; print " " $4 " " $1 " " $2 }' + )" + + RESULT="$( + echo "$REDDITRESULTS" | + dmenu -c -l 10 -fn Terminus-20 + )" + + [ "CLOSE_MENU" = "$RESULT" ] && exit 0 + URL=$(echo "$RESULT" | awk -F " " '{print $NF}') + + $BROWSER "$URL" +} + +menu diff --git a/scripts/core/sxmo_appmenu.sh b/scripts/core/sxmo_appmenu.sh index 253f4eb..d27171e 100755 --- a/scripts/core/sxmo_appmenu.sh +++ b/scripts/core/sxmo_appmenu.sh @@ -29,6 +29,7 @@ programchoicesinit() { Youtube (Audio) ^ 0 ^ sxmo_youtube.sh audio Weather ^ 0 ^ sxmo_weather.sh RSS ^ 0 ^ sxmo_rss.sh + Reddit ^ 0 ^ sxmo_reddit.sh " WINNAME=Scripts elif echo "$WMCLASS" | grep -i "applications"; then