ref: f3afdf563f784c0a5703496f48c1a72dff4617f4
author: thedaemon <thedaemon@9skull>
date: Fri Dec 6 16:26:07 EST 2024
test
--- /dev/null
+++ b/9fs
@@ -1,0 +1,138 @@
+#!/bin/rc
+# 9fs filesystem [mountpoint] - srv & mount filesystem, usually from plan 9
+
+rfork e
+switch($1){+case ''
+ echo usage: 9fs service '[mountpoint]' >[1=2]
+ exit usage
+case 9fat esp pidos dos
+ if(~ $#2 1)
+ part=`{ls $2 >[2]/dev/null}+ if not if(~ $1 pidos)
+ part=`{ls /dev/sdM*/dos >[2]/dev/null}+ if not
+ part=`{ls /dev/fs/$1 /dev/sd*/$1 >[2]/dev/null}+ if(~ $#part 0) {+ echo 'no '$1' partition found' >[1=2]
+ exit no.$1
+ }
+ part=$part(1)
+
+ if(! test -f /srv/dos)
+ dossrv >/dev/null </dev/null >[2]/dev/null
+
+ unmount /n/$1 >/dev/null >[2]/dev/null
+ mount -c /srv/dos /n/$1 $part
+ if(~ $1 9fat){+ unmount /n/9 >/dev/null >[2]/dev/null
+ mount -c /srv/dos /n/9 $part
+ }
+case dump other
+ mount -C /srv/boot /n/$1 $1
+case sources
+ srv -nqC tcp!9p.io sources /n/sources
+case sourcesdump
+ 9fs sources
+ mount -nC /srv/sources /n/sourcesdump main/archive
+case sourcessnap
+ 9fs sources
+ mount -nC /srv/sources /n/sourcessnap main/snapshot
+case atom
+ srv -nq tcp!atom.9atom.org atom && mount -nC /srv/atom /n/atom atom
+case atomdump
+ 9fs atom && mount -nC /srv/atom /n/atomdump atomdump
+case 9pio
+ srv -nq tcp!9p.io 9pio && mount -nC /srv/9pio /n/9pio
+case 9front
+ 9fs tcp!9front.org!9000
+ for(i in 9front fqa iso lists sites extra)
+ bind /n/9front.org!9000/$i /n/$i
+case 9contrib
+ 9fs contrib.9front.org /n/contrib
+case 9grep
+ 9fs tcp!9front.org!7734
+ bind -b /n/9front.org!7734 /n/lists
+case 9registry
+ srv tcp!registry.9p.zone!6675 registry /n/registry
+case 9disk
+ srv -c tcp!9p.zone!9991 9p.zone.disk /n/disk
+case 9chat
+ srv tcp!chat.9p.zone!9990 gridchat /n/chat
+case sdf
+ srv -nq tcp!9p.sdf.org sdf && mount -nC /srv/sdf /usr/sdf
+ bind -a /usr/sdf/bin /bin
+ bind -a /usr/sdf/rc /bin
+
+# arbitrary venti archives
+case vac:*
+ vacfs <{echo $1}+case *.vac
+ if (test -e $1)
+ score=$1
+ if not if (! ~ $1 /* && test -e $home/lib/vac/$1)
+ score=$home/lib/vac/$1
+ if not if (! ~ $1 /* && test -e /lib/vac/$1)
+ score=/lib/vac/$1
+ if not {+ echo $0: $1: no such score file >[1=2]
+ exit 'no score file'
+ }
+ vacfs -m /n/`{basename $1 .vac} `{cat $score}+
+case kfs
+ if(! test -f /srv/kfs) disk/kfs
+ mount -c /srv/kfs /n/kfs
+
+case wiki
+ srv -m 'net!9p.io!wiki' wiki /mnt/wiki
+
+case *!snip
+ srv -cnmq tcp!^`{echo $1 | sed 's/snip$/17037/'} $1 /n/$1+
+# Shortcut for 9srv
+case 9srv
+ srv -q tcp!9srv.net 9srv /n/9srv
+
+# plan9 pastebin
+case 9paste
+ srv -n fs.9paste.net 9paste /n/9paste
+
+# Our other is a fossil with snapshots (but no dumps).
+case other
+ 9fs 9srv
+ mount -cC /srv/9srv /n/other other/active
+case othersnap
+ 9fs other
+ mount -C /srv/9srv /n/othersnap other/snapshot
+# That "other" has a bunch of CD/DVD images. Shortcut to mount.
+case cd
+ if(~ $#* 1)
+ echo 'Please specify a cd image.' >[1=2]
+ if not {+ 9fs other
+ 9660srv 9660.^$user
+ mount /srv/9660.^$user /n/^$2 /n/other/^$2^.iso
+ }
+
+# Cooperating unix hosts
+case ssh:*
+ if(test -e $home/lib/uname) {+ t=`{echo $1 | sed 's/^ssh://'}+ user=`{grep '^'$t' ' $home/lib/uname | sed 's/'$t' +([^@]+)@.+$/\1/'}+ host=`{grep '^'$t' ' $home/lib/uname | sed 's/'$t' +[^@]+@(.+)$/\1/'}+ }
+ srvssh -u /1/bin/u9fs $host $t /n/$t
+
+case nntp:*
+ t=`{echo $1 | sed 's/^nntp://'}+ nntpfs -m /n/$t $t
+
+case *
+ switch($#*){+ case 1
+ srv -m $1
+ case *
+ srv -m $1 $1 $2
+ }
+}
--- /dev/null
+++ b/9paste
@@ -1,0 +1,22 @@
+#!/bin/rc -e
+rfork en
+
+# usage: 9paste [.suffix] <file
+# eg: topng </dev/screen | 9paste .png
+
+if(! test -e /n/9paste/none)
+ 9fs 9paste
+
+suf=$1
+if(~ $"suf .png .jpg .jpeg .gif)
+ t=I
+if not
+ t=0
+x=`{randname}^$"suf+f=/n/9paste/none/$x
+
+cat >$f
+
+echo http://www.9paste.net/none/$x^'
+'^gopher://gopher.9paste.net/$t/none/$x^'
+'^$f >[1=2]
--- /dev/null
+++ b/9psdf
@@ -1,0 +1,12 @@
+#!/bin/rc
+# 9psdf - access files on 9p.sdf.org
+# usage: 9psdf
+
+if(! test -d /usr/sdf){+ mkdir /usr/sdf
+}
+
+rimport -p -u $user 9p.sdf.org / /n/sdf
+bind -a /n/sdf/usr/sdf /usr/sdf
+bind -a /usr/sdf/bin /bin
+bind -a /n/sdf/usr/$user/html $home/www/sdf
--- /dev/null
+++ b/9void
@@ -1,0 +1,3 @@
+#!/bin/rc
+
+rcpu -h 192.168.0.101
--- /dev/null
+++ b/Bp
@@ -1,0 +1,2 @@
+#!/bin/rc
+B `{walk -f $1 | dmenu -b}--- /dev/null
+++ b/a
@@ -1,0 +1,2 @@
+#!/bin/rc
+acme -l /usr/thedaemon/docs/acme.dump
--- /dev/null
+++ b/anonradio
@@ -1,0 +1,2 @@
+#!/bin/rc
+hget http://anonradio.net:8000/anonradio | play
--- /dev/null
+++ b/backup.rc
@@ -1,0 +1,23 @@
+#!/bin/rc
+# By jgstratt
+# Just cd into the dir you want to backup and run. Defaults to /mnt/term/rw/. If you want to write to another location, set the "tar_dir" env veriable.
+
+tardir='/mnt/term/rw'
+backdir=`{pwd}+
+# Overwrite defaults with env, if they exist
+if ( test -s /env/tar_dir ) {+ tardir=$tar_dir
+}
+
+# Overwrite with args, if they exist
+switch($1){+case -t*
+ tardir=$2
+case -d*
+ backdir=$2
+}
+
+date=`{date -f YYYYMMDD}+basebackdir=`{basename $backdir}+tar czf $tardir/$date.$basebackdir.tgz $backdir
--- /dev/null
+++ b/bandcamp
@@ -1,0 +1,94 @@
+#!/bin/rc
+# data matches 'https://[^.]+\.bandcamp.com/(track|album)/[^ /]+'
+# plumb start window -scroll bandcamp $data
+if(! ~ $1 https://?*.bandcamp.com/^(track album)^/?*){+ echo 'usage: bandcamp https://artist.bandcamp.com/(track|album)/name' >[1=2]
+ exit usage
+}
+{echo $1; hget $1} | awk '+ BEGIN{+ getline
+ sub("^https:/", "/tmp/mp3")+ if(sub("\.bandcamp\.com/track", "/singles")){+ single = $0
+ system("mkdir -p `{basename -d "single"}")+ }
+ else{+ sub("\.bandcamp\.com/album", "")+ dir = $0
+ system("mkdir -p "dir)+ }
+ RS = "{"+ }
+ !single && /"@type":"ListItem"/{n++}+ !single && match($0, /"@id":"[^"]+\/track\/[^\/"]+/){+ track[n] = substr($0, RSTART, RLENGTH)
+ sub(".+/", "", track[n])+ }
+ /"name":"file_mp3-128"/{+ match($0, /"https?:\/\/[^"]+/)
+ if(single){+ src = substr($0, RSTART + 1, RLENGTH - 1)
+ print "track: "single".mp3"
+ system("hget ''"src"'' > "single".mp3")+ }
+ else
+ url[n] = substr($0, RSTART + 1, RLENGTH - 1)
+ }
+ match($0, /"text":"[^"]+/){+ lyr = substr($0, RSTART + 8, RLENGTH - 8)
+ gsub(/\\"/, "\"", lyr)
+ gsub(/\\r\\n/, "\n", lyr)
+ if(!single)
+ lyrics[n] = lyr
+ }
+ match($0, /<meta name="description" content="([^"]|\n)+/){+ info = substr($0, RSTART + 35, RLENGTH - 35)
+ gsub("\r", "", info)+ gsub("&#39;", "''", info)+ gsub("&amp;", "\&", info)+ }
+ match($0, /<a class="popupImage" href="[^"]+">/){+ src = substr($0, RSTART + 28, RLENGTH - 30)
+ match(src, /\.[^.]+$/)
+ if(single)
+ art = single substr(src, RSTART, RLENGTH)
+ else
+ art = dir"/art"substr(src, RSTART, RLENGTH)
+ print "art: "art
+ system("hget ''"src"'' > "art)+ }
+ END{+ if(single){+ out = single".txt"
+ if(info){+ print "single info: "out
+ print info > out
+ }
+ if(lyr){+ print "lyrics: "lyr
+ print lyr >> out
+ }
+ }
+ else{+ if(info){+ out = dir"/info.txt"
+ print "album info: "out
+ print info > out
+ }
+ if(n > 99) fmt = "%s/%03d_%s"
+ else if(n > 9) fmt = "%s/%02d_%s"
+ else fmt = "%s/%d_%s"
+ for(i = 1; i <= n; i++){+ out = sprintf(fmt".mp3", dir, i, track[i])
+ print "track: "out
+ system("hget ''"url[i]"'' > "out)+ if(lyrics[i]){+ out = sprintf(fmt".txt", dir, i, track[i])
+ print "lyrics: "out
+ print lyrics[i] > out
+ }
+ }
+ }
+ }
+'
--- /dev/null
+++ b/bunsay
@@ -1,0 +1,28 @@
+#!/bin/rc
+#
+# build a fusen here.
+#
+wc = `{echo $* | wc -c}+#echo $wc
+
+echo
+echo $*
+
+cat <<'...'
+ __
+ \ / )
+ \ /' / __
+ _.----'-./ _-" )
+ -" "v" _-'
+ ." 'Y"
+ | |
+ | o o |
+ | .><. |
+ | "Ll" /
+ '. |
+ | |
+ \ )
+ / . /'\ *
+ '-(_/,__.--^--" * *
+ * * *
+...
--- /dev/null
+++ b/c
@@ -1,0 +1,2 @@
+#!/bin/rc
+echo >/dev/text
--- /dev/null
+++ b/catbox
@@ -1,0 +1,9 @@
+#!/bin/rc
+
+fn usage {+ echo usage: catbox file >/fd/2
+ exit usage
+}
+if(! ~ $#* 1)
+ usage
+hpost -u https://catbox.moe -m /user/api.php 'reqtype:fileupload' 'fileToUpload@'^$1 | tee /dev/snarf ; echo
--- /dev/null
+++ b/cc
@@ -1,0 +1,2 @@
+#!/bin/rc
+6c -FVw $*
--- /dev/null
+++ b/cl
@@ -1,0 +1,4 @@
+#!/bin/rc
+echo >/dev/text
+pwd
+lc
--- /dev/null
+++ b/clear
@@ -1,0 +1,2 @@
+#!/bin/rc
+echo >/dev/text
--- /dev/null
+++ b/clears
@@ -1,0 +1,10 @@
+#!/bin/rc
+# clears all the output from programs,
+# leaving only the command prompts
+
+grep `{echo -n '^'^$prompt(1)} </dev/text | \+ grep -v '^'^$prompt(1)^'(clear|"")' | \
+ uniq >/tmp/clearing.$pid
+
+cp /tmp/clearing.$pid /dev/text
+rm -f /tmp/clearing.$pid
--- /dev/null
+++ b/committreason
@@ -1,0 +1,8 @@
+#!/bin/rc
+
+#Downloads and updates treason
+rm -rf /tmp/treason
+mkdir /tmp/treason
+cd /tmp/treason
+hget https://ftrv.se/_/treason.gz | gunzip | disk/mkext -d .
+./treason/install.rc
--- /dev/null
+++ b/crip
@@ -1,0 +1,68 @@
+#!/bin/rc
+# 2016-10-22T22:34:59-0400
+# Repack .cbr as .cbz. Try to fix the file names.
+rfork e
+fn fixname{+ sed '
+ s/( |\+|%C2)/_/g;
+ s/(\(|\)|\'')//g;
+ s/%..//g;
+ s/(__|___)/_/g;
+ s/_-_/-/g;
+ '
+}
+fn usage {+ echo 'usage: crip [ -cdnrz ]' >[1=2]
+ exit usage
+}
+zip=(zip -v -f)
+switch($1){+case -c
+ for(i in *.cbr){+ wdir=`{pwd}+ file=`{echo $"i | urlencode | fixname | sed 's/\.cbr$/\.cbz/g'}+ dir=`{echo $"file | sed 's/\.cbz$//g'}+ mkdir crip.$file &&
+ cd crip.$file &&
+ unrar x $"wdir'/'$"i &&
+ crip -n &&
+ cd $wdir &&
+ mv crip.$file $dir &&
+ eval $zip $file $dir &&
+ rm -r $dir &&
+ rm $"i &&
+ echo $file
+ }
+case -d
+ for(i in `{ls | grep -v -e '\.cb(r|z)'}){+ file=`{echo $"i | urlencode | fixname}+ if(! ~ $i $file)
+ mv $"i $file
+ eval $zip $file.cbz $file &&
+ rm -rf $file
+ echo $file.cbz
+ }
+case -n
+ for(i in *){+ file=`{echo $"i | urlencode | fixname}+ if(! ~ $i $file)
+ mv $"i $file
+ echo $file
+ }
+case -r
+ for(i in *.rar){+ file=`{echo $"i | urlencode | fixname | sed 's/\.rar$/\.cbr/g'}+ if(! ~ $i $file)
+ mv $"i $file
+ echo $file
+ }
+case -z
+ for(i in *.zip){+ file=`{echo $"i | urlencode | fixname | sed 's/\.zip$/\.cbz/g'}+ if(! ~ $i $file)
+ mv $"i $file
+ echo $file
+ }
+case *
+ usage
+}
--- /dev/null
+++ b/df
@@ -1,0 +1,12 @@
+#!/bin/rc
+# df - print disk usage on hjfs/cwfs
+# usage: df
+
+if (test -f /srv/hjfs.cmd) {+ echo df >> /srv/hjfs.cmd
+}
+if not {+ echo statw >> /srv/cwfs.cmd
+ dd -if /srv/cwfs.cmd -bs 1024 -count 21 -quiet 1 |
+ grep wmax | sed 's/.*\+//'
+}
--- /dev/null
+++ b/drawterm
@@ -1,0 +1,3 @@
+#!/bin/rc
+
+rcpu -u thedaemon -h thedaemon.space
--- /dev/null
+++ b/duck
@@ -1,0 +1,2 @@
+#!/bin/rc
+mothra 'http://duckduckgo.com/lite?q='^`"{echo $* | sed 's/ /+/g'}--- /dev/null
+++ b/dump
@@ -1,0 +1,2 @@
+#!/bin/rc
+ echo dump >>/srv/cwfs.cmd
--- /dev/null
+++ b/dus
@@ -1,0 +1,10 @@
+#!/bin/rc
+# dus - disk usage summary for current dir
+# usage: dus
+
+du -s * | sort -nrk 1 | awk '{+ if ($1 > 1073741824) printf("%7.2f %s\t%s\n", $1/1073741824, "Tb", $2)+ else if ($1 > 1048576) printf("%7.2f %s\t%s\n", $1/1048576, "Gb", $2)+ else if ($1 > 1024) printf("%7.2f %s\t%s\n", $1/1024, "Mb", $2)+ else printf("%7.2f %s\t%s\n", $1, "Kb", $2)+}'
--- /dev/null
+++ b/emu
@@ -1,0 +1,33 @@
+#!/bin/rc -e
+# emu - a wrapper for games/^(2600 gb gba md nes snes)
+# usage: emu [-j usbep] console width height [params] rom
+# requires:
+# - rescale
+
+rfork n
+
+if(~ $*(3) ''){+ echo $0 'usage: emu [-j usbep] console width height [params] rom'
+ exit usage
+}
+
+emu=$1
+rescale $2 $3
+shift 3
+joy=()
+
+if(~ $1 -j){+ joy=$2
+ shift 2
+}
+
+if(test -d /sys/games/lib/rom/$emu){+ mkdir -p $home/lib/$emu
+ bind -bc $home/lib/$emu /sys/games/lib/rom/$emu
+ cd /sys/games/lib/rom/$emu
+}
+
+if(~ $#joy 1)
+ nusb/joy /dev/usb/ep^$joy^.0 | joy | {eval games/$emu -a $* || eval games/$emu $*}+if not
+ eval games/$emu -a $* || eval games/$emu $*
--- /dev/null
+++ b/enabledrawterm
@@ -1,0 +1,3 @@
+#!/bin/rc
+aux/listen1 -t 'tcp!*!rcpu' /rc/bin/service/tcp17019 &
+
--- /dev/null
+++ b/explorer
@@ -1,0 +1,90 @@
+#!/bin/rc
+# a plumber's file browser
+
+# wdir is /mnt/explorer
+# plumb to explorer
+
+# data matches [a-zA-Z¡-0-9_\-+.,!/]+
+# arg isdir $data
+# plumb to explorer
+# plumb client window explorer
+
+rfork en
+r = ()
+v = ()
+buttons = '{name} [mtime] [atime] [size]'+fn list{ls -Fp $v $r $dir}+fn display{+ echo unhide >/dev/wctl >[2]/dev/null
+ echo current >/dev/wctl
+ echo -n scroll >/dev/wctl
+ >/dev/text{+ echo $dir
+ echo $buttons '[reverse] [verbosity] [history] [new]'
+ list
+ }
+ echo -n >/dev/kbdin
+}
+ramfs -m /mnt/explorer
+cd /mnt/explorer
+echo -n /mnt/explorer >/dev/wdir
+echo -n explorer >/dev/label
+touch hist
+</mnt/plumb/explorer while(>/dev/null{+ src = `{read}+ dst = `{read}+ wdir = `{read}+ type = `{read}+ attr = `{read}+ ndata = `{read}+ data = `''{read -c $ndata}+})switch($data){+case '[new]'
+ window -cd $dir
+case '[history]'
+ cat hist >/dev/text
+case '{name}'+case '[name]'
+ buttons = '{name} [mtime] [atime] [size]'+ fn list{ls -Fp $v $r $dir}+ display
+case '{mtime}'+case '[mtime]'
+ buttons = '[name] {mtime} [atime] [size]'+ fn list{ls -Fpt $v $r $dir}+ display
+case '{atime}'+case '[atime]'
+ buttons = '[name] [mtime] {atime} [size]'+ fn list{ls -Fptu $v $r $dir}+ display
+case '{size}'+case '[size]'
+ buttons = '[name] [mtime] [atime] {size}'+ fn list{ls -Fp $v $dir | sort $r +4}+ display
+case '[reverse]'
+ if(~ $r -r)
+ r = ()
+ if not
+ r = -r
+ display
+case '[verbosity]'
+ if(~ $v -l)
+ v = ()
+ if not
+ v = -l
+ display
+case *
+ if(~ $wdir /mnt/explorer)
+ wdir = $dir
+ d = `{cleanname -d $wdir $data}+ if(test -d $d){+ dir = $d
+ if(! ~ $dir `{sed -n '$p' hist})+ echo $dir >> hist
+ display
+ }
+ if not
+ plumb -s $src -w $wdir -t $type -a $attr $data
+}
--- /dev/null
+++ b/face
@@ -1,0 +1,2 @@
+#!/bin/rc
+window 940,10,1200,210 faces -i
--- /dev/null
+++ b/frogfind
@@ -1,0 +1,21 @@
+#!/bin/rc
+
+baseurl=https://frogfind.com
+querystr=""
+
+if (~ $#* 1) {+
+ switch($1) {+ case http://*
+ querystr='read.php?a='$1
+
+ case https://*
+ querystr='read.php?a='$1
+
+ case *
+ querystr='?q='$1
+ }
+}
+
+
+mothra -a -d $baseurl/$querystr
--- /dev/null
+++ b/gb
@@ -1,0 +1,2 @@
+#!/bin/rc
+games/gb -a $*
--- /dev/null
+++ b/getwsys
@@ -1,0 +1,7 @@
+#!/bin/rc
+# waits for you to click another window, then reports its wsys dir
+read -c 144 /dev/wctl >/dev/null
+for(i in /dev/wsys/*/wctl)
+ if(~ `{read -c 72 $i} *' cur'*)+ echo $i | sed 's/wctl$//'
+echo current > /dev/wctl
--- /dev/null
+++ b/gfetch
@@ -1,0 +1,88 @@
+#!/bin/rc
+# Warning, parts of this script have been STOLEN!
+
+# TODO:
+# fs usage - done
+# kernel
+
+fn storage {+ disks = `{ls -d /dev/sd* | uniq}+ anydisk = 'false'
+ for(i in $disks){+ if(test -f $i/data){+ full = `{ls -l $i/data}+ disk = `{echo $full | awk -F '/' '{print $3}'}+ size = `{echo $full | awk '{print $6}'}+ echo $disk^': '^`{echo $size^' / 1024 / 1024 /1024' | bc}^GB+ anydisk = 'true'
+ echo statw >> /srv/cwfs.cmd
+ dd -if /srv/cwfs.cmd -bs 1024 -count 21 -quiet 1 | grep wmax | sed 's/.*\+//'
+ }
+ }
+ if(~ $anydisk -c 'false')
+ echo Running in the diskless
+}
+
+fn fs {+ if(ls /srv | grep -s '*.cmd')
+ ls /srv/*.cmd | sed 's/.cmd//g' | sed 's/\/srv\///g'
+ if(test -f /srv/fscons)
+ echo fossil
+ # Logic from storage to scrape for venti arenas
+ v='false'
+ disks = `{ls -d /dev/sd* | uniq}+ for(i in $disks){+ if(ls $i | grep -s arena)
+ v='true'
+ }
+ if(~ $v -c 'true')
+ echo venti
+}
+
+fn cpuid {+ if(test -f /bin/aux/cpuid)
+ aux/cpuid >[2]/dev/null | grep procname | sed 's/.*procname//'
+}
+
+os=`{+ if(grep -s 'zrv' /dev/drivers)
+ echo 9ants
+ if not if(grep -s 'vmx' /dev/drivers)
+ echo 9front
+ if not
+ echo Bell Labs
+}
+
+# fs and storage require #S bound on /dev
+bind -b '#S' /dev
+
+arch=`{echo $cputype}+shell=/bin/rc
+wm=/bin/rio
+uptime=`{uptime| sed 's/.*up//; s/..........$//'}+scr=`{dd -count 1 < /dev/screen|[2];}+scr=($scr(4) x $scr(5))
+ram=(`{tr / ' '</dev/swap})+free=`{echo $ram(1)'/1024^2'|bc}+used=`{echo '('$ram(3)'*('$ram(7)^+$ram(5)^'))/1024^2'|bc}+cpu=`{cpuid}+files=`{fs}+strg=`{storage}+
+cat <<EOF
+ __
+ ( \
+ __ \ '\
+( "-_ \ .-'--____
+ '-_ "v" "-. $user @$sysname
+ "γ' \ ---------------
+ | | os: Plan 9 from $os/$arch
+ | O O | shell: $shell
+ | ɾᑕᑐɿ | wm: $wm
+ \ "L˩ʺ | uptime: $uptime
+ | .| ram: $used/$free MiB
+ | | cpu: $cpu
+ ( / res: $scr
+ ⡎⠉'\ . \ fs: $files
+ ⠣⠤⋯^__.__/\_)-' $strg
+EOF
--- /dev/null
+++ b/gfetch.rc
@@ -1,0 +1,80 @@
+#!/bin/rc
+# Warning, parts of this script have been STOLEN!
+
+# TODO:
+# fs usage
+# kernel
+
+fn storage {+ disks = `{ls -d /dev/sd* | uniq}+ anydisk = 'false'
+ for(i in $disks){+ if(test -f $i/data){+ full = `{ls -l $i/data}+ disk = `{echo $full | awk -F '/' '{print $3}'}+ size = `{echo $full | awk '{print $6}'}+ echo $disk^': '^`{echo $size^' / 1024 / 1024 /1024' | bc}^GB+ anydisk = 'true'
+ }
+ }
+ if(~ $anydisk -c 'false')
+ echo Running in the diskless
+}
+
+fn fs {+ if(ls /srv | grep -s '*.cmd')
+ ls /srv/*.cmd | sed 's/.cmd//g' | sed 's/\/srv\///g'
+ if(test -f /srv/fscons)
+ echo fossil
+ # Logic from storage to scrape for venti arenas
+ v='false'
+ disks = `{ls -d /dev/sd* | uniq}+ for(i in $disks){+ if(ls $i | grep -s arena)
+ v='true'
+ }
+ if(~ $v -c 'true')
+ echo venti
+}
+
+fn cpuid {+ if(test -f /bin/aux/cpuid)
+ aux/cpuid >[2]/dev/null | grep procname | sed 's/.*procname//'
+}
+
+os=`{+ if(grep -s 'zrv' /dev/drivers)
+ echo 9ants
+ if not if(grep -s 'vmx' /dev/drivers)
+ echo 9front
+ if not
+ echo Bell Labs
+}
+
+# fs and storage require #S bound on /dev
+bind -b '#S' /dev
+
+arch=`{echo $cputype}+shell=/bin/rc
+uptime=`{uptime| sed 's/.*up//; s/..........$//'}+scr=`{dd -count 1 < /dev/screen|[2];}+scr=($scr(4) x $scr(5))
+ram=(`{tr / ' '</dev/swap})+free=`{echo $ram(1)'/1024^2'|bc}+used=`{echo '('$ram(3)'*('$ram(7)^+$ram(5)^'))/1024^2'|bc}+cpu=`{cpuid}+files=`{fs}+strg=`{storage}+
+cat <<EOF
+ $user@$sysname
+ (\(\ -----------
+ j". .. os: Plan 9 from $os/$arch
+ ( . .) shell: $shell
+ | ° ¡ uptime: $uptime
+ ¿ ; ram: $used/$free MiB
+ c?".UJ cpu: $cputype $cpu
+ resolution: $scr
+ fs: $files
+ $strg
+EOF
--- /dev/null
+++ b/gitcommit
@@ -1,0 +1,2 @@
+#!/bin/rc
+git/commit -me $1
--- /dev/null
+++ b/gitdpaint
@@ -1,0 +1,2 @@
+#!/bin/rc
+git/push -u hjgit://shithub.us/thedaemon/dpaint
--- /dev/null
+++ b/gopherd
@@ -1,0 +1,87 @@
+#!/bin/rc
+
+root=/usr/web/gopher
+server=thedaemon.space
+port=70
+
+fn gls {+r='{f=$10+sub("^'^$"root^'", "", f)+b=$10
+sub("^.*/", "", b)+print "'
+x='"b" "f" '^$"server^' '^$"port^'"
+next
+}'
+a='
+/^d/'^$"r^1^$"x^'
+/\.gph$/'^$"r^1^$"x^'
+/README$/'^$"r^0^$"x^'
+/\.Z$/'^$"r^5^$"x^'
+/\.awk$/'^$"r^0^$"x^'
+/\.c$/'^$"r^0^$"x^'
+/\.gif$/'^$"r^g^$"x^'
+/\.h$/'^$"r^0^$"x^'
+/\.html$/'^$"r^h^$"x^'
+/\.man$/'^$"r^0^$"x^'
+/\.mod$/'^$"r^s^$"x^'
+/\.mp3$/'^$"r^s^$"x^'
+/\.ms$/'^$"r^0^$"x^'
+/\.ogg$/'^$"r^s^$"x^'
+/\.pdf$/'^$"r^d^$"x^'
+/\.ps$/'^$"r^d^$"x^'
+/\.rc$/'^$"r^0^$"x^'
+/\.s$/'^$"r^0^$"x^'
+/\.tar$/'^$"r^5^$"x^'
+/\.tex$/'^$"r^0^$"x^'
+/\.tgz$/'^$"r^5^$"x^'
+/\.troff$/'^$"r^0^$"x^'
+/\.txt$/'^$"r^0^$"x^'
+/\.wav$/'^$"r^s^$"x^'
+/\.zip$/'^$"r^5^$"x^'
+/mkfile$/'^$"r^0^$"x^'
+'^$"r^9^$"x
+ls -l $1 | awk $"a | sed 's/$/
+/g'
+}
+
+fn gph {+ sed 's/\|server\|[^\|\]]+\]$/|'^$"server^'|'^$"port^']/;
+s/^\[//g; s/]$//g; s/(.)\|/\1/;
+s/\|/ /g; s/$//g;' < $1
+}
+
+r=`{read | sed 's/+//g; s/\.\.//g; s!//!!g;'}
+
+if(~ $"r ''){+ r=$"root
+}
+if not {+ r=$"root^$"r
+}
+
+if(test -d $"r){+ if(test -r $"r/index.gph){+ gph $"r/index.gph
+ }
+ if not {+ gls $"r
+ }
+}
+if not {+ if(test -r $"r) {+ if(~ $"r *.gph){+ gph $"r
+ }
+ if not {+ cat $"r
+ exit
+ }
+ }
+ if not {+ echo '3"'^$"r^'" not found error.file error.host 0
+'
+ }
+}
+echo '.'
--- /dev/null
+++ b/grid/chat
@@ -1,0 +1,125 @@
+#!/bin/rc
+# grid/chat - minimal chat client for hubfs
+# usage: grid/chat [-j CHANNEL] [-n NICK] [chatsrv]
+
+rfork efn
+
+fn helpmessage{+ echo ' /c to list channels'
+ echo ' /h for this message'
+ echo ' /j CHANNEL to change channel'
+ echo ' /m MSG to emote'
+ echo ' /n NICK to change nick'
+ echo ' /q to quit'
+}
+
+fn close{+ #echo $nick vanishes from $channel into the void. >>/n/$chatsrv/$channel
+ @{echo kill>/proc/$catkill/ctl}+}
+
+fn shutdown{+ close
+ exit
+}
+
+fn sighup{+ shutdown
+}
+
+fn sigint{+ shutdown
+}
+
+channel=chat
+chatsrv=149.28.123.225
+while (~ $1 -*){+ switch($1){+ case -j
+ channel = $2
+ shift 2
+ case -n
+ nick = $2
+ shift 2
+ case *
+ echo bad flag $1 -j CHANNEL -n NICK
+ shift
+ }
+}
+if(! ~ $1 '')
+ chatsrv=$1
+if(! test -e /n/$chatsrv/chat)
+ mount /srv/$chatsrv /n/$chatsrv
+if(! test -e /n/$chatsrv/chat){+ echo no chat service named $chatsrv found >[1=2]
+ exit no.chatsrv
+if(! test -e /n/$chatsrv/$channel)
+ echo no channel named $channel found >[1=2]
+ exit no.channel
+}
+
+label $channel
+if(~ $#nick 0)
+ nick=thedæmon
+#echo JOIN $nick to chat >>/n/$chatsrv/$channel
+cat /n/$chatsrv/$channel &
+catkill=$apid
+
+while(talk=`{read}){+ if(~ $talk /*){+ switch($talk){+ case /c
+ echo available channels:
+ lc /n/$chatsrv
+ echo -------------------
+ echo currently in $channel
+ echo
+ command=yes
+ case /h*
+ helpmessage
+ echo currently in $channel
+ echo
+ command=yes
+ case /j*
+ if (~ $talk(2) '')
+ echo must specify a channel
+ if not if(test -e /n/$chatsrv/$talk(2)){+ close
+ channel=$talk(2)
+ cat /n/$chatsrv/$channel &
+ catkill=$apid
+ #echo JOIN $nick to $channel >>/n/$chatsrv/$channel
+ }
+ if not
+ echo channel does not exist
+ command=yes
+ case /m*
+ if(! ~ $talk(2) ''){+ echo ' *' $nick $talk(2-) >>/n/$chatsrv/$channel
+ }
+ if not
+ echo must provide a message
+ command=yes
+ case /n*
+ if(! ~ $talk(2) ''){+ echo ' *' $nick is now $talk(2) >>/n/$chatsrv/$channel
+ nick=$talk(2)
+ }
+ if not
+ echo must supply a nick
+ command=yes
+ case /q*
+ shutdown
+ case *
+ echo unknown command
+ command=yes
+ }
+ }
+ if(~ $talk '')
+ command=yes
+ if(! ~ $command yes){+ line=`{echo $nick ' → ' $talk}+ echo $line >>/n/$chatsrv/$channel
+ }
+ command=no
+}
--- /dev/null
+++ b/grid/chatold
@@ -1,0 +1,127 @@
+#!/bin/rc
+# grid/chat - minimal chat client for hubfs
+# usage: grid/chat [-j CHANNEL] [-n NICK] [chatsrv]
+
+rfork efn
+
+fn helpmessage{+ echo ------------commands------------
+ echo ' /c to list channels'
+ echo ' /h for this message'
+ echo ' /j CHANNEL to change channel'
+ echo ' /m MSG to emote'
+ echo ' /n NICK to change nick'
+ echo ' /q to quit'
+ echo --------------------------------
+}
+# This is the message when you leave.
+fn close{+# echo PART $nick from $channel >>/n/$chatsrv/$channel
+ @{echo kill>/proc/$catkill/ctl}+}
+
+fn shutdown{+ close
+ exit
+}
+
+fn sighup{+ shutdown
+}
+
+fn sigint{+ shutdown
+}
+
+channel=chat
+chatsrv=chat.9p.zone
+while (~ $1 -*){+ switch($1){+ case -j
+ channel = $2
+ shift 2
+ case -n
+ nick = $2
+ shift 2
+ case *
+ echo bad flag $1 -j CHANNEL -n NICK
+ shift
+ }
+}
+if(! ~ $1 '')
+ chatsrv=$1
+if(! test -e /n/$chatsrv/chat)
+ mount /srv/$chatsrv /n/$chatsrv
+if(! test -e /n/$chatsrv/chat){+ echo no chat service named $chatsrv found >[1=2]
+ exit no.chatsrv
+if(! test -e /n/$chatsrv/$channel)
+ echo no channel named $channel found >[1=2]
+ exit no.channel
+}
+
+label $channel
+if(~ $#nick 0)
+ nick=anon
+#echo JOIN $nick to chat >>/n/$chatsrv/$channel
+cat /n/$chatsrv/$channel &
+catkill=$apid
+
+while(talk=`{read}){+ if(~ $talk /*){+ switch($talk){+ case /c
+ echo available channels:
+ lc /n/$chatsrv
+ echo -------------------
+ echo currently in $channel
+ echo
+ command=yes
+ case /h*
+ helpmessage
+ echo currently in $channel
+ echo
+ command=yes
+ case /j*
+ if (~ $talk(2) '')
+ echo must specify a channel
+ if not if(test -e /n/$chatsrv/$talk(2)){+ close
+ channel=$talk(2)
+ cat /n/$chatsrv/$channel &
+ catkill=$apid
+ #echo JOIN $nick to $channel >>/n/$chatsrv/$channel
+ }
+ if not
+ echo channel does not exist
+ command=yes
+ case /m*
+ if(! ~ $talk(2) ''){+ echo ' *' $nick $talk(2-) >>/n/$chatsrv/$channel
+ }
+ if not
+ echo must provide a message
+ command=yes
+ case /n*
+ if(! ~ $talk(2) ''){+ echo ' *' $nick is now $talk(2) >>/n/$chatsrv/$channel
+ nick=$talk(2)
+ }
+ if not
+ echo must supply a nick
+ command=yes
+ case /q*
+ shutdown
+ case *
+ echo unknown command
+ command=yes
+ }
+ }
+ if(~ $talk '')
+ command=yes
+ if(! ~ $command yes){+ line=`{echo $nick ' → ' $talk}+ echo $line >>/n/$chatsrv/$channel
+ }
+ command=no
+}
--- /dev/null
+++ b/grid/now
@@ -1,0 +1,2 @@
+#!/bin/rc
+grid/up && grid/chat
--- /dev/null
+++ b/grid/rio
@@ -1,0 +1,5 @@
+#!/bin/rc
+# grid/rio - rio script for gridchat
+# usage: rio [-s] -i grid/rio
+
+window -scroll grid/chat
--- /dev/null
+++ b/grid/up
@@ -1,0 +1,30 @@
+#!/bin/rc
+# grid/up - initialize grid services
+# usage: grid/up
+
+srv tcp!149.28.123.225!9990 149.28.123.225 /n/grid
+
+#
+#fn clean {+# echo $1 | sed 's/.*!([^!]+)!.*/\1/'2
+#}
+#
+#for(s in /n/registry/tcp*){+# s=`{basename $s}+# srv $s `{clean $s} /n/^`{clean $s} &+#}
+
+echo
+echo ' -- welcome to 9grid --'
+echo
+
+#while(~ $#nick 0){+# echo please enter a nick:
+# nick=`{read}+#}
+
+nick=thedæmon
+
+#exec rio -i grid/rio
+#window -scroll grid/chat
+grid/chat
--- /dev/null
+++ b/grid/upold
@@ -1,0 +1,40 @@
+#!/bin/rc
+# grid/up - initialize grid services
+# usage: grid/up
+
+srv tcp!149.28.123.225!9990 149.28.123.225 /n/gridtemp/
+srv -c tcp!149.28.123.225!9991 149.28.123.225 /n/disk
+
+# registry n/a atm
+#srv tcp!registry.9p.zone!6675 9p.zone.registry /n/registry
+#
+#fn clean {+# echo $1 | sed 's/.*!([^!]+)!.*/\1/'2
+#}
+#
+#for(s in /n/registry/tcp*){+# s=`{basename $s}+# srv $s `{clean $s} /n/^`{clean $s} &+#}
+
+echo
+echo ' -- welcome to 9grid --'
+echo ------------commands------------
+echo ' /c to list channels'
+echo ' /h for this message'
+echo ' /j CHANNEL to change channel'
+echo ' /m MSG to emote'
+echo ' /n NICK to change nick'
+echo ' /q to quit'
+echo --------------------------------
+echo
+
+#while(~ $#nick 0){+# echo please enter a nick:
+# nick=`{read}+#}
+
+nick=thedæmon
+
+#exec rio -i grid/rio
+#window -scroll grid/chat
--- /dev/null
+++ b/highres
@@ -1,0 +1,2 @@
+#!/bin/rc
+rfork n; aux/realemu; aux/vga -l 2560x1440x32
--- /dev/null
+++ b/irc/catv
@@ -1,0 +1,2 @@
+#!/bin/rc
+ircx -s oftc -t '#cat-v'
--- /dev/null
+++ b/irc/chats
@@ -1,0 +1,9 @@
+#!/bin/rc
+# lower left chat window
+window -r 0 800 900 1440 -scroll
+# lower right chat window
+window -r 910 800 1810 1440 -scroll
+# upper left
+window -r 0 210 900 790 -scroll
+# upper right
+window -r 910 210 1810 790 -scroll
--- /dev/null
+++ b/irc/occ
@@ -1,0 +1,2 @@
+#!/bin/rc
+ircx -s libera -t '#oldcomputerchallenge'
--- /dev/null
+++ b/irc/start
@@ -1,0 +1,3 @@
+#!/bin/rc
+ircs -p -s oftc thedaemon irc.oftc.net &
+ircs -p -s libera thedaemon irc.libera.chat &
--- /dev/null
+++ b/irc/startrek
@@ -1,0 +1,2 @@
+#!/bin/rc
+ircx -s libera -t '#startrek'
--- /dev/null
+++ b/irc/surreal
@@ -1,0 +1,2 @@
+#!/bin/rc
+ircx -s libera -t '#unix_surrealism'
--- /dev/null
+++ b/irctime
@@ -1,0 +1,25 @@
+#!/bin/awk -f
+# irctime: convert ircs timestamps to ISO 8601 format
+BEGIN {+ mon["Jan"] = "01"
+ mon["Feb"] = "02"
+ mon["Mar"] = "03"
+ mon["Apr"] = "04"
+ mon["May"] = "05"
+ mon["Jun"] = "06"
+ mon["Jul"] = "07"
+ mon["Aug"] = "08"
+ mon["Sep"] = "09"
+ mon["Oct"] = "10"
+ mon["Nov"] = "11"
+ mon["Dec"] = "12"
+}
+/^-- / {+ dd = $3
+ mm = mon[$4]
+ yyyy = $5
+ next
+}
+{+ print yyyy "-" mm "-" dd "T" $0
+}
--- /dev/null
+++ b/ircx
@@ -1,0 +1,323 @@
+#!/bin/rc
+# ircx: ircs ui
+rfork e
+
+flagfmt='e,p,r,T,U,s srvname,f file,t target,b lines'
+args='[nick[!user] addr]'
+
+srv=ircs
+mainlog=()
+log=()
+opt=()
+
+lines=()
+target=()
+offset=()
+
+help='<del>, /q quit ircx (leaves ircs running)
+/h print this help
+/j #channel join #channel and set it as target
+/n nick change nick
+/N list nicks on channel target
+/p [message] part from channel target
+/Q [message] quit (stops ircs)
+/r message send raw message to server
+/t target set target (channel or nick)
+/T [topic] get [set] topic of channel target
+/w mask send who query
+/W mask send whois query
+/x create new ircx window
+[/ ]message send message to target
+/me message send an action emote'
+
+fn usage{+ aux/usage
+ exit usage
+}
+fn fatal{+ echo $* >[1=2]
+ exit $"*
+}
+fn isnum{+ echo $1 | grep -s '^[0-9]+$'
+}
+fn clear{+ awk 'BEGIN {+ for(i = 0; i < '$1'; i++)
+ printf "\x08"
+ }'
+}
+fn runtail{+ { tail -$2+ while(sleep 1) cat
+ } <$1 &
+ tailpid=$apid
+}
+fn oldlabel{+ if(! ~ $#oldlabel 0)
+ label $oldlabel
+}
+fn killtail{+ @{+ echo kill >/proc/$tailpid/note
+ } &
+}
+fn saveoffset{+ if(~ $#offset 1 && test -r $log)
+ wc -l <$log | tr -d ' ' >$offset
+}
+fn shutdown{+ saveoffset
+ killtail
+ oldlabel
+ exit 0
+}
+fn sighup sigint sigterm{+ shutdown
+}
+fn send{+ if(test -e /srv/$srv)
+ echo $* >>/srv/$srv
+ if not{+ echo /srv/$srv not found '(ircs stopped?)'
+ shutdown
+ }
+}
+fn settarget{+ if(~ $1 ''){+ target=()
+ label $mainlog
+ }
+ if not{+ target=$1
+ label $target
+ }
+}
+fn newtarget{+ if(~ $#flagf 1)
+ settarget $newtarget
+ if not{+ if(~ $newtarget '#'*){+ f=/tmp/$srv/$newtarget
+ sleep 1
+ }
+ if not{+ settarget $newtarget
+ f=$mainlog
+ }
+ if(! ~ $f $log){+ if(test -r $f){+ settarget $newtarget
+ saveoffset
+ offset=()
+ killtail
+ log=$f
+ echo $log
+ runtail $log 10
+ }
+ if not
+ echo can''''t access $f
+ }
+ }
+ newtarget=()
+}
+fn lines{+ if(~ $#offset 1 && test -r $offset && test -r $log){+ n₀=`{cat $offset}+ n₁=`{wc -l <$log}+ δn=`{echo $n₁ - $n₀ + 10 | bc}+ echo $δn
+ }
+ if not
+ echo 10
+}
+
+if(! ifs=() eval `{aux/getflags $*} || ! ~ $#* 0 2)+ usage
+
+if(~ $#flagb 1){+ if(! isnum $flagb)
+ usage
+ lines=$flagb
+}
+if(~ $#flagt 1)
+ target=$flagt
+
+if(~ $#flags 1){+ if(~ $flags '')
+ fatal empty srvname
+ srv=$flags
+ opt=($opt -s $srv)
+}
+if(~ $#flagf 1){+ mainlog=$flagf
+ opt=($opt -f $mainlog)
+}
+if not{+ mainlog=/tmp/$srv/log
+ if(~ $#lines 0){+ offset=/tmp/$srv/offsets/log
+ mkdir -p /tmp/$srv/offsets
+ }
+}
+if(~ $#flage 1) opt=($opt -e)
+if(~ $#flagp 1) opt=($opt -p)
+if(~ $#flagr 1) opt=($opt -r)
+if(~ $#flagT 1) opt=($opt -T)
+if(~ $#flagU 1) opt=($opt -U)
+
+switch($#*){+case 0
+ for(i in /srv/$srv $mainlog)
+ if(! test -e $i)
+ fatal $i not found
+case 2
+ if(test -e /srv/$srv)
+ fatal ircs already running
+ nick=$1
+ addr=$2
+ ircs $opt $nick $addr
+ stat=$status
+ if(! ~ $stat '')
+ exit $stat
+case *
+ usage
+}
+
+oldlabel=`{cat /dev/label}+oifs=$ifs
+log=$mainlog
+
+if(~ $#target 1){+ label $target
+ if(~ $target '#'*){+ send JOIN $target
+ if(~ $#flagf 0){+ log=/tmp/$srv/$target
+ if(~ $#lines 0)
+ offset=/tmp/$srv/offsets/$target
+ if(! test -e $log)
+ sleep 1
+ }
+ }
+}
+if not
+ label $log
+
+if(~ $#lines 0)
+ lines=`{lines}+
+echo $log -$lines
+runtail $log $lines
+
+while(ifs=() line=`{read | tr -d \xa}){+ ifs=$oifs
+ clear `{echo $line | wc -r}+
+ if(! ~ $line ''){+ msg=()
+ *=`{echo $line}+ cmd=$1
+ shift
+
+ switch($cmd){+ case /h
+ echo $help
+ case /j
+ if(~ $#* 0)
+ echo no channel
+ if not{+ msg='JOIN '^$"*
+ newtarget=$1
+ }
+ case /t
+ if(~ $#* 0)
+ echo no target
+ if not
+ newtarget=$1
+ case /N
+ if(! ~ $target '#'*)
+ echo no channel
+ if not
+ msg='NAMES '^$target
+ case /T
+ if(! ~ $target '#'*)
+ echo no channel
+ if not{+ msg='TOPIC '^$target
+ if(! ~ $#* 0)
+ msg=$msg^' :'^$"*
+ }
+ case /p
+ if(! ~ $target '#'*)
+ echo no channel
+ if not{+ msg='PART '^$target
+ if(! ~ $#* 0)
+ msg=$msg^' :'^$"*
+ newtarget=''
+ }
+ case /q
+ shutdown
+ case /Q
+ if(~ $#* 0)
+ send QUIT
+ if not
+ send 'QUIT :'^$"*
+ sleep 1
+ shutdown
+ case /r
+ if(~ $#* 0)
+ echo no message
+ if not{+ ifs=()
+ msg=`{echo -n $line | sed 's!^[ ]*/r[ ]+!!'}+ ifs=$oifs
+ }
+ case /n
+ if(~ $#* 0)
+ echo no nick
+ if not
+ msg='NICK '^$1
+ case /w
+ if(~ $#* 0)
+ echo no mask
+ if not
+ msg='WHO '^$"*
+ case /W
+ if(~ $#* 0)
+ echo no mask
+ if not
+ msg='WHOIS '^$"*
+ case /x
+ window -m ircx $opt
+ case /
+ if(~ $#target 0)
+ echo no target
+ if not{+ ifs=()
+ line=`{echo -n $line | sed 's!^[ ]*/[ ]*!!'}+ ifs=$oifs
+ msg='PRIVMSG '^$target^' :'^$line
+ }
+ case /me
+ if(~ $#target 0)
+ echo no target
+ if not
+ msg='PRIVMSG '^$target^' :ACTION '^$"*^''
+ case /*
+ echo unknown command
+ case *
+ if(~ $#target 0)
+ echo no target
+ if not
+ msg='PRIVMSG '^$target^' :'^$line
+ }
+ if(! ~ $#msg 0)
+ send $msg
+
+ if(~ $#newtarget 1)
+ newtarget
+ }
+}
+shutdown
--- /dev/null
+++ b/l
@@ -1,0 +1,3 @@
+#!/bin/rc
+pwd
+lc
--- /dev/null
+++ b/lowres
@@ -1,0 +1,2 @@
+#!/bin/rc
+rfork n; aux/realemu; aux/vga -l 1920x1080x32
--- /dev/null
+++ b/m
@@ -1,0 +1,2 @@
+#!/bin/rc
+mothra -a $*
--- /dev/null
+++ b/mailstart
@@ -1,0 +1,2 @@
+#!/bin/rc
+upas/fs -f /imaps/disroot.org/thedaemon@disroot.org &
--- /dev/null
+++ b/masto
@@ -1,0 +1,2 @@
+#!/bin/rc
+masto9 bsd.network $*
--- /dev/null
+++ b/md
@@ -1,0 +1,13 @@
+#!/bin/rc
+# md - play mega drive (genesis) games
+# usage: md [params] rom
+# requires:
+# - emu
+# - rescale
+
+if(~ $*(1) ''){+ echo $0 'usage: md [params] rom' >[1=2]
+ exit usage
+}
+
+emu md 320 224 $*
--- /dev/null
+++ b/mountspace
@@ -1,0 +1,3 @@
+#!/bin/rc
+
+rimport -p -u $user thedaemon.space / /n/space
--- /dev/null
+++ b/nectarineradio
@@ -1,0 +1,2 @@
+#!/bin/rc
+hget http://necta.burn.net:8000/nectarine | play
--- /dev/null
+++ b/news
@@ -1,0 +1,2 @@
+#!/bin/rc
+window 'nntpfs -a news.eternal-september.org'
--- /dev/null
+++ b/nofront
@@ -1,0 +1,2 @@
+#!/bin/rc
+ircx -s libera -t '#nofront'
--- /dev/null
+++ b/nojqpn
@@ -1,0 +1,2 @@
+#!/bin/grep -vf
+^[0-9:]+ (JOIN|QUIT|PART|NICK)
--- /dev/null
+++ b/pkginit
@@ -1,0 +1,305 @@
+#!/bin/rc
+# pkginit - set up pkg
+# usage: pkginit
+
+instdir=/rc/bin/pkg
+
+fn die{+ >[1=2] echo !! $*
+ >[1=2] echo !! exiting...
+ exit $"*
+}
+
+fn fin{+ say installation successful
+ say use pkg/add to install packages
+ exit ''
+}
+
+fn say{+ >[1=2] echo :: $*
+}
+
+>[1=2] echo -n '|| package store location? [/sys/pkg] '
+pkgdir=`{read}+switch($pkgdir){+case ''
+ pkgdir=/sys/pkg
+case /*
+ pkgdir=$pkgdir(1)
+case *
+ die please use an absolute path
+}
+
+say initializing pkg...
+if(! test -d $pkgdir){+ say creating $pkgdir...
+ mkdir -p $pkgdir || die failed to create $pkgdir
+}
+if not say $pkgdir already exists
+if(! test -d $instdir){+ say creating $instdir...
+ mkdir -p $instdir || die failed to create $instdir
+}
+if not say $instdir already exists
+
+say adding pkg/env to $instdir...
+>$instdir/env cat <<'...' | >[2=] sed -e 's!REPLACE!'$pkgdir'!g' || die failed to install $instdir/env
+pkgdir=REPLACE
+pkglist=$pkgdir/.pkglist
+pkgs=(`{>[2=] sed -e '/^#/d;/^$/d;s/.*pkg=//g;s/\ .*//g' $pkglist})+t=/tmp/pkg.$pid
+
+fn checklist{+ if(! test -s $pkglist) die no pkglist found
+}
+
+fn die{+ rm -f $t
+ >[1=2] echo !! $*
+ >[1=2] echo !! exiting...
+ exit $"*
+}
+
+fn say{+ >[1=2] echo :: $*
+}
+
+fn sighup sigint sigterm{+ rm -f $t
+ exit interrupt
+}
+...
+
+say adding pkg/add to $instdir...
+>$instdir/add cat <<'...' || die failed to install $instdir/add
+#!/bin/rc
+rfork en
+. pkg/env
+
+flagfmt=''; args='url ...'
+if(! eval `''{aux/getflags $*} || ~ $#* 0) exec aux/usage+
+for(repo in $*){+ pkg=`{echo $repo | awk -F'/' '{print $NF}'}+ say pulling $pkg...
+ git/clone $repo $pkgdir/$pkg || die failed to clone $pkg
+ cd $pkgdir/$pkg
+ if(~ $pkg 'nsport'){+ fetch clone http || die failed to fetch $pkg
+ say building $pkg...
+ mk || die failed to build $pkg
+ }
+ say installing $pkg...
+ mk install || die failed to install $pkg
+ say $pkg installed, cleaning...
+ mk clean || die failed to clean $pkg
+ >>$pkglist echo 'pkg='$pkg' url='$repo
+ say $pkg successfully added to pkglist
+} || exit
+
+say all packages successfully installed
+exit ''
+...
+chmod +x $instdir/add || die failed to chmod $instdir/add
+
+say adding pkg/del to $instdir...
+>$instdir/del cat <<'...' || die failed to install $instdir/del
+#!/bin/rc
+rfork en
+. pkg/env
+checklist
+
+flagfmt=''; args='name ...'
+if(! eval `''{aux/getflags $*} || ~ $#* 0) exec aux/usage+
+for(pkg in $*){+ cp $pkglist $t
+ if(test -d $pkgdir/$pkg){+ cd $pkgdir/$pkg
+ say uninstalling $pkg...
+ mk uninstall || die failed to uninstall $pkg
+ cd $pkgdir
+ say removing $pkg sources...
+ rm -rf $pkg || die failed to remove $pkg
+ say removing $pkg from pkglist...
+ >$t.x grep -ve 'pkg='$pkg $t
+ mv $t.x $t
+ mv $t $pkglist
+ }
+ if not die $pkg not installed
+} || exit
+
+say all packages successfully removed
+exit ''
+...
+chmod +x $instdir/del || die failed to chmod $instdir/del
+
+say adding pkg/ls to $instdir...
+>$instdir/ls cat <<'...' || die failed to install $instdir/ls
+#!/bin/rc
+rfork en
+. pkg/env
+checklist
+
+flagfmt='c:c'
+eval `''{aux/getflags $*} || exec aux/usage+
+if(~ $c 1) >[1=2] echo $#pkgs
+if not{+ say managed packages:
+ >[1=2] echo $pkgs | tr ' ' '\x0A' | sort | mc
+}
+
+exit ''
+...
+chmod +x $instdir/ls || die failed to chmod $instdir/ls
+
+say adding pkg/up to $instdir...
+>$instdir/up cat <<'...' || die failed to install $instdir/up
+#!/bin/rc
+rfork en
+. pkg/env
+checklist
+
+flagfmt=''; args='[name ...]'
+eval `''{aux/getflags $*} || exec aux/usage+
+if(~ $#* 0) name=$pkgs
+if not name=$*
+
+for(pkg in $name){+ if(test -d $pkgdir/$pkg){+ cd $pkgdir/$pkg
+ say updating $pkg...
+ if(~ $pkg 'nsport'){+ fetch pull || die failed to fetch $pkg
+ say building $pkg...
+ mk || die failed to build $pkg
+ }
+ if not git/pull || die failed to fetch $pkg
+ }
+ if not if(grep -se 'pkg='$pkg $pkglist){+ sel=($pkg `{grep -e 'pkg='$pkg $pkglist | sed -ne '/^#/d;s/.*url=//g;s/\ .*//g;1p'})+ if(test $#sel -lt 2) die $pkg not in pkglist
+ say pulling $pkg...
+ git/clone $sel(2) $pkgdir/$sel(1) || die failed to clone $pkg
+ cd $pkgdir/$pkg
+ if(~ $pkg 'nsport'){+ fetch clone http || die failed to fetch $pkg
+ say building $pkg...
+ mk || die failed to build $pkg
+ }
+ }
+ if not die $pkg not in pkglist
+ say installing $pkg...
+ mk install || die failed to install $pkg
+ say $pkg installed, cleaning...
+ mk clean || die failed to clean $pkg
+} || exit
+
+say all updates successfully completed
+exit ''
+...
+chmod +x $instdir/up || die failed to chmod $instdir/up
+
+say installing manual...
+>/sys/man/1/pkg cat <<'...' | >[2=] sed -e 's!REPLACE!'$pkgdir'!g' || die failed to install manual
+.TH PKG 1
+.SH NAME
+pkg, pkg/add, pkg/del, pkg/ls, pkg/up \- Manage third-party packages.
+
+.SH SYNOPSIS
+.PP
+.B pkg/add
+.I url ...
+.PP
+.B pkg/del
+.I name ...
+.PP
+.B pkg/ls
+[
+.B -c
+]
+.PP
+.B pkg/up
+[
+.I name ...
+]
+
+.SH DESCRIPTION
+.PP
+.I Pkg
+is a simple package manager. It uses
+.IR git (1)
+and
+.IR mk (1)
+to automatically clone, install, and update third-party source
+repositories from a database.
+
+.SH COMMANDS
+.PP
+.B Pkg/add
+is used to install new packages. Packages are fetched via
+.IR git ,
+after which they are built, installed, and finally cleaned with
+.IR mk .
+An entry is then added to the database of managed packages.
+.PP
+.B Pkg/del
+is used to purge packages. Selected packages are uninstalled with
+.I mk
+and their sources are removed from the store, after which their entry
+is removed from the database of managed packages.
+.PP
+.B Pkg/ls
+displays a columnated list of packages currently being managed by
+.IR pkg .
+Passing the
+.B -c
+option will instead display a
+.I count
+of managed packages.
+.PP
+.B Pkg/up
+is used to update packages to their latest versions followed by the
+build steps described above for
+.BR pkg/add .
+If no package is specified, all packages are updated.
+
+.SH FILES
+.TP
+REPLACE/.pkglist
+The database of managed packages.
+
+.SH NOTES
+.PP
+There are no automatic dependency management triggers and packages are
+updated in the order in which they were installed.
+.PP
+Packages without an
+.I uninstall
+target in their
+.I mkfile
+will cause
+.B pkg/del
+to exit without removing sources or purging the entry from the
+database.
+.PP
+Entries without a corresponding source directory in the store will be
+pulled automatically when running
+.BR pkg/up .
+This means a pre-generated
+.I .pkglist
+can be supplied to quickly install a large selection of packages.
+
+.SH BUGS
+.PP
+Probably.
+
+.SH SEE ALSO
+.IR git (1),
+.IR mk (1)
+...
+
+fin
--- /dev/null
+++ b/playbsd
@@ -1,0 +1,4 @@
+#!/bin/rc
+rfork ne
+
+ audio/zuke < /usr/$user/music/bsdmusic.plist
--- /dev/null
+++ b/playmusic
@@ -1,0 +1,4 @@
+#!/bin/rc
+rfork ne
+
+ audio/zuke < /usr/$user/music/bsdmusic.plist
--- /dev/null
+++ b/program
@@ -1,0 +1,3 @@
+#!/bin/rc
+
+acme -l /usr/thedaemon/docs/prog.dump
--- /dev/null
+++ b/quake
@@ -1,0 +1,3 @@
+#!/bin/rc
+games/quake >/dev/null
+
--- /dev/null
+++ b/rcpustart
@@ -1,0 +1,2 @@
+#!/bin/rc
+aux/listen1 -t 'tcp!*!rcpu' /rc/bin/service/tcp17019 &
--- /dev/null
+++ b/rdp
@@ -1,0 +1,2 @@
+#!/bin/rc
+rd 192.168.0.100
--- /dev/null
+++ b/rescale
@@ -1,0 +1,12 @@
+#!/bin/rc
+# rescale - resize a window
+# usage: rescale width height
+echo $vgasize | awk -Fx -v 'w='$1 -v 'h='$2 '
+{+ dx = $1 / w
+ dy = $2 / h
+ scale = int(dy < dx ? dy : dx)
+ if(scale * w == $1 || scale * h == $2)
+ scale--
+ print "resize -dx", scale * w + 8, "-dy", scale * h + 8 >"/dev/wctl"
+}'
--- /dev/null
+++ b/riostart
@@ -1,0 +1,28 @@
+#!/bin/rc
+
+# theme
+#window 'cat /usr/thedaemon/lib/theme/gruv9.theme > /mnt/wsys/theme'
+themes gruv9
+setbg glenda
+
+# console to keep the horrors at bay
+window -hide -scroll cat /dev/kprint >> /sys/log/kernel
+
+# riow & bar script
+window wm
+
+# password gui popups when needed
+window -hide auth/fgui
+
+# statistics
+window 10,10,200,200 statsdark -lmisce
+
+# window list
+window 10,210,200,600 winwatchsand -e '^(winwatch|auth/fgui|9weather|cat|stats|faces|bar|vol|fgui)'
+
+# weather
+window 10,610,230,800 9weather -i -z 35022,US -k a29dc2d85251c76e67b5be32354be64f
+
+
+# faces
+#window 940,10,1200,210 faces -i
--- /dev/null
+++ b/sdf
@@ -1,0 +1,2 @@
+#!/bin/rc
+rcpu -h 9p.sdf.org -u thedaemon
--- /dev/null
+++ b/sdfcom
@@ -1,0 +1,2 @@
+#!/bin/rc
+9psdf && com
--- /dev/null
+++ b/setbg
@@ -1,0 +1,133 @@
+#!/bin/rc
+
+rfork en
+bgdir=$home/lib/theme/bg
+
+fn default{+ >/dev/theme cat <<'...'
+rioback 777777
+...
+ exit
+}
+
+fn list{+ if(! test -d $bgdir)
+ error nodir
+ bglist=`{walk -f $bgdir | grep -e '*.bit' | sort}+ switch($bglist){+ case ''
+ error nolist
+ case *
+ echo 'available backgrounds in' $bgdir
+ for(i in $bglist)
+ echo ' -' `{basename $i .bit}+ exit
+ }
+}
+
+fn error{+ switch($1){+ case nodev
+ echo 'error: /dev/theme not found'
+ echo 'is rio running and is it patched?'
+ exit nodev
+ case nodir
+ echo 'error:' $bgdir 'is not a directory'
+ exit nodir
+ case nofile
+ echo 'error: background file for "'$arg'" not found in' $bgdir
+ exit nofile
+ case nolist
+ echo 'error: no valid backgrounds found in' $bgdir
+ exit nolist
+ case nopath
+ echo 'error: no path specified'
+ usage
+ case nobg
+ echo 'error: no background file specified'
+ usage
+ case unknown
+ echo 'error: unknown option "'$flag'"'
+ usage
+ }
+}
+
+fn help{+ echo 'options:'
+ echo ' -d for default colors'
+ echo ' -p for setting $bgdir (default=$home/lib/theme/bg)'
+ echo ' -l for list of available backgrounds'
+ echo ' -r for random background'
+ echo 'requires:'
+ echo ' - rio patched for theme support (see https://ftrv.se/14)'
+ echo ' - <name>.bit files in $bgdir'
+ echo ' * ex:' $bgdir/glenda_wallpaper.bit
+ usage
+}
+
+fn random{+ if(! test -d $bgdir)
+ error nodir
+ randbg=`{fortune <{walk -f $bgdir | grep -e '*.bit'}}+ switch($randbg){+ case ''
+ error nolist
+ case *
+ echo rioback $randbg >/dev/theme
+ exit
+ }
+}
+
+
+fn usage{+ echo 'usage: setbg [-h help] [-d default] [-p /path/to/bgdir] [-l list] [-r random] <name>'
+ exit usage
+}
+
+
+############ Main
+if(! test -f /dev/theme)
+ error nodev
+
+while(~ $1 -*){+ switch($1){+ case -p
+ switch($2){+ case '' -*
+ error nopath
+ case *
+ bgdir=$2
+ shift 2
+ }
+ case -d
+ default
+ case -h -help --help
+ help
+ case -l
+ list
+ case -r
+ random
+ case *
+ flag=$1
+ error unknown
+ }
+}
+switch($#*){+case 0
+ if(~ $#bg 1)
+ arg=$bg
+ if not
+ error nobg
+case 1
+ arg=$1
+case *
+ usage
+}
+
+if(! test -d $bgdir)
+ error nodir
+
+if(! test -f $bgdir/$arg.bit)
+ error nofile
+
+echo rioback $bgdir/$arg.bit > /dev/theme
--- /dev/null
+++ b/surl
@@ -1,0 +1,25 @@
+#!/bin/rc
+#
+# set site and surl then mkdir $surl
+#
+site=https://9p.sdf.org
+surl=/usr/web/l
+
+if(! test -d $surl){+ echo $surl does not exist.
+ exit
+}
+
+echo -n 'surl: '
+url=`{read}+if(! ~ $url ''){+ last=`{ls -rt $surl|awk -F/ '{print $5}'|tail -1}+ if(~ $last ''){+ last=0
+ }
+ last=`{echo $last|tr a-z A-Z}+ next=`{echo 'ibase=16;obase=16; ' $last+1 | bc|awk '{print $1}'}+ mkdir $surl/$next
+ echo '<html><meta http-equiv=refresh content="0; url='$url'"></html>' > $surl/$next/index.html
+ echo $site/l/$next
+}
--- /dev/null
+++ b/synctime
@@ -1,0 +1,2 @@
+#!/bin/rc
+aux/timesync -n pool.ntp.org
--- /dev/null
+++ b/themes
@@ -1,0 +1,160 @@
+#!/bin/rc
+# theme - set a rio(1) theme
+# usage: theme [-d] [-p /path/to/themedir] [-l] [-r] <name>
+# requires:
+# - patched rio with theme support (https://ftrv.se/14)
+# - <name>.theme files in $themedir
+
+############################
+## defaults / definitions ##
+############################
+rfork en
+themedir=$home/lib/theme
+
+fn default{+ >/dev/theme cat <<'...'
+rioback 777777
+back ffffff
+high cccccc
+border 999999
+text 000000
+htext 000000
+title 55aaaa
+ltitle 9eeeee
+hold 000099
+lhold 005dbb
+palehold 4993dd
+paletext 666666
+size ff0000
+menubar 448844
+menuback eaffea
+menuhigh 448844
+menubord 88cc88
+menutext 000000
+menuhtext eaffea
+...
+ exit
+}
+
+fn error{+ switch($1){+ case nodev
+ echo 'error: /dev/theme not found'
+ echo 'is rio running and is it patched?'
+ exit nodev
+ case nodir
+ echo 'error:' $themedir 'is not a directory'
+ exit nodir
+ case nofile
+ echo 'error: theme file for "'$arg'" not found in' $themedir
+ exit nofile
+ case nolist
+ echo 'error: no valid themes found in' $themedir
+ exit nolist
+ case nopath
+ echo 'error: no path specified'
+ usage
+ case notheme
+ echo 'error: no theme file specified'
+ usage
+ case unknown
+ echo 'error: unknown option "'$flag'"'
+ usage
+ }
+}
+
+fn help{+ echo 'options:'
+ echo ' -d for default colors'
+ echo ' -p for setting $themedir (default=$home/lib/theme)'
+ echo ' -l for list of available themes'
+ echo ' -r for random theme'
+ echo 'requires:'
+ echo ' - rio patched for theme support (see https://ftrv.se/14)'
+ echo ' - <name>.theme files in $themedir'
+ echo ' * ex:' $themedir/my_awesome.theme
+ usage
+}
+
+fn list{+ if(! test -d $themedir)
+ error nodir
+ themelist=`{walk -f $themedir | grep -e '*.theme' | sort}+ switch($themelist){+ case ''
+ error nolist
+ case *
+ echo 'available themes in' $themedir
+ for(i in $themelist)
+ echo ' -' `{basename $i .theme}+ exit
+ }
+}
+
+fn random{+ if(! test -d $themedir)
+ error nodir
+ randtheme=`{fortune <{walk -f $themedir | grep -e '*.theme'}}+ switch($randtheme){+ case ''
+ error nolist
+ case *
+ cat $randtheme >/dev/theme
+ exit
+ }
+}
+
+fn usage{+ echo 'usage: themes [-h help] [-d default] [-p /path/to/themedir] [-l list] [-r random] <name>'
+ exit usage
+}
+
+###############
+## main body ##
+###############
+if(! test -f /dev/theme)
+ error nodev
+
+while(~ $1 -*){+ switch($1){+ case -p
+ switch($2){+ case '' -*
+ error nopath
+ case *
+ themedir=$2
+ shift 2
+ }
+ case -d
+ default
+ case -h -help --help
+ help
+ case -l
+ list
+ case -r
+ random
+ case *
+ flag=$1
+ error unknown
+ }
+}
+
+switch($#*){+case 0
+ if(~ $#theme 1)
+ arg=$theme
+ if not
+ error notheme
+case 1
+ arg=$1
+case *
+ usage
+}
+
+if(! test -d $themedir)
+ error nodir
+
+if(! test -f $themedir/$arg.theme)
+ error nofile
+
+cat $themedir/$arg.theme >/dev/theme
--- /dev/null
+++ b/themez
@@ -1,0 +1,17 @@
+#!/bin/rc
+
+if(~ $#* 0){+ echo 'Usage: theme [ls|set theme]'
+}
+
+comm=$1
+
+switch($comm){+
+case 'ls'
+ lc $home/lib/theme/
+case 'set'
+ theme=$2
+
+ cat $home/lib/theme/$theme > /dev/theme
+ }
--- /dev/null
+++ b/top
@@ -1,0 +1,2 @@
+#!/bin/rc
+ps -axw|sort -k5n|tail -25
--- /dev/null
+++ b/toppish
@@ -1,0 +1,96 @@
+#!/bin/rc
+# top
+rfork en
+
+flagfmt='d interval,m maxlines'
+args=''
+
+old=/tmp/top.$pid.old
+new=/tmp/top.$pid.new
+out=/tmp/top.$pid.out
+
+int=5
+max=20
+len=()
+
+fn usage{+ aux/usage
+ exit usage
+}
+fn isfloat{+ echo $1 | grep -s '^[0-9\.]+$'
+}
+fn isnum{+ echo $1 | grep -s '^[0-9]+$'
+}
+fn get{+ grep . */status |
+ sed '
+ s!/status:! !
+ s! +! !g
+ '
+}
+fn clear{+ awk 'END { for(i = 0; i < '$len'; i++) printf "\x08" }' </dev/null+}
+fn sigint{+ rm -f $old $new $out
+ exit
+}
+fn top{+ get | tee $new | join - $old |
+ awk '
+ {+ newusr = $5
+ newsys = $6
+ oldusr = $17
+ oldsys = $18
+ delta = newusr + newsys - (oldusr + oldsys)
+ pid = $1
+ name = $2
+ user = $3
+ state = $4
+ mem = $11
+ usr = newusr / 1000
+ sys = newsys / 1000
+ printf("%-10s %8s %6s %4ld:%.2ld %3ld:%.2ld %8ldK %-8s %s\n",+ user, pid, delta,
+ usr / 60, usr % 60,
+ sys / 60, sys % 60,
+ mem, state, name)
+ }
+ ' |
+ sort -nr +2 -3 | sed $max^q
+ mv $new $old
+}
+
+if(! ifs=() eval `{aux/getflags $*})+ usage
+if(~ $#flagd 1){+ if(! isfloat $flagd)
+ usage
+ int=$flagd
+}
+if(~ $#flagm 1){+ if(! isnum $flagm)
+ usage
+ max=$flagm
+}
+cd /proc
+ramfs
+get >$old
+sleep $int
+
+while(){+ {+ echo
+ uptime
+ top
+ } >$out
+ if(~ $#len 1)
+ clear
+ len=`{wc -r <$out}+ cat $out
+ sleep $int
+}
+
--- /dev/null
+++ b/tube
@@ -1,0 +1,82 @@
+#!/bin/rc
+# tube - a wrapper for treason
+# usage: tube
+# requires:
+# - treason (https://git.sr.ht/~ft/treason)
+#
+# notes:
+# - use with the following plumbing rules:
+
+# dst is video
+# plumb to video
+# plumb client window tube
+
+# wdir is /mnt/⏵
+# data matches [0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]
+# plumb to video
+
+# data matches .+\.(mp4|mkv|webm)
+# arg isfile $data
+# data set $file
+# plumb to video
+# plumb client window tube
+
+ramfs -um/mnt/⏵
+cd /mnt/⏵
+echo -n /mnt/⏵ >/dev/wdir
+echo -n ⏵ >/dev/label
+echo -n scroll >/dev/wctl
+</mnt/plumb/video while(>/dev/null{+ read # src
+ read # dst
+ read # wdir
+ read # type
+ attr = `{read}+ ndata = `{read}+}){+ if(~ $attr *'action=showdata'*){+ read -c $ndata >tmp
+ data = `{sum tmp | read -c 8}+ mv tmp $data
+ }
+ if not
+ data = `''{read -c $ndata}+ echo -n unhide >/dev/wctl >[2]/dev/null
+ echo -n current >/dev/wctl
+ if(! ~ $data /* && ~ $data *[~0-9a-f]* || ! test -f $data){+ echo -n 'bad plumb: '
+ cat /env/data
+ echo
+ }
+ if not{+ echo playing $data …
+ treason $data
+ if(! ~ $data /*){+ done = 0
+ echo -n `{{walk -es $data; echo 1048576/1+p}|dc} 'MB: '+ while(~ $done 0){+ echo 𝐫ewatch, 𝐰rite to disk, 𝐝elete from ram, or 𝐤eep in ram for now?
+ echo -n >/dev/kbdin
+ >[3]/dev/consctl{+ echo rawon >[1=3]
+ k = `''{read -c 1 /dev/cons}+ }
+ switch($k){+ case r
+ plumb $data
+ done = 1
+ case w
+ echo -n 'write: '
+ k = `{read /dev/cons}+ mv $data $k && done = 1
+ case d
+ rm $data && echo $data removed from ramfs && done = 1
+ case i
+ echo ignoring for now: replumb later to watch again, write, or delete
+ done = 1
+ }
+ }
+ }
+ echo -n hide >/dev/wctl
+ }
+}
binary files /dev/null b/upd differ
--- /dev/null
+++ b/update
@@ -1,0 +1,57 @@
+#!/bin/rc
+# update - update your 9front system
+# usage: update
+
+curdir=`{pwd}+
+echo UPDATING SYSTEM SOURCE CODE
+
+sysupdate
+
+echo DOWNLOAD COMPLETED
+echo CONTINUE AND RECOMPILE [y/N]
+choice=`{read}+if (~ $choice [yY]* ) echo YOU ASKED FOR IT: RECOMPILING
+if not exit
+
+cd /
+. /sys/lib/rootstub
+
+echo BUILDING
+echo UPDATING COMPILERS
+cd /sys/src/cmd/cc
+mk install
+cd /sys/src/cmd/6c
+mk install
+
+echo UPDATING SYSTEM
+cd /sys/src
+mk install
+mk clean
+
+
+echo UPDATING MANUALS
+cd /sys/man
+mk
+
+
+echo UPDATING DOCUMENTS
+cd /sys/doc
+mk
+mk html
+
+echo UPDATING KERNEL BRAIN
+cd /sys/src/9/pc64
+mk install
+
+echo FLASHING NEW MEMORY BRAIN
+9fs 9fat
+rm /n/9fat/9bootfat
+cp /386/9bootfat /n/9fat/
+chmod +al /n/9fat/9bootfat
+cp /amd64/9pc64 /n/9fat
+
+cd $curdir
+
+echo 9front UPDATE IS COMPLETE
+echo FSHALT -R NOW OR FACE DOOM
--- /dev/null
+++ b/updatemusic
@@ -1,0 +1,6 @@
+#!/bin/rc
+rfork ne
+
+# This updates the playlist for zuke to play, adding all
+# music from /usr/$user/music/
+audio/mkplist /usr/$user/music/ > /usr/$user/music/music.plist
--- /dev/null
+++ b/w
@@ -1,0 +1,3 @@
+#!/bin/rc
+uptime
+who
--- /dev/null
+++ b/weather
@@ -1,0 +1,2 @@
+#!/bin/rc
+9weather -i -z 35022,US -k a29dc2d85251c76e67b5be32354be64f
--- /dev/null
+++ b/webserver
@@ -1,0 +1,4 @@
+#!/bin/rc
+
+aux/listen1 tcp!*!80 rc-httpd/rc-httpd
+
--- /dev/null
+++ b/wifis
@@ -1,0 +1,42 @@
+#!/bin/rc -e
+# wifis - initialize wifi and prompt for network
+# usage: wifis
+
+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 -b '#'l1 /net
+ aux/wpa -p2 -s $essid /net/ether1
+ ip/ipconfig -6
+ ip/ipconfig ra6 recvra 1 &
+ ip/ipconfig ether /net/ether1 &
+ wait
+ secstore=`{grep sys /net/ndb | awk -F'=' '{print $2}'}+ 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
+}
--- /dev/null
+++ b/wm
@@ -1,0 +1,18 @@
+#!/bin/rc
+rfork ne
+
+# Customized Bar - thanks to noam for the script idea.
+# sed command replaces the virtual desktop numbers with labels
+fn custombar {+ sed -u \
+ -e 's/^1/ one /' -e 's/^2/ two /' -e 's/^3/ three /' \
+ -e 's/^4/ four /' -e 's/^5/ five /' -e 's/^6/ six /' \
+ -e 's/^7/ seven /' -e 's/^8/ eight /' -e 's/^9/ nine /' \
+ -e 's/^0/ ten /' \
+ | bar -b -d 'H:mm a WW M/D/Y'
+}
+
+# Launches bar with riow and custom scripting piped to it.
+# -s makes windows sticky if you add the label of it.
+</dev/kbdtap riow -s 9weather >/dev/kbdtap |[3] custombar
+
--- /dev/null
+++ b/yt/a
@@ -1,0 +1,13 @@
+#!/bin/rc
+# yt/dl - download youtube videos
+# usage: yt/dl videoid
+# requires:
+# - nvi (https://git.sr.ht/~ft/nvi)
+
+if(! ~ $#* 1){+ echo 'usage: yt/dl videoid'
+ exit usage
+}
+
+# easiest way, low quality
+nvi -V 18 -v $1.mp4 $"1
--- /dev/null
+++ b/yt/dl
@@ -1,0 +1,13 @@
+#!/bin/rc
+# yt/dl - download youtube videos
+# usage: yt/dl videoid
+# requires:
+# - nvi (https://git.sr.ht/~ft/nvi)
+
+if(! ~ $#* 1){+ echo 'usage: yt/dl videoid'
+ exit usage
+}
+
+# easiest way, low quality
+nvi -V 18 -v $1.mp4 $"1
--- /dev/null
+++ b/yt/v
@@ -1,0 +1,15 @@
+#!/bin/rc
+# yt/v - play a youtube video
+# usage: yt/v videoid
+# requires:
+# - nvi (https://git.sr.ht/~ft/nvi)
+
+if(! ~ $#* 1){+ echo 'usage: yt/v videoid'
+ exit usage
+}
+
+# easiest way, low quality
+nvi -V 18 -v /tmp/vid.mp4 $"1 \
+ && treason /tmp/vid.mp4 \
+ && rm /tmp/vid.mp4
--
⑨