Various minor script bugfixesmaster
parent
9beef511af
commit
ed09f2b8b3
20 changed files with 33534 additions and 122 deletions
@ -0,0 +1,32 @@ |
||||
#sfeedpath="$HOME/.sfeed/feeds" |
||||
USERAGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.162 Safari/537.36" |
||||
|
||||
#[ -z "$https_proxy" ] && echo "Please set https_proxy" 2>&1 && exit 1 |
||||
#[ -z "$http_proxy" ] && echo "Please set http_proxy" 2>&1 && exit 1 |
||||
|
||||
# fetch a feed via HTTP/HTTPS etc. |
||||
# fetch(name, url, feedfile) |
||||
fetch() { |
||||
# fail on redirects, hide User-Agent, timeout is 15 seconds. |
||||
curl -L --max-redirs 2 -H "User-Agent: $USERAGENT" -f -s -m 15 \ |
||||
"$2" 2>/dev/null |
||||
} |
||||
|
||||
# list of feeds to fetch: |
||||
feeds() { |
||||
# feed <name> <feedurl> [basesiteurl] [encoding] |
||||
feed 'Tech/HN' 'https://news.ycombinator.com/rss' |
||||
feed 'Tech/Lobsters' 'https://lobste.rs/rss' |
||||
feed 'Tech/Pine64' 'https://www.pine64.org/blog/' |
||||
feed 'Tech/Slashdot' 'http://feeds.feedburner.com/SlashdotSitenews' |
||||
feed 'Tech/Suckless' 'http://git.suckless.org/sites/atom.xml' |
||||
|
||||
feed 'Yt/Distrotube' 'https://www.youtube.com/feeds/videos.xml?channel_id=UCVls1GmFKf6WlTraIb_IaJg' |
||||
feed 'Yt/Budlabs' 'https://www.youtube.com/feeds/videos.xml?channel_id=UCi8XrDg1bK_MJ0goOnbpTMQ' |
||||
feed 'Yt/LukeSmith' 'https://www.youtube.com/feeds/videos.xml?channel_id=UC2eYFnH61tmytImy1mTYvhA' |
||||
feed 'Yt/Rossman' 'https://www.youtube.com/feeds/videos.xml?channel_id=UCl2mFZoRqjw_ELax4Yisf6w' |
||||
|
||||
feed 'MSM/CNN' 'http://rss.cnn.com/rss/cnn_topstories.rss' |
||||
feed 'MSM/Fox' 'http://feeds.foxnews.com/foxnews/latest' |
||||
} |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,148 @@ |
||||
#include <X11/XF86keysym.h> |
||||
#include <stdlib.h> |
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
#include <X11/keysym.h> |
||||
#include <X11/Xlib.h> |
||||
|
||||
static int running = 1; |
||||
static int lastkeysym = NULL; |
||||
static int lastkeyn = 0; |
||||
static int oldbrightness = 10; |
||||
static int screenon = 1; |
||||
static char screentogglecommand[100]; |
||||
|
||||
|
||||
void |
||||
updatescreen() { |
||||
sprintf( |
||||
screentogglecommand, |
||||
"sh -c 'echo %d > /sys/devices/platform/backlight/backlight/backlight/brightness'", |
||||
screenon ? oldbrightness : 0 |
||||
); |
||||
if (screenon) { |
||||
system("sh -c 'echo 1 > /sys/devices/platform/leds/leds/pinephone:blue:user/brightness'"); |
||||
system("sh -c 'echo 0 > /sys/devices/platform/leds/leds/pinephone:red:user/brightness'"); |
||||
} else { |
||||
system("sh -c 'echo 0 > /sys/devices/platform/leds/leds/pinephone:blue:user/brightness'"); |
||||
system("sh -c 'echo 1 > /sys/devices/platform/leds/leds/pinephone:red:user/brightness'"); |
||||
} |
||||
system(screentogglecommand); |
||||
} |
||||
|
||||
void |
||||
cleanupscreen() { |
||||
screenon = 1; |
||||
updatescreen(); |
||||
system("sh -c 'echo 0 > /sys/devices/platform/leds/leds/pinephone:red:user/brightness'"); |
||||
system("sh -c 'echo 0 > /sys/devices/platform/leds/leds/pinephone:blue:user/brightness'"); |
||||
} |
||||
|
||||
static void die(const char *err, ...) { |
||||
fprintf(stderr, "Error: %s", err); |
||||
cleanupscreen(); |
||||
exit(1); |
||||
} |
||||
static void usage(void) { |
||||
die("usage: slock [-v] [cmd [arg ...]]\n"); |
||||
} |
||||
|
||||
// Loosely derived from suckless' slock's lockscreen binding logic but
|
||||
// alot more coarse, intentionally so can be triggered while grab_key
|
||||
// for dwm multikey path already holding..
|
||||
void lockscreen(Display *dpy, int screen) { |
||||
int i, ptgrab, kbgrab; |
||||
//XSetWindowAttributes wa;
|
||||
Window root; |
||||
//win,
|
||||
root = RootWindow(dpy, screen); |
||||
//wa.override_redirect = 1;
|
||||
//win = XCreateWindow(dpy, root, 0, 0,
|
||||
// DisplayWidth(dpy, screen),
|
||||
// DisplayHeight(dpy, screen),
|
||||
// 0, DefaultDepth(dpy, screen),
|
||||
// CopyFromParent,
|
||||
// DefaultVisual(dpy, screen),
|
||||
// CWOverrideRedirect | CWBackPixel, &wa);
|
||||
for (i = 0, ptgrab = kbgrab = -1; i < 9999999; i++) { |
||||
if (ptgrab != GrabSuccess) { |
||||
ptgrab = XGrabPointer(dpy, root, False, |
||||
ButtonPressMask | ButtonReleaseMask | |
||||
PointerMotionMask, GrabModeAsync, |
||||
GrabModeAsync, None, None, CurrentTime); |
||||
} |
||||
if (kbgrab != GrabSuccess) { |
||||
kbgrab = XGrabKeyboard(dpy, root, True, |
||||
GrabModeAsync, GrabModeAsync, CurrentTime); |
||||
} |
||||
if (ptgrab == GrabSuccess && kbgrab == GrabSuccess) { |
||||
XSelectInput(dpy, root, SubstructureNotifyMask); |
||||
return; |
||||
} |
||||
usleep(100000); |
||||
} |
||||
return; |
||||
} |
||||
|
||||
|
||||
void |
||||
readinputloop(Display *dpy, int screen) { |
||||
KeySym keysym; |
||||
XEvent ev; |
||||
char buf[32]; |
||||
|
||||
while (running && !XNextEvent(dpy, &ev)) { |
||||
if (ev.type == KeyPress) { |
||||
XLookupString(&ev.xkey, buf, sizeof(buf), &keysym, 0); |
||||
if (lastkeysym == keysym) { |
||||
lastkeyn++; |
||||
} else { |
||||
lastkeysym = keysym; |
||||
lastkeyn = 1; |
||||
} |
||||
|
||||
if (lastkeyn < 3) |
||||
continue; |
||||
|
||||
lastkeyn = 0; |
||||
lastkeysym = NULL; |
||||
|
||||
switch (keysym) { |
||||
case XF86XK_AudioRaiseVolume: |
||||
screenon = !screenon; |
||||
updatescreen(); |
||||
|
||||
break; |
||||
case XF86XK_AudioLowerVolume: |
||||
screenon = !screenon; |
||||
updatescreen(); |
||||
break; |
||||
case XF86XK_PowerOff: |
||||
cleanupscreen(); |
||||
running = 0; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
int |
||||
main(int argc, char **argv) { |
||||
Display *dpy; |
||||
Screen *screen; |
||||
|
||||
|
||||
if (setuid(0)) |
||||
die("setuid(0) failed\n"); |
||||
if (!(dpy = XOpenDisplay(NULL))) |
||||
die("Cannot open display\n"); |
||||
|
||||
updatescreen(); |
||||
screen = XDefaultScreen(dpy); |
||||
XSync(dpy, 0); |
||||
lockscreen(dpy, screen); |
||||
XSync(dpy, 0); |
||||
readinputloop(dpy, screen); |
||||
return 0; |
||||
} |
@ -0,0 +1,3 @@ |
||||
#!/usr/bin/env sh |
||||
media-ctl -d /dev/media1 --set-v4l2 '"ov5640 3-004c":0[fmt:UYVY8_2X8/1280x720]' |
||||
mpv --video-rotate=90 av://v4l2:/dev/video1 |
@ -1,33 +0,0 @@ |
||||
#!/usr/bin/env sh |
||||
|
||||
power_1() { |
||||
pgrep -f sxmo_appmenu.sh || sxmo_keyboard.sh |
||||
} |
||||
power_2() { |
||||
st |
||||
} |
||||
power_3() { |
||||
surf |
||||
} |
||||
|
||||
voldown_1() { |
||||
pgrep -f sxmo_appmenu.sh && xdotool key Control+n || xdotool key Alt+Ctrl+period |
||||
} |
||||
voldown_2() { |
||||
xdotool key Alt+Shift+c |
||||
} |
||||
voldown_3() { |
||||
xdotool key Alt+Return |
||||
} |
||||
|
||||
volup_1() { |
||||
pgrep -f sxmo_appmenu.sh && xdotool key Control+p || sxmo_appmenu.sh |
||||
} |
||||
volup_2() { |
||||
echo nop |
||||
} |
||||
volup_3() { |
||||
echo nop |
||||
} |
||||
|
||||
$@ |
@ -0,0 +1,6 @@ |
||||
#!/usr/bin/env sh |
||||
OLDB=$(cat /tmp/oldscreenb || echo 10) |
||||
DIMB=2 |
||||
CURB=$(cat /sys/devices/platform/backlight/backlight/backlight/brightness) |
||||
|
||||
[[ $CURB == $DIMB ]] && sxmo_setpinebacklight $OLDB || sxmo_setpinebacklight $DIMB |
@ -1,6 +1,6 @@ |
||||
#!/usr/bin/env sh |
||||
|
||||
sxmo_keyboard.sh on & |
||||
pidof svkbd-sxmo || svkbd-sxmo & |
||||
OUTPUT="$(cat | dmenu -t $@)" |
||||
sxmo_keyboard.sh off |
||||
pkill svkbd-sxmo |
||||
echo "$OUTPUT" |
||||
|
@ -1,30 +0,0 @@ |
||||
#!/usr/bin/env sh |
||||
|
||||
P=/tmp/KEYTOG |
||||
|
||||
keyoff() { |
||||
kill -9 $(cat $P) |
||||
pgrep -f sxmo_keyboard.sh | grep -Ev "^${$}$" | xargs kill -9 |
||||
pkill -9 svkbd-en |
||||
pkill -9 svkbd-symbols |
||||
rm $P |
||||
} |
||||
|
||||
keyon() { |
||||
echo $$ >> $P |
||||
while : |
||||
do |
||||
svkbd-en -d |
||||
svkbd-symbols -d |
||||
done |
||||
} |
||||
|
||||
if [ "$1" == "on" ]; then |
||||
[ -f $P ] && keyoff |
||||
keyon |
||||
elif [ "$1" == "off" ]; then |
||||
[ -f $P ] && keyoff |
||||
else |
||||
# Default toggle |
||||
[ -f $P ] && keyoff || keyon |
||||
fi |
@ -1,18 +0,0 @@ |
||||
#!/usr/bin/env sh |
||||
TOUCHSCREENID=$( |
||||
xinput | |
||||
grep -i touchscreen | |
||||
grep pointer | |
||||
grep -oE 'id=[0-9]+' | |
||||
cut -d= -f2 |
||||
) |
||||
|
||||
xinput disable $TOUCHSCREENID |
||||
sxmo_setpineled blue 1 |
||||
OLDB="$(cat /sys/class/backlight/backlight/brightness)" |
||||
sxmo_setpinebacklight 0 |
||||
echo "Dragons?" | dmenu |
||||
|
||||
sxmo_setpinebacklight $OLDB |
||||
sxmo_setpineled blue 0 |
||||
xinput enable $TOUCHSCREENID |
@ -1,16 +1,23 @@ |
||||
#!/usr/bin/env sh |
||||
sxmo_keyboard.sh on & |
||||
INPUT="$(cat)" |
||||
|
||||
cat |\ |
||||
grep -Eo '\\S+' |\ |
||||
pidof svkbd-sxmo || svkbd-sxmo & |
||||
|
||||
RESULT="$( |
||||
echo "$( |
||||
echo "Close Menu" && |
||||
echo "$INPUT" |\ |
||||
grep -Eo '\S+' |\ |
||||
tr -d '[:blank:]' |\ |
||||
sort |\ |
||||
uniq |\ |
||||
dmenu -p Type -l 10 -i -c -fn Terminus-20 |
||||
uniq |
||||
)" | dmenu -p Type -l 10 -i -c -fn Terminus-20 |
||||
)" |
||||
|
||||
sxmo_keyboard.sh off |
||||
pkill svkbd-sxmo |
||||
|
||||
if [[ "$RESULT" = "Close Menu" ]]; then |
||||
exit 0 |
||||
else |
||||
xargs -I CC xdotool type "$RESULT" |
||||
xdotool type "$RESULT" |
||||
fi |
||||
|
@ -0,0 +1,53 @@ |
||||
#!/usr/bin/env sh |
||||
SFEEDCONF=/usr/share/sxmo/sxmo_sfeedrc |
||||
|
||||
tflt() { |
||||
# Date with feature like "1 day ago" etc main reason |
||||
# coreutils is a dep... |
||||
TIME=$(eval date -d \""$TIMESPAN"\" +%s) |
||||
cat | gawk "\$1 > $TIME" |
||||
} |
||||
|
||||
prep_temp_folder_with_items() { |
||||
mkdir -p $FOLDER |
||||
rm -rf $FOLDER/* |
||||
cd ~/.sfeed/feeds/ |
||||
for f in $(ls) |
||||
do |
||||
cat $f | tflt $@ > $FOLDER/$f |
||||
[ -s $FOLDER/$f ] || rm $FOLDER/$f |
||||
done |
||||
} |
||||
|
||||
list_items() { |
||||
cd $FOLDER |
||||
gawk -F'\t' '{print $1 " " FILENAME " | " $2 ": " $3}' * |\ |
||||
grep -E '^[0-9]{5}' |\ |
||||
sort -nk1 |\ |
||||
sort -r |\ |
||||
gawk -F' ' '{printf strftime("%y/%m/%d %H:%M",$1); $1=""; print $0}' |
||||
} |
||||
|
||||
# Update Sfeed |
||||
st -e sh -c "echo Syncing Feeds && sfeed_update $SFEEDCONF" |
||||
|
||||
# Dmenu prompt for timespan |
||||
TIMESPAN=$( |
||||
echo "1 hour ago |
||||
3 hours ago |
||||
12 hours ago |
||||
1 day ago |
||||
2 day ago |
||||
1970-01-01" | dmenu -p "RSS Timespan" -c -l 10 -fn Terminus-20 |
||||
) |
||||
|
||||
# Make folder like /tmp/sfeed_1_day_ago |
||||
FOLDER="/tmp/sfeed_$(echo "$TIMESPAN" | sed 's/ /_/g')" |
||||
prep_temp_folder_with_items |
||||
|
||||
# Show list of items |
||||
PICKED=$(echo "$(list_items)" | dmenu -p "RSS" -c -l 20 -fn Terminus-15) |
||||
|
||||
# Handle picked item |
||||
URL="$(echo "$PICKED" | gawk -F " " '{print $NF}')" |
||||
sxmo_urlhandler.sh "$URL" |
@ -0,0 +1,23 @@ |
||||
#!/usr/bin/env sh |
||||
|
||||
pidof svkbd-sxmo || svkbd-sxmo & |
||||
ZIP=$( |
||||
echo -e " |
||||
10025 - NYC |
||||
60007 - Chicago |
||||
94016 - San Francisco |
||||
97035 - Portland, OR |
||||
" | |
||||
awk 'NF' | |
||||
awk '{$1=$1};1' | |
||||
dmenu -fn Terminus-20 -i -c -l 10 -p "US Zipcode" | |
||||
awk -F " " '{print $1}' |
||||
) |
||||
pkill svkbd-sxmo |
||||
|
||||
LATLON=$(cat /usr/share/sxmo/zipcodes_for_weather.csv | grep "^$ZIP") |
||||
LAT=$(echo $LATLON | cut -d, -f2 | tr -d ' ') |
||||
LON=$(echo $LATLON | cut -d, -f3 | tr -d ' ') |
||||
URL="https://forecast.weather.gov/MapClick.php?lat=${LAT}&lon=${LON}&unit=0&lg=english&FcstType=text&TextType=1" |
||||
|
||||
st -f Monospace-20 -e w3m "$URL" |
@ -0,0 +1,23 @@ |
||||
#!/usr/bin/env sh |
||||
pidof svkbd-sxmo || svkbd-sxmo & |
||||
SEARCHTERMS="$( |
||||
echo "Search term" | |
||||
dmenu -p "Yt Search" -c -l 10 -fn Terminus-20 |
||||
)" |
||||
pkill svkbd-sxmo |
||||
|
||||
IDIOTRESULTS="$(idiotbox-cli $SEARCHTERMS)" |
||||
RESULT="$( |
||||
echo "$IDIOTRESULTS" | |
||||
grep -Ev '^(Channelid|Atom feed|Channel title|Published|Viewcount|Userid):' | |
||||
sed -E 's/^(URL|Duration):\s+/\t/g' | |
||||
tr -d '\n' | |
||||
sed 's/===/\n/g' | |
||||
gawk -F'\t' '{ print $3 " " $1 " " $2}' | |
||||
dmenu -c -l 10 -fn Terminus-20 |
||||
)" |
||||
|
||||
[[ "CLOSE_MENU" == "$RESULT" ]] && exit 0 |
||||
|
||||
URL=$(echo "$RESULT" | awk -F " " '{print $NF}') |
||||
st -e mpv --ytdl-format='[height<420]' "$URL" |
Loading…
Reference in new issue