Files
sxmo-utils/scripts/appscripts/sxmo_reddit.sh
Stacy Harper 8a27933c47 SWMO - SXMO over Wayland
This is a huge patch for Swmo, Sxmo over Sway.

It is Dwm backward compatible so dwm users should not expect regressions.

If you install all dependencies, you then can toggle between Sway and Dwm using a new config entry. It will reboot the phone.

This commit also contains:
    * Make the modemmonitor bullet proof
    * various other smaller fixes

Signed-off-by: Stacy Harper <contact@stacyharper.net>
Signed-off-by: Maarten van Gompel <proycon@anaproy.nl>
2021-08-22 13:23:22 +02:00

43 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env sh
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. "$(dirname "$0")/sxmo_common.sh"
[ -z "$SXMO_SUBREDDITS" ] && SXMO_SUBREDDITS="pine64official pinephoneofficial unixporn postmarketos linux"
menu() {
sxmo_keyboard.sh open
SUBREDDIT="$(
printf %b "Close Menu\n$(echo "$SXMO_SUBREDDITS" | tr " " '\n')" |
sxmo_dmenu.sh -p "Subreddit:"
)"
sxmo_keyboard.sh close
[ "Close Menu" = "$SUBREDDIT" ] && exit 0
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 -t"$(printf '%b' '\t')" -rnk4 |
awk -F'\t' '{ printf "↑%4s", $3; print " " $4 " " $1 " " $2 }'
)"
while true; do
RESULT="$(
printf %b "Close Menu\n$REDDITRESULTS" |
sxmo_dmenu.sh -fn Terminus-20
)"
[ "Close Menu" = "$RESULT" ] && exit 0
URL=$(echo "$RESULT" | awk -F " " '{print $NF}')
sxmo_urlhandler.sh "$URL" fork
done
}
menu