Files
sxmo-utils/scripts/appscripts/sxmo_reddit.sh
Willow Barraco 4913fac4ee Cleanup virtual keyboard management
Some devices doesn't need a virtual keyboard, aka Nokia N900, aka
Pinephone with keyboard. This give a way to disable this feature
completely.

Also, we remove the sxmo_dmenu_with_kb.sh script, cause it is poorly
used, and give inconsistent behavior between menus. The user can already open
the keyboard very easily.

For this same reason, we remove some random "sxmo_keyboards.sh open". If
this isn't necessary cause of a specific usage (aka dtmf special
layout.

I also dropped some code in sxmo_dmenu.sh that adapt the available size
depending on if the keyboard is open or not. The keyboard can be open
later, so this is dumb to rely on this, and we should alway be able to
open/close it, and to read all lines.

I adapted the inputhandler a bit when keyboard is disabled. If you guys
think about better usage of freed handler, I'm open!
2024-03-25 17:32:26 +01:00

43 lines
1.0 KiB
Bash
Executable File

#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2022 Sxmo Contributors
# title="$icon_red Reddit"
# include common definitions
# shellcheck source=scripts/core/sxmo_common.sh
. sxmo_common.sh
[ -z "$SXMO_SUBREDDITS" ] && SXMO_SUBREDDITS="pine64official pinephoneofficial unixporn postmarketos linux"
menu() {
SUBREDDIT="$(
printf %b "Close Menu\n$(echo "$SXMO_SUBREDDITS" | tr " " '\n')" |
sxmo_dmenu.sh -p "Subreddit:"
)" || exit 0
[ "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
)" || exit 0
[ "Close Menu" = "$RESULT" ] && exit 0
URL=$(echo "$RESULT" | awk -F " " '{print $NF}')
sxmo_urlhandler.sh "$URL"
done
}
menu