Update 2022-12-06 08:01 OpenBSD/amd64

This commit is contained in:
c0dev0id 2022-12-06 08:01:44 +01:00
parent fb05d04fee
commit df81168e5e
28 changed files with 701 additions and 4 deletions

60
.bin/apps/amused Executable file
View File

@ -0,0 +1,60 @@
#!/bin/sh
. $HOME/.bin/_config
showlist() {
printf '%s\n' \
"next
prev
play
stop
shuffle
sort
load tank
load local
---------
> $(amused status | head -1 | sed 's,/tank/pub/Audio_/,,g')
---------"
amused show | cut -d'/' -f5-
}
SEL="$( showlist | $DMENU_CMD -p Playlist -l 30)"
amused_shuffle() {(
twmnc -d 2000 -t "amused" -c "shuffle started in background";
amused show | sort -R | amused load;
twmnc -d 2000 -t "amused" -c "shuffle finished";
)&}
amused_sort() {(
twmnc -d 2000 -t "amused" -c "sorting started in background"
amused show | sort -u | amused load
twmnc -d 2000 -t "amused" -c "sorting finished"
)&}
amused_load_tank() {(
twmnc -d 2000 -t "amused" -c "loading started in background"
amused load < /home/sdk/.music.all.txt
twmnc -d 2000 -t "amused" -c "loading finished"
)&}
amused_load_local() {(
twmnc -d 2000 -t "amused" -c "loading started in background"
find ~/MusicSelection -type f | amused load
twmnc -d 2000 -t "amused" -c "loading finished"
)&}
amused_cmd() {
amused "${@}"
twmnc -d 5000 \
-t "amused $1" \
-c "$(amused status | head -1 | cut -d'/' -f5-)"
}
case "${SEL}" in
play) amused_cmd play; ;;
prev) amused_cmd pref; ;;
stop) amused_cmd stop; ;;
next) amused_cmd next; ;;
shuffle) amused_shuffle; ;;
sort) amused_sort; ;;
load*tank) amused_load_tank; ;;
load*local) amused_load_local; ;;
*) amused_cmd jump "${SEL}"; ;;
esac

20
.bin/apps/ccc-streams Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
# needs: jq, curl, ffplay, notify-send
# https://codevoid.de/1/git/dotfiles/file/.bin/_config.gph
. ~/.bin/_config
PLAYER="ffplay -loglevel error"
JSON="https://streaming.media.ccc.de/streams/v2.json"
QUALITY="hd-native"
FORMAT="webm"
SLUG=$(curl -s "$JSON" | jq -crM '.[].groups[].rooms[].slug' | $DMENU_CMD -p Stream )
if [ ! -z "$SLUG" ];
then
URL=$(curl -s "$JSON" | jq -Mcr ".[].groups[].rooms[] | select(.slug==\"$SLUG\") | .streams[] | select(.slug==\"$QUALITY\").urls.$FORMAT.url")
ERR="$($PLAYER "$URL" 2>&1 > /dev/null)"
[ ! -z "$ERR" ] && notify-send "$ERR"
fi

3
.bin/apps/fefe Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
. $HOME/.bin/_config
texec "sacc codevoid.de/1/fefe"

3
.bin/apps/hackernews Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
. $HOME/.bin/_config
texec "sacc codevoid.de/1/hn"

3
.bin/apps/irssi Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
. $HOME/.bin/_config
texec "tmux new-session -A -s irrsi irssi"

34
.bin/apps/settings Executable file
View File

@ -0,0 +1,34 @@
#!/bin/sh
. $HOME/.bin/_config
SEL=$(printf "BACKLIGHT\nAUDIODEVICE\nLIDACTION\nSCREEN\nCONFIGFILES" \
| $DMENU_CMD -p Mailbox)
case $SEL in
"BACKLIGHT")
S=$(printf "10\n20\n30\n40\n50\n60\n70\n80\n90\n100" | $DMENU_CMD -p Backlight)
doas wsconsctl display.brightness=$S
;;
"AUDIODEVICE")
D=$(printf "0\n1\n2\n3\n4\n5" | $DMENU_CMD -p AudioDevice)
sndioctl server.device=$D
;;
"LIDACTION")
A=$(printf "enable\ndisable" | $DMENU_CMD -p Lidaction)
case $A in
"enable") doas sysctl machdep.lidaction=1; ;;
"disable") doas sysctl machdep.lidaction=0; ;;
esac
;;
"CONFIGFILES")
C=$(printf "cwmrc\nvimrc\nkshrc\nvimb\nmuttrc\nspectrwm" | sort | $DMENU_CMD -p File)
case $C in
"cwmrc") texec "vim $HOME/.cwmrc"; ;;
"mailcap") texec "vim $HOME/.mutt/mailcap"; ;;
"muttrc") texec "vim $HOME/.mutt/rc-common $HOME/.mutt/rc-account-*"; ;;
"spectrwm") texec "vim $HOME/.config/spectrwm/spectrwm.conf"; ;;
"vimb") texec "vim $HOME/.config/vimb/config"; ;;
"vimrc") texec "vim $HOME/.vim/vimrc"; ;;
esac
;;
esac

3
.bin/bterm Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
. $HOME/.bin/_config
$BTERM $@

3
.bin/dexec Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
. $HOME/.bin/_config
$DMENURUN_CMD -p Exec

4
.bin/dexec_apps Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
. $HOME/.bin/_config
APP=$(ls -1 $HOME/.bin/apps/ | $DMENU_CMD -p App)
[ ! -z "$APP" ] && $HOME/.bin/apps/$APP

187
.bin/dexec_browser Executable file
View File

@ -0,0 +1,187 @@
#!/bin/sh
# dexec_browser
# A multi browser launcher
#
# 1. choose input source
# (filtered-, full history, clipboad, manual entry)
# 2. choose how to handle the input
# (can suggest a matching default)
# 3. choose which browser to use
# (can suggest a matching default)
HISTFILE="${HOME}/.browser_history"
test -f ${HOME}/.bin/_config \
&& . ${HOME}/.bin/_config \
|| DMENU_CMD=dmenu
test -f "${HISTFILE}" \
|| touch "${HISTFILE}"
PICKLIST="paste_from_clipboard
pick_from_history
-----------------
$(cat "${HISTFILE}" \
| cut -b 23- \
| sort -u \
| egrep -v ' |^[^a-zA-Z0-9]' \
| fgrep '.')
http://localhost"
# show filtered history file
# EXPECTS: $PICKLIST $HISTFILE $DMENU_CMD
# PROVIDES: $INPUT
read_input() {
local S=$(printf '%s\n' "${PICKLIST}" \
| ${DMENU_CMD} -p "Bookmarks")
case "${S}" in
paste_from_clipboard)
S=$(xclip -o \
| head -n 1) ;;
pick_from_history)
S=$(sort -r "${HISTFILE}" \
| ${DMENU_CMD} -p "History:" \
|cut -b23-) ;;
esac
[ -z "${S}" ] && exit 0
INPUT="${S}"
}
# Decide how to open the thing
# EXPECTS: $INPUT $DMENU_CMD
# PROVIDES: $URI
choose_wrapper() {
local SE="OPEN URL
Amazon
CPAN
Crates.io
DuckDuckGo Web Search
DuckDuckGo Image Search
Github
Marc Info MessageID
Marc Info OpenBSD Misc List
Marc Info OpenBSD Ports CVS
Marc Info OpenBSD Ports List
Marc Info OpenBSD Tech List
PDF Viewer
SearX Web Search
SearX Image Search
Wikipedia DE
Wikipedia EN
InternetMovieDataBase (IMDB)
OpenStreetMap (OSM)
Grep.app
Google Maps
Youtube"
local C="$(printf '%s' "${INPUT}" \
| head -n 1)"
case "${C}" in
*::*) DEFAULT="CPAN (default)"; ;;
http*) DEFAULT="OPEN (default)"; ;;
192.168.*) DEFAULT="OPEN (default)"; ;;
gopher*) DEFAULT="OPEN (default)"; ;;
www.*) DEFAULT="OPEN (default)"; ;;
\<*@*\>) DEFAULT="Marc Info Message ID (default)"; ;;
*.com|*.de|*.net|*.org) DEFAULT="OPEN (default)"; ;;
*.at|*.ch|*.social) DEFAULT="OPEN (default)"; ;;
*.io|*.sh|*.pw|*.party) DEFAULT="OPEN (default)"; ;;
*.coffee|*.me|*.cloud) DEFAULT="OPEN (default)"; ;;
*.[a-zA-Z]*/*) DEFAULT="OPEN (default)"; ;;
*) DEFAULT="DuckDuckGo Web Search (default)"; ;;
esac
local S="$(printf "%s\n%s" "${DEFAULT}" "${SE}" \
| ${DMENU_CMD} -p "Search Where?")"
case "${S}" in
OPEN*) URI="${C}"; ;;
Amazon*) URI="https://www.amazon.de/s?k=${C}"; ;;
CPAN*) URI="https://metacpan.org/search?q=${C}"; ;;
Crate*) URI="https://crates.io/search?q=${C}"; ;;
Grep*) URI="https://grep.app/search?q=${C}"; ;;
Github) URI="https://github.com/search?q=${C}"; ;;
D*Web*) URI="https://html.duckduckgo.com/html?q=${C}"; ;;
D*Ima*) URI="https://duckduckgo.com/?q=${C}&iax=images&ia=images"; ;;
S*Web*) URI="https://searx.bar/search?q=${C}&category_general=on"; ;;
S*Ima*) URI="https://searx.bar/search?q=${C}&category_images=on"; ;;
W*DE*) URI="https://de.m.wikipedia.org/wiki/Spezial:Suche/${C}"; ;;
W*EN*) URI="https://en.m.wikipedia.org/wiki/Spezial:Search/${C}"; ;;
*IMDB*) URI="https://www.imdb.com/find?q=${C}"; ;;
O*S*M*) URI="https://www.openstreetmap.org/search?query=${C}"; ;;
G*Maps) URI="https://www.google.com/maps/place/${C}"; ;;
You*be) URI="https://m.youtube.com/results?sp=mAEA&search_query=${C}" ;;
M*I*ID*) URI="https://marc.info/?i=$(printf '%s' "${C}" | tr -d '<>')"; ;;
M*I*P*List) URI="https://marc.info/?l=openbsd-ports&s=${C}&q=b"; ;;
M*I*T*List) URI="https://marc.info/?l=openbsd-tech&s=${C}&q=b"; ;;
M*I*M*List) URI="https://marc.info/?l=openbsd-misc&s=${C}&q=b"; ;;
M*I*P*CVS) URI="https://marc.info/?l=openbsd-ports-cvs&s=${C}&q=b"; ;;
*) exit 0 ;;
esac
}
# Which browser shall we use?
# EXPECTS: $URI $DMENU_CMD
# PROVIDES: $BROWSER
choose_browser() {
case "${URI}" in
gopher://*) DEFAULT="Lagrange (default)"; ;;
gemini://*) DEFAULT="Lagrange (default)"; ;;
*.pdf|*.cb|*.ps) DEFAULT="Zathura (default)"; ;;
192.168.*) DEFAULT="Firefox (default)"; ;;
*github.com*) DEFAULT="Firefox (default)"; ;;
*amazon.de*) DEFAULT="Firefox (default)"; ;;
*twitter.com*) DEFAULT="Firefox (default)"; ;;
*chaos.social*) DEFAULT="Firefox (default)"; ;;
*hetzner.cloud*) DEFAULT="Firefox (default)"; ;;
*hetzner.de*) DEFAULT="Firefox (default)"; ;;
*duckduckgo.com/*images*) DEFAULT="Firefox (default)"; ;;
*codevoid.de*) DEFAULT="Luakit (default)"; ;;
*google.*) DEFAULT="Chrome (default)"; ;;
*youtube.com*) DEFAULT="Chrome (default)"; ;;
*youtu.be*) DEFAULT="Chrome (default)"; ;;
*bsd.network*) DEFAULT="Chrome (default)"; ;;
*itch.io*) DEFAULT="Chrome (default)"; ;;
*chat.uugrn.org*) DEFAULT="Chrome (default)"; ;;
*[./]amazon.*) DEFAULT="Firefox (default)"; ;;
*comdirect.de*) DEFAULT="Firefox (default)"; ;;
*motorradfreunde-rheinneckar.de*) DEFAULT="Firefox (default)"; ;;
*polo-motorrad.com*) DEFAULT="Firefox (default)"; ;;
*peek-cloppenburg.de*) DEFAULT="Firefox (default)"; ;;
*asos.com*) DEFAULT="Firefox (default)"; ;;
*zalando.de*) DEFAULT="Firefox (default)"; ;;
*) DEFAULT="Luakit (default)"; ;;
esac
local S="${DEFAULT}\nLuakit\nFirefox\nChrome\nQutebrowser\nNetsurf\nTor-Browser"
case $(echo "${S}" | ${DMENU_CMD} -p "Browser") in
Netsurf*) BROWSER=netsurf-gtk3 ;;
Vimb*) BROWSER=vimb ;;
Quteb*r*) BROWSER=qutebrowser ;;
Surf*) BROWSER=surf ;;
Otter*r*) BROWSER=otter-browser ;;
Luakit*) BROWSER="luakit -Un" ;;
Chrome*) BROWSER=chrome ;;
Firefox*) BROWSER=firefox ;;
Tor-B*r*) BROWSER=tor-browser ;;
Zathura*) BROWSER=zathura ;;
Lagrange*) BROWSER=lagrange ;;
*) exit 0;;
esac
}
save_history() {
printf '%s %s\n' "$(date +"%Y-%m-%d %H:%M:%S |")" "${INPUT}" \
>> "${HISTFILE}"
}
# main program starts here.
read_input
choose_wrapper
choose_browser
save_history
exec $BROWSER "$(printf '%s' "${URI}" | sed 's/ /%20/g')"

4
.bin/dexec_ding Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
. $HOME/.bin/_config
D="$(echo "$(xclip -o)" | $DMENU_CMD -p Translate)"
[ ! -z "$D" ] && ding "$D"

10
.bin/dexec_findwin Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
. $HOME/.bin/_config
WID=$(wmctrl -l | col -b \
| grep -v "^$" \
| awk '{printf("%s",$1);$1="";$2="";$3=""; print $0}' \
| $DMENU_CMD -p "Windows" \
| awk '{ print $1 }' \
)
[ -z "$WID" ] || wmctrl -i -a $WID

10
.bin/dexec_mail Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
ALIASES=$(ksh -ic alias | grep ^mutt- | cut -d= -f1)
. $HOME/.bin/_config
MAILBOX="imaps://mail.codevoid.de"
SEL=$(printf "$ALIASES" | $DMENU_CMD -p Mutt)
[ -z "$SEL" ] || texec $SEL

12
.bin/dexec_man Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
. $HOME/.bin/_config
MAN="$( for i in $(jot 9 1); do
man -s $i -k . | awk -v i=$i -F"(" '{ gsub(", ","\n"i"-",$1); print i"-"$1}'
done | $DMENU_CMD -p "Manpage" )"
if [ ! -z "$MAN" ]; then
M="$(printf '%s' "$MAN" | cut -d"-" -f2)"
S="$(printf '%s' "$MAN" | cut -d"-" -f1)"
bterm -e man -s "$S" "$M"
fi

29
.bin/dexec_pass Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/env bash
. $HOME/.bin/_config
shopt -s nullglob globstar
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
password=$(printf '%s\n' "${password_files[@]}" | $DMENU_CMD -p Password)
[[ -n $password ]] || exit
# read password file
password_out=$(pass "$password" 2> /dev/null)
# copy password line
printf "%s" "$password_out" | head -1 | xclip -r
# extract additional information
password_info=$(printf "%s" "$password_out" | grep -Ei 'login|user')
url_info=$(printf "%s" "$password_out" | grep -Ei '^url' | awk -F"[ :]*" '{ $1=""; print $0 }' )
# show desktop notification
if [[ -n $password_info ]]; then
notify pass "$(printf '%s' "$password_info")"
else
notify pass "No username provided."
fi

49
.bin/dexec_pim Executable file
View File

@ -0,0 +1,49 @@
#!/bin/sh
. $HOME/.bin/_config
SEL=$(printf "Notes\nDocuments\nContacts\nSlides" | $DMENU_CMD -p "Information System")
case $SEL in
Notes)
N=$(printf "Todo\nNotes\nEvents" | $DMENU_CMD -p Notes)
case $N in
Todo) hterm -e "vim scp://sdk@shell.codevoid.de/work/notes/todos.txt"; ;;
Notes) hterm -e "vim scp://sdk@shell.codevoid.de/work/notes/notes.txt" ;;
Events) hterm -e "vim scp://sdk@shell.codevoid.de/work/notes/events.txt" ;;
esac
;;
Documents)
DOC=$(ls -1pr $PIMDIR/documents/ | grep -v '/$' | sort -hr | $DMENU_CMD -p Documents -l 25)
if [ ! -z "$DOC" ]; then
ACT=$(printf "View\nEdit\nEmail" | $DMENU_CMD -p Action)
case $ACT in
View) mupdf "$PIMDIR/documents/$DOC" ;;
Edit) pdfarranger "$PIMDIR/documents/$DOC" ;;
Email) texec "mutt -a \"$PIMDIR/documents/$DOC\"" ;;
esac
fi
;;
Contacts)
C=$(contactsearch | $DMENU_CMD -p Contacts -l 25)
if [ ! -z "$C" ]; then
_file=$(printf "$C" | cut -d" " -f1)
if [ -f "$PIMDIR/contacts/$_file" ]; then
texec "vim \"$PIMDIR/contacts/$_file\""
else
printf "Name:\nAddress:\nHome:\nWork:\nMail:\nWeb:\nBirthday:\n" >> "$PIMDIR/contacts/$_file"
texec "vim \"$PIMDIR/contacts/$_file\""
fi
fi
;;
Slides)
P=$(ls -1 "$PIMDIR/slides/" | sort -hr | $DMENU_CMD -p Slides -l 25)
if [ ! -z "$P" ]; then
ACT=$(printf "Open\nEdit" | $DMENU_CMD -p Action)
case $ACT in
Open) sent "$PIMDIR/slides/$P" ;;
Edit) texec "vim \"$PIMDIR/slides/$P\"" ;;
esac
fi
;;
esac

25
.bin/dexec_port Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
# provides DMENU_CMD (dmenu + color parameter)
. $HOME/.bin/_config
cd /usr/ports
DIR=$( ls -1d */* mystuff/*/* | egrep -v '^pobj|^distfiles|^log|^plist|^packages|CVS|Makefile|\.tgz$' | dmenu -p "DIR:" $DMENUOPTS -l 20);
if [ ! -z "$DIR" ]; then
cd /usr/ports/$DIR
DIR2=$(printf "%s\n\n%s\n%s\n%s\n\nCVS %s\n" \
"/usr/ports/$DIR" \
"Package: $(make show=FULLPKGNAME)" \
"Maintainer: $(make show=MAINTAINER)" \
"Homepage: $(make show=HOMEPAGE)" \
"$(cvs log -Nl -rHEAD 2>&1 | awk '{ if ($0 ~ /^===/) p++; if (p == 1) print $0; if ($0 ~ /^---/) p++; }')" \
| dmenu -p "INFO:" $DMENUOPTS -l 20)
if [ ! -z "$DIR2" ]; then
case "$DIR2" in
Homepage*) firefox "$(make show=HOMEPAGE)" & ;;
Package*) make show=FULLPKGNAME | xclip -r ;;
Maintainer*) make show=MAINTAINER | xclip -r ;;
*) cd "$DIR2"; port mark; dterm & ;;
esac
fi
fi

13
.bin/dexec_ssh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
. $HOME/.bin/_config
CONF=$(cat $HOME/.ssh/config| grep -Ei "^host" | grep -v '*' | cut -d" " -f2)
HOSTS=$(cat $HOME/.ssh/known_hosts | cut -d" " -f1 | tr ',' '\n')
HOST=$(printf '%s\n%s' "$CONF" "$HOSTS" | grep -v '=' | sort -ru | $DMENU_CMD -p SSH)
if [ ! -z "$HOST" ]; then
case "$HOST" in
*-sftp) texec "sftp $HOST"; ;;
*) texec "ssh $HOST"; ;;
esac
fi

4
.bin/dexec_term Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
. $HOME/.bin/_config
S=$(dmenu_path | $DMENU_CMD -p Exec)
[ ! -z $S ] && sterm -e "$S"

55
.bin/dopaste Executable file
View File

@ -0,0 +1,55 @@
#!/bin/sh
. $HOME/.bin/_config
PSSH="${USER}@${DOMAIN}"
LOC="p"
f="$1"
if [ "$1" = "-h" ]; then
printf "Usage:\n"
printf " paste < text.txt - read from stdin, generate filename\n"
printf " paste new.txt < file.txt - read from stdin with filename\n"
printf " paste file.txt - upload file as is\n"
return 0
fi
if [ -z "$1" ]; then
f="$(date +"%Y-%m-%d_%M-%S")-$(pwgen -1 4 -A -0).txt"
ssh ${PSSH} "printf \"%s\" \"$(cat)\" > ${RPATH}/${LOC}/$f"
elif [ -f "$f" ]; then
scp "$f" ${PSSH}:"${RPATH}/${LOC}/${f##*/}"
else
ssh ${PSSH} "printf \"%s\n\" \"$(cat)\" > ${RPATH}/${LOC}/${f##*/}"
fi
SELECTOR="9"
# if data comes from stdin
if [ ! -t 0 ]; then
# it's always 0
SELECTOR="0"
else
# if a parmeter is given and it's a file
if [ -f "$f" ]; then
# determine type and set selector
case "$(file --mime-type -b "$f")" in
image/*) SELECTOR="I";;
text/*) SELECTOR="0";;
message/*) SELECTOR="0";;
*/x-shellscript) SELECTOR="0";;
*/pgp-keys) SELECTOR="0";;
esac
else
# parameter given, but not a file, must be cat then...
SELECTOR=0
fi
fi
printf "https://${DOMAIN}/${SELECTOR}/${LOC}/${f##*/}\n"
printf "https://${DOMAIN}/${SELECTOR}/${LOC}/${f##*/}" | xclip
# write paste history (for convenience and rmpaste)
printf "$(date +"%Y-%m-%d %M:%S")|$f\n" \
| ssh -q $PSSH "cat - >> $RPATH/${LOC}/.pastehistory"
[ -z $DISPLAY ] || notify-send "$(xclip -o)"

3
.bin/hterm Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh +x
. $HOME/.bin/_config
$HTERM -T "term" $@

6
.bin/lspaste Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
. $HOME/.bin/_config
ssh $USER@$DOMAIN "cd $RPATH/p && ls -tr1 | xargs file --mime-type" \
| awk -F'[ :]*' -v url="https://$DOMAIN" \
'{if ($2 ~ /^image/) { print url"/I/p/"$1 } else { print url"/0/p/"$1 }}'

97
.bin/nnn.sh Executable file
View File

@ -0,0 +1,97 @@
#!/bin/ksh
if [ -z "$1" ];
then
print "Parameter missing."
exit 2
fi
###################################################
# URLS
###################################################
if print "$1" | egrep -qi '^shell:|^ushell:|^cvs:';
then
_server=${1%%:*}
_dir=${1#*:}
ssh -tt $_server "vim $_dir"
exit 0
fi
if print "$1" | egrep -qi '^http[s]{0,1}://';
then
case "$1" in
*.mkv) mpv "$1"; ;;
*.mp4) mpv "$1"; ;;
*.webm) mpv "$1"; ;;
*) sacc "$1"; ;;
esac
${BROWSER:=luakit} "$1"
exit 0
fi
if print "$1" | egrep -qi '^gopher://';
then
case "$1" in
*.mkv) mpv "$1"; ;;
*.mp4) mpv "$1"; ;;
*.webm) mpv "$1"; ;;
*) sacc "$1"; ;;
esac
exit 0
fi
###################################################
# REAL FILES
###################################################
if [ ! -f "$1" ];
then
print "Parameter is not a file."
exit 1
fi
###################################################
# EXTENSIONS
###################################################
EXT="$(print "${1##*.}" | tr '[:upper:]' '[:lower:]')"
case "$EXT" in
docx) libreoffice "$1"; ;;
xlsx) libreoffice "$1"; ;;
txt) vim "$1"; ;;
m2ts) mpv "$1"; ;;
sid) sidplay "$1"; ;;
out) kdump -RTf "$1" | less; ;;
*) unset EXT; ;;
esac
if [ ! -z "$EXT" ];
then
exit 0;
fi
###################################################
# MIME TYPES
###################################################
case "$(file -ib "$1")" in
# full qualified
application/ogg) ogg123 "$1"; ;;
application/pdf) mupdf-gl -XJA0 "$1"; ;;
application/postscript) mupdf-gl -XJA0 "$1"; ;;
application/vnd.oasis.opendocument.*) libreoffice "$1"; ;;
audio/mpeg) mpg123 "$1"; ;;
audio/midi) timidity "$1"; ;;
# with wildcards
audio/*) mpv "$1"; ;;
video/*) mpv "$1"; ;;
image/webp) mpv "$1"; ;;
image/*) sxiv -N floating -g 1280x720+300+180 -ab "$1"; ;;
# can't handle
application/octet-stream) print "Sorry, can't handle: $1"; ;;
# vim can handle a lot!
*) vim "$1"; ;;
esac

27
.bin/rmpaste Executable file
View File

@ -0,0 +1,27 @@
#!/bin/sh
. $HOME/.bin/_config
PSSH="$USER@$DOMAIN"
LOC="p"
if [ "$1" = "-h" ]; then
printf "Usage:\n"
printf " rmpaste - deletes last paste based on ~/.pastehistory\n"
printf " rmpaste <filename> - deletes paste with <filename>\n"
return 0
fi
if [ -z $1 ]; then
if ssh -q $PSSH "! [ -s $RPATH/$LOC/.pastehistory ];"; then
printf "The history file is empty.\n"
return 0
fi
f=$(ssh -q $PSSH "tail -1 $RPATH/$LOC/.pastehistory | cut -d'|' -f2")
read d?"Delete last paste? ($f) [y/N] : "
if [ "$d" = "y" ]; then
ssh $PSSH "rm $RPATH/$LOC/$f"
ssh -q $PSSH "sed -i '$ d' $RPATH/$LOC/.pastehistory"
fi
else
ssh $PSSH "rm $RPATH/$LOC/$1"
fi

3
.bin/sterm Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
. $HOME/.bin/_config
$STERM $@

31
.bin/v Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
set -xe
[ -f /usr/bin/doas ] || alias doas=sudo
_input="$(echo "$1" | sed 's/:$//g')"
_file="$(echo "$_input" | sed 's/:[0-9:]*$//g')"
_fnr="$(echo "$_input" | awk -F: '{ print NF }')"
[ ! -w $_file ] \
&& _cmd="doas vim" \
|| _cmd="vim"
if [ $_fnr -eq 3 ]
then
_row="$(echo "$_input" | awk -F: '{ print $2 }')"
_col="$(echo "$_input" | awk -F: '{ print $3 }')"
$_cmd -c ":call cursor($_row,$_col)" "$_file"
elif [ $_fnr -eq 2 ]
then
_row="$(echo "$_input" | awk -F: '{ print $2 }')"
$_cmd +$_row "$_file"
else
echo "No cursor position found..."
$_cmd "$_file"
fi
exit 0

3
.kshrc
View File

@ -506,9 +506,8 @@ dotfiles_autoupdate() {
dotfiles_init() { dotfiles_init() {
git --no-replace-objects clone --bare --depth 1 \ git --no-replace-objects clone --bare --depth 1 \
sdk@home.codevoid.de:.dotfiles.git $HOME/.cfg; git@github.com:c0dev0id/dotfiles.git $HOME/.cfg;
config config --local status.showUntrackedFiles no; config config --local status.showUntrackedFiles no;
mkdir -p $HOME/.vim/undo $HOME/.vim/swapfiles $HOME/.vim/backup;
config checkout -f config checkout -f
} }

View File

@ -1,5 +1,6 @@
let g:netrw_dirhistmax =10 let g:netrw_dirhistmax =10
let g:netrw_dirhistcnt =3 let g:netrw_dirhistcnt =4
let g:netrw_dirhist_4='/home/sdk/.bin'
let g:netrw_dirhist_3='/home/sdk' let g:netrw_dirhist_3='/home/sdk'
let g:netrw_dirhist_2='/home/sdk/.vim' let g:netrw_dirhist_2='/home/sdk/.vim'
let g:netrw_dirhist_1='sftp://sdk@gopher.codevoid.de/../www/htdocs/gopher/' let g:netrw_dirhist_1='sftp://sdk@gopher.codevoid.de/../www/htdocs/gopher/'
@ -9,4 +10,3 @@ let g:netrw_dirhist_8='/home/sdk/code/bar'
let g:netrw_dirhist_7='/home/sdk/code/drist' let g:netrw_dirhist_7='/home/sdk/code/drist'
let g:netrw_dirhist_6='/home/sdk/code' let g:netrw_dirhist_6='/home/sdk/code'
let g:netrw_dirhist_5='/home/sdk/.FontForge' let g:netrw_dirhist_5='/home/sdk/.FontForge'
let g:netrw_dirhist_4='/home/sdk/.audacity-data'