From 0b3ad012fccb838d638a1e00fe8397490493b954 Mon Sep 17 00:00:00 2001 From: zongor Date: Sun, 23 Apr 2023 09:43:40 -0400 Subject: [PATCH] Add scripts --- .emacs | 19 ------- LICENSE | 2 +- bin/rc/gridup | 137 ++++++++++++++++++++++++++++++++++++++++++++++++ bin/rc/initwifi | 35 +++++++++++++ bin/rc/pins | 14 +++++ bin/rc/riostart | 7 +++ bin/rc/youtube | 3 ++ bin/sh/mpv_play | 2 + bin/sh/rss_do | 2 + 9 files changed, 201 insertions(+), 20 deletions(-) create mode 100644 bin/rc/gridup create mode 100644 bin/rc/initwifi create mode 100644 bin/rc/pins create mode 100644 bin/rc/riostart create mode 100644 bin/rc/youtube create mode 100644 bin/sh/mpv_play create mode 100644 bin/sh/rss_do diff --git a/.emacs b/.emacs index 4cf36b4..627c82c 100755 --- a/.emacs +++ b/.emacs @@ -133,25 +133,6 @@ :config (global-undo-tree-mode 1) :diminish undo-tree-mode) - -(use-package eaf - :straight (eaf - :type git - :host github - :repo "emacs-eaf/emacs-application-framework" - :files ("*.el" "*.py" "core" "app" "*.json") - :includes (eaf-browser eaf-terminal) ; Straight won't try to search for these packages when we make further use-package invocations for them - :pre-build (("python3" "install-eaf.py" "--install" "browser" "terminal" "--ignore-sys-deps")) - ) - :init (evil-set-initial-state 'eaf-mode 'emacs)) ; Evil mode doesn't work well with eaf keybindings. - -(use-package eaf-browser - :custom - (eaf-browser-continue-where-left-off t) - (eaf-browser-enable-adblocker t) - (eaf-browser-dark-mode "force")) -(use-package eaf-terminal) - (use-package format-all :hook ( diff --git a/LICENSE b/LICENSE index 2071b23..47aa234 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) +Copyright (c) 2023 zongor Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/bin/rc/gridup b/bin/rc/gridup new file mode 100644 index 0000000..673abb7 --- /dev/null +++ b/bin/rc/gridup @@ -0,0 +1,137 @@ +#!/bin/rc +rfork e +fn usage { + >[2=1] echo 'usage:' $0 '[-mst]' + exit usage +} +fn quiet { + if(~ $quiet 'no') + >[2=1] echo $* +} +fn fail { + quiet fail: $* + exit 'fail: '$* +} + +registry='tcp!registry.9gridchan.org!6675' +reconnect='no' +mountonly='no' +scriptonly='no' +tls='no' +quiet='no' +while(~ $1 -* && ! ~ $1 --){ + switch($1){ + case -m + mountonly='yes' + case -s + scriptonly='yes' + case -t + tls='yes' + registry='tcp!registry.9gridchan.org!6675' + case -q + quiet='yes' + reconnect='yes' + case * + usage + } + shift +} +if(! ~ $#* 0) + usage + +services=( \ + gridregistry pubregistry \ + gridchat gridplumber \ + gridram griddisk \ + gridroot gridwiki) +for(s in $services) + if(test -w /srv/$s) + reconnect='yes' +if(~ $reconnect 'yes'){ + if(~ $quiet 'no'){ + echo -n 'old grid connections found in /srv, remove? [y/n]: ' + reconnect=`{read} + } + if(~ $reconnect y*) + rm -f /srv/^$services +} + +if(~ $mountonly 'no') + rfork n +if(~ $tls 'no') + srv $registry gridregistry /mnt/registry || fail registry +if not{ + if(! test -w /mnt/factotum/ctl) + auth/factotum + >/mnt/factotum/ctl echo 'key proto=dp9ik user=glenda dom=grid !password=9gridchan' || fail factotum + srvtls $registry gridregistry /mnt/registry || fail registry +} + +>/tmp/gridmount echo '#!/bin/rc' +>>/tmp/gridmount /tmp/chatcat cat <<'...' +#!/bin/rc +label chat +echo 'README:' +echo ' This is chatcat(1).' +echo ' Type a (multi-line) message ending with a newline' +echo ' and press control-d (EOT) to send.' +echo +echo -n 'nick? ' +nick=`{read} +if(~ $#nick 0) + nick='unknown gridster' +echo JOIN $nick to chat >>/n/chat/chat +cat /n/chat/chat & +while() cat | sed '1s/^/'$nick' → /' >>/n/chat/chat +... +chmod +x /tmp/chatcat + +>/tmp/gridrio cat <<'...' +#!/bin/rc +if(test -x /bin/chat) + window -r 0 0 700 400 -scroll chat +if not + window -r 0 0 700 400 -scroll /tmp/chatcat +window -r 700 0 1300 400 acme -c1 /n/griddisk /n/griddisk/gridmsg +window -r 0 400 700 750 mothra -a http://wiki.9gridchan.org/message_board +window -r 700 400 1300 750 page /n/gridroot/lib/musicant.png +... +chmod +x /tmp/gridrio + +>/tmp/gridscript cat <<'...' +#!/bin/rc +/tmp/gridmount +fn cpl { + cp $1 /n/griddisk/cpl + ptarg=`{basename $1} + plumb http://wiki.9gridchan.org/incoming/cpl/$ptarg +} +if(! test -e /mnt/web/ctl) + webfs +rio=(rio) +if(test -x /bin/grio) + rio=(grio -c 0x99009900) +exec $rio -i /tmp/gridrio +... +chmod +x /tmp/gridscript + +window -r 0 0 1350 750 /tmp/gridscript diff --git a/bin/rc/initwifi b/bin/rc/initwifi new file mode 100644 index 0000000..d2959dd --- /dev/null +++ b/bin/rc/initwifi @@ -0,0 +1,35 @@ +#!/bin/rc -e +rfork e + +fn Help{ echo `{basename $0}^' [essid]' } +fn Dump{ grep node '#'l1/ether1/ifstats } +fn Ask{ + echo -n $1 + essid=`{dd -bs 64 -count 1 >[2]/dev/null} +} +fn Wifi{ + ip/ipconfig ether /net/ether0 unbind + bind -a '#'l1 /net + aux/wpa -p2 -s $essid /net/ether1 + ip/ipconfig ether /net/ether1 + cat /net/ndb +} + +switch($#*){ + case 0 + if(~ $#essid 0){ + echo Available wifi essids… + Dump + echo + Ask 'essid=' + } + if(! ~ $#essid 0){ + Wifi + } + case 1 + essid=($1) + Wifi + case * + Help + Dump +} diff --git a/bin/rc/pins b/bin/rc/pins new file mode 100644 index 0000000..43f22aa --- /dev/null +++ b/bin/rc/pins @@ -0,0 +1,14 @@ +#!/bin/rc +dir=$1 +if(~ $#dir 0) + dir='out' +/dev/audioctl} #", $2 + for (i = 4; i < NF; i++) { + if ($i == "←") + break + printf " %s", $i + } + printf "\n" +}' diff --git a/bin/rc/riostart b/bin/rc/riostart new file mode 100644 index 0000000..97697dd --- /dev/null +++ b/bin/rc/riostart @@ -0,0 +1,7 @@ +#!/bin/rc +window 0,0,161,117 stats -lmisce +window 161,0,278,117 winwatch -e '^(winwatch|stats|faces)' +window -scroll bar + +# run a system shell on the serial console +~ $#console 0 || window -scroll console diff --git a/bin/rc/youtube b/bin/rc/youtube new file mode 100644 index 0000000..b965f11 --- /dev/null +++ b/bin/rc/youtube @@ -0,0 +1,3 @@ +#!/bin/rc +rfork ne +nvi -V 18 -v /tmp/video $1 && treason /tmp/video diff --git a/bin/sh/mpv_play b/bin/sh/mpv_play new file mode 100644 index 0000000..0de5719 --- /dev/null +++ b/bin/sh/mpv_play @@ -0,0 +1,2 @@ +#!/bin/sh +mpv --ytdl-format="bestvideo[height<=?720][fps<=?30][vcodec!=?vp9]+bestaudio/best" --playlist=$HOME/inv.plist diff --git a/bin/sh/rss_do b/bin/sh/rss_do new file mode 100644 index 0000000..e3188ea --- /dev/null +++ b/bin/sh/rss_do @@ -0,0 +1,2 @@ +#!/bin/sh +rss2mpv inv.plist https://yewtu.be/feed/private?token=QaRbw6HeUUNTi5K24U6eMWSw9xYjYc0ARTeUcZK1pJA=