Add scripts

This commit is contained in:
zongor 2023-04-23 09:43:40 -04:00
parent dc59711f18
commit 0b3ad012fc
9 changed files with 201 additions and 20 deletions

19
.emacs
View File

@ -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
(

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) <year> <copyright holders>
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:

137
bin/rc/gridup Normal file
View File

@ -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 </mnt/registry/index awk -v 'tls='$tls '
/service tlssrv/ && tls == "yes" {
print "srvtls -c", $1, $3, $5}
/service \/bin\/exportfs/ && tls == "no" {
print "srv -c", $1, $3, $5}
'
chmod +x /tmp/gridmount
if(~ $scriptonly 'yes'){
quiet 'mount script saved in /tmp/gridmount'
cat /tmp/gridmount
exit
}
if(~ $mountonly 'yes'){
/tmp/gridmount || fail 'could not mount'
quiet 'grid services mounted'
exit
}
>/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

35
bin/rc/initwifi Normal file
View File

@ -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
}

14
bin/rc/pins Normal file
View File

@ -0,0 +1,14 @@
#!/bin/rc
dir=$1
if(~ $#dir 0)
dir='out'
</dev/audiostat awk '
/^pin [0-9]+ '$dir'/ {
printf "@{echo pin %d>/dev/audioctl} #", $2
for (i = 4; i < NF; i++) {
if ($i == "←")
break
printf " %s", $i
}
printf "\n"
}'

7
bin/rc/riostart Normal file
View File

@ -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

3
bin/rc/youtube Normal file
View File

@ -0,0 +1,3 @@
#!/bin/rc
rfork ne
nvi -V 18 -v /tmp/video $1 && treason /tmp/video

2
bin/sh/mpv_play Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh
mpv --ytdl-format="bestvideo[height<=?720][fps<=?30][vcodec!=?vp9]+bestaudio/best" --playlist=$HOME/inv.plist

2
bin/sh/rss_do Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh
rss2mpv inv.plist https://yewtu.be/feed/private?token=QaRbw6HeUUNTi5K24U6eMWSw9xYjYc0ARTeUcZK1pJA=