deleted clutter

This commit is contained in:
tavo-wasd 2024-07-07 00:08:48 -06:00
parent 63ea163fff
commit 93df183c90
18 changed files with 0 additions and 660 deletions

View file

@ -1,88 +0,0 @@
#!/bin/sh
# Based from Bugswriter's (https://github.com/Bugswriter)
# music-fairy (https://github.com/Bugswriter/music_fairy)
#
# Generate a string of text based on 4s of listening through default input.
# The first word of the string will dictate which function to execute.
# Configuration
# Speech recognition engine
VOSK="$HOME/.local/pipx/venvs/vosk/bin/vosk-transcriber"
VOSK_MODEL="$HOME/.local/share/vosk-models/vosk-model-small-en-us-0.15/"
TIME=4 # Time in seconds for ffmpeg to record $SPEECH
# Cache
CACHE="$HOME/.local/cache/assistant"
# Multimedia
INVIDIOUS_INSTANCE="https://vid.puffyan.us"
# Read SPEECH
mkdir -p $CACHE
notify-send -t 4000 " Listening..."
ffmpeg -y \
-f alsa \
-i default \
-acodec pcm_s16le \
-ac 1 -ar 44100 \
-t $TIME \
-f wav \
$CACHE/input.wav
# Analyze with vosk-transcriber
$VOSK -m $VOSK_MODEL -i $CACHE/input.wav -o $CACHE/output.txt
read SPEECH < $CACHE/output.txt # Save $SPEECH variable
rm -rf $CACHE/input.wav # Remove
rm -rf $CACHE/output.txt # cached files
play() { # Play a song
killall mpv
notify-send "󰝚 Playing" "${SPEECH##*play}"
QUERY="song audio ${SPEECH##*play}"
mpv "$( \
yt-dlp ytsearch:"$QUERY" -f bestaudio --get-url |
grep -v manifest | tail -n 1 \
)"
}
watch() { # Watch a video
killall mpv
notify-send " Loading" "${SPEECH##*watch}"
QUERY="$(echo ${SPEECH##*watch} | tr ' ' '+')"
mpv "https://youtube.com/$( \
curl -s "$INVIDIOUS_INSTANCE/search?q=$QUERY" |
grep -Eo "watch\?v=.{11}" | head -n 1 \
)"
}
# Main Menu
CMD=$(echo "$SPEECH" | cut -d ' ' -f 1)
case "$CMD" in
"play") play ;;
"watch") watch ;;
"stop") killall mpv ;;
*) notify-send "Assistant:" "I couldn't understand!" ;;
esac
# Alternative to watch function,
# without invidious instance (slower).
#
# watch() { # Watch a video
# killall mpv
# notify-send " Loading" "${SPEECH##*watch}"
# QUERY="${SPEECH##*watch}"
# mpv "https://youtube.com/watch\?v=$( \
# yt-dlp ytsearch:"$QUERY" --get-id
# )"
# }
# Alternative to play function,
# with INVIDIOUS instance (slower).
#
# play() { # Play a song
# killall mpv
# notify-send "󰝚 Playing" "${SPEECH##*play}"
# QUERY="song audio ${SPEECH##*play}"
# mpv "https://youtube.com/$( \
# curl -s "$INVIDIOUS_INSTANCE/search?q=$QUERY" |
# grep -Eo "watch\?v=.{11}" | head -n 1 \
# )"
# }

View file

@ -1,5 +0,0 @@
#!/bin/sh
HCOL="\x1b[44m"
TODAY="$(date '+%d' | sed 's/^0//')"
/bin/cal "$@" | sed "s, $TODAY ,$HCOL $TODAY\x1b[0m ,"

View file

@ -1,61 +0,0 @@
#!/bin/sh
# Automate temporary shell envs
OPT="$1"
ENVDIR="/tmp/env"
ENVSHELL="/bin/bash"
print_title() {
printf "\033[2m%s\033[0m\n" "$1"
}
print_dialogue() {
printf "\033[2m%s:\033[0m " "$1"
}
print_warning() {
printf "\033[31mWarning:\033[0m \033[2m%s\033[0m\n" "$1"
}
help() {
printf "\033[2mUsage:\033[0m envm [list|create|login|delete]\n"
}
list() {
print_title "Current users:"
sed '/^env-.*::\/tmp\/env\/.*:\/bin\/bash$/!d;s/^env-//g;s/:.*::/ -> /g;s/:/ -> /g' /etc/passwd
}
create() {
print_warning 'super user privileges are needed for user and home creation'
print_dialogue 'Create user' && read -r ENVUSER
ENVNAME="env-$ENVUSER"
sudo mkdir -p "$ENVDIR"
sudo useradd -m -d $ENVDIR/$ENVUSER -s $ENVSHELL $ENVNAME
}
login() {
list && echo
print_warning 'super user privileges are needed for login'
print_dialogue 'Login as' && read -r ENVUSER
[ -z "$ENVUSER" ] && print_warning 'Empty user' && return 0
ENVNAME="env-$ENVUSER"
sudo su - "$ENVNAME"
}
delete() {
list && echo
print_warning 'super user privileges are needed for user and home deletion'
print_dialogue 'Delete user' && read -r ENVUSER
[ -z "$ENVUSER" ] && print_warning 'Empty user' && return 0
ENVNAME="env-$ENVUSER"
sudo rm -rfv $ENVDIR/$ENVUSER
sudo userdel $ENVNAME
}
[ "$OPT" = "" ] && help && list
[ "$OPT" = "help" ] && help
[ "$OPT" = "list" ] && list
[ "$OPT" = "create" ] && create
[ "$OPT" = "login" ] && login
[ "$OPT" = "delete" ] && delete

View file

@ -1,25 +0,0 @@
#!/bin/sh
PASSWORD_STORE_DIR="$HOME/.local/share/password-store"
FIRMADOR="$HOME/.local/share/firmador/firmador.jar"
DOCUMENTOS="$@"
firmar() {
DOC="$1"
NOM="${DOC%.*}"
EXT="${DOC##*.}"
PIN="$(pass personal/firma-digital | head -n 1)"
[ -z "$PIN" ] && exit 1
echo "$PIN" | java -jar "$FIRMADOR" \
-dargs "$DOC" "$NOM-firmado.$EXT"
PIN=""
}
for DOC in $DOCUMENTOS ; do
firmar "$DOC"
done
PIN=""
rm -rf "$HOME/.pdfbox.cache" "$HOME/.ase"

View file

@ -1,6 +0,0 @@
#!/bin/sh
FIRMADOR="$HOME/.local/share/firmador/firmador.jar"
java -jar "$FIRMADOR"
rm -rf "$HOME/.pdfbox.cache" "$HOME/.ase"

View file

@ -1,12 +0,0 @@
#!/bin/sh
# Get current ISO for
# various linux distros
case $1 in
debian) wget -c "https://cdimage.debian.org/cdimage/weekly-builds/amd64/iso-cd/debian-testing-amd64-netinst.iso" ;;
ubuntu) links "https://ubuntu.com/download/desktop/" ;;
arch) links "https://geo.mirror.pkgbuild.com/iso/" ;;
mint) links "https://mirrors.edge.kernel.org/linuxmint/stable/" ;;
void) links "https://repo-default.voidlinux.org/live/current/" ;;
*) echo "Usage: wget-iso <arch/mint/void...>" ;;
esac

View file

@ -1,13 +0,0 @@
#!/bin/sh
# Get branch info
echo "Branch name: " && read -r branch
[ -z "$branch" ] && echo "No branch name specified" && exit
echo "Branch origin (blank for 'origin'): " && read -r origin
# Create branch and switch to it
git checkout -b "$branch"
# Push changes from origin
[ -z "$origin" ] && origin="origin"
git push --set-upstream "$origin" "$branch"

View file

@ -1,20 +0,0 @@
#!/bin/sh
HOST="$1"
print_yes() {
#printf '\033[2m%s:\033[0m \033[1m\033[32mYES\033[0m\n' "$1"
printf '%s: YES\n' "$1"
}
print_no() {
#printf '\033[2m%s:\033[0m \033[1m\033[31mNO\033[0m\n' "$1"
printf '%s: NO\n' "$1"
}
if ! ping -c 1 "$HOST" > /dev/null 2>&1; then
print_no DNS
print_no WEB
else
print_yes DNS
curl --silent --fail "$HOST" > /dev/null 2>&1 &&
print_yes WEB || print_no WEB
fi

View file

@ -1,16 +0,0 @@
#!/bin/sh
# Get URL from clipboard
# and save as a bookmark
bookmark="$(xsel -ob)"
if grep -q "$bookmark" "$HOME/Documents/bookmarks" ; then
notify-send "󰃀 Bookmarks" "Already bookmarked"
exit
else
name="$(menu "Bookmark name:" empty)"
[ -z "$name" ] && exit
entry="$name-$bookmark"
echo "$entry" >> "$HOME/Documents/bookmarks"
notify-send "󰃀 Bookmarks" "Added '$entry'"
fi

View file

@ -1,128 +0,0 @@
#!/bin/sh
TASKS="$@"
PACMAN_UPDATE='yay -Sy && yay -Sy archlinux-keyring --needed --noconfirm'
PACMAN_UPGRADE='yay -Syu --noconfirm'
FLATPAK_UPDATE='/usr/bin/flatpak update -y --noninteractive'
DISTROBOX_UPDATE='/usr/bin/distrobox-upgrade -a'
PIP_UPDATE='/usr/bin/pipx upgrade-all'
PASSMGR_UPDATE='/usr/bin/pass git pull'
success() {
PROMPT="$1"
notify-send "󰇚 $PROMPT"
printf "\033[32m󰇚 %s\033[0m\n" "$PROMPT"
}
warn() {
PROMPT="$1"
printf "\033[33mWarning: %s\033[0m\n" "$PROMPT"
}
error() {
PROMPT="$1"
notify-send "Error: $PROMPT"
printf "\033[31mError: %s\033[0m\n" "$PROMPT"
}
pacman_update() {
if [ -d "/var/lib/pacman" ] ; then
$PACMAN_UPDATE && success "Updated pacman package index" && return 0
error "Could not update pacman index"
return 0
fi
warn "pacman not installed"
}
apt_update() {
[ -z "$sudopass" ] && sudopass="$(< /dev/null | menu "sudo:" pass)"
if [ -d "/var/lib/dpkg" ] && [ -e "/usr/bin/apt-get" ] ; then
printf '%s' "$sudopass" | sudo -S apt update && status="success"
[ "$status" != "success" ] && error "Could not update apt index" && return 1
upgradable="$(apt list --upgradable)"
[ "$upgradable" != "Listing..." ] && success "Updates available"
success "Updated apt package index" && return 0
return 0
fi
warn "apt not installed"
}
pacman_upgrade() {
pacman_update
if [ -d "/var/lib/pacman" ] ; then
$PACMAN_UPGRADE && success "Updated pacman packages" && return 0
error "Could not update pacman packages"
fi
}
apt_upgrade() {
[ -z "$sudopass" ] && sudopass="$(< /dev/null | menu "sudo:" pass)"
apt_update
if [ -d "/var/lib/dpkg" ] && [ -e "/usr/bin/apt-get" ] ; then
mkdir -p /tmp/apt-updater
dpkg-query -l --no-pager | gzip > /tmp/apt-updater/previous
printf '%s' "$sudopass" | sudo apt upgrade -y || status="$(echo 'error')"
[ "$status" = "error" ] && error "Could not update apt packages"
dpkg-query -l --no-pager | gzip > /tmp/apt-updater/current
if [ -z "$(diff /tmp/apt-updater/current /tmp/apt-updater/previous)" ] ; then
return 0
else
success "Updated apt packages"
return 0
fi
rm -rf /tmp/apt-updater
error "Could not update apt packages"
fi
}
flatpak_update() {
if [ -e "/usr/bin/flatpak" ] ; then
$FLATPAK_UPDATE
success "Updated flatpak packages"
else
warn "flatpak not installed"
fi
}
distrobox_update() {
if [ -e "/usr/bin/distrobox" ] ; then
$DISTROBOX_UPDATE
success "Updated distrobox containers"
else
warn "distrobox not installed"
fi
}
pip_update() {
if [ -e "/usr/bin/pipx" ] ; then
status="$($PIP_UPDATE)"
[ "$status" = "Versions did not change after running 'pipx upgrade' for each package 😴" ] && return 0
success "Updated pipx packages"
else
warn "pipx not installed"
fi
}
configs() {
for homecfg in /home/*/.config ; do
status="$(/usr/bin/git -C $homecfg pull || echo 'error')"
[ "$status" = "error" ] && error "Updating configs failed" && return 1
if [ "$status" != "Already up to date." ] ; then
success "Updated configs"
fi
done
}
passmgr() {
if [ -e "/usr/bin/pass" ] ; then
status="$($PASSMGR_UPDATE || echo 'error')"
[ "$status" = "error" ] && error "Updating passwords failed" && return 1
if [ "$status" != "Already up to date." ] ; then success "Updated passwords" ; fi
else
warn "pass not installed"
fi
}
for TASK in $TASKS ; do $TASK ; done
sudopass=""

View file

@ -1,5 +0,0 @@
#!/bin/sh
# Play from clipboard on mpv
notify-send "mpv" "Attempting to play from URL..."
mpv "$(xsel -ob)" || notify-send "mpv" "Error: Couldn't open URL"

View file

@ -1,7 +0,0 @@
#!/bin/sh
WEEK=$(date '+%U')
[ -e "/home/$USER/Documents/personal/sched-$WEEK" ] && sched.py print ~/Documents/personal/sched-$WEEK && exit
echo "No sched-$WEEK found in ~/Documents/personal/"

View file

@ -1,195 +0,0 @@
#!/usr/bin/env python
help="Usage: sched.py [OPTION] [FILE]\nOptions: new, print, edit."
import sys # arguments (if given file, just output it with formatting)
import os # clear console for easier readability
# schedule layout & formatting
weekdays = [
"sun",
"mon",
"tue",
"wed",
"thu",
"fri",
"sat",
]
hours = [
"05:00",
"06:00",
"07:00",
"08:00",
"09:00",
"10:00",
"11:00",
"12:00",
"13:00",
"14:00",
"15:00",
"16:00",
"17:00",
"18:00",
"19:00",
"20:00",
]
colors = [
'\033[0m', # 0 - normal
'\033[90m', # 1 - grey
'\033[91m', # 2 - red
'\033[92m', # 3 - green
'\033[93m', # 4 - yellow
'\033[94m', # 5 - purple
'\033[95m', # 6 - magenta
'\033[96m', # 7 - cyan
]
styles = [
'\033[0m', # 0 - normal
'\033[1m', # 1 - bold
'\033[4m', # 2 - underline
]
header_align = "center" # center, left, right
entry_align = "left" # center, left, right
cell_width = 13
header_color = 1
header_style = 0
# generate from previous values (utf8 encoded)
def gen_layout():
# create matrix to fit layout
placeholder = formatting("~", 1, 0, "center")
w, h = len(weekdays)+1, len(hours)+1
schedule = [[placeholder.encode("utf8") for x in range(w)] for y in range(h)]
# set days & hours in var schedule
for i in range(1, len(weekdays)+1):
day=formatting(weekdays[i-1], header_color, header_style, header_align)
schedule[0][i]=day.encode("utf8")
for i in range(len(hours)+1):
hour=colors[1]+"|"+formatting(hours[i-1], header_color, header_style, header_align)
schedule[i][0]=hour.encode("utf8")
index=colors[1]+cell_width*" "+" |"+colors[0]
schedule[0][0] = index.encode("utf8")
return(schedule)
# formatting
def formatting(entry, color, style, align):
if align == "left":
spaces = cell_width-len(entry)-1
entry = styles[style]+colors[color]+" "+entry+spaces*" "
if align == "center":
entry = entry.center(cell_width)
entry = styles[style]+colors[color]+entry
if align == "right":
spaces = cell_width-len(entry)-1
entry = styles[style]+colors[color]+spaces*" "+entry+" "
return(entry+styles[0]+colors[1]+"|"+colors[0])
# print schedule (decode)
def print_sched(schedule):
os.system('cls' if os.name == 'nt' else 'clear')
decoded_sched = []
for i in range(len(schedule)):
decoded_line = []
for j in range(len(schedule[i])):
decoded_line.append(schedule[i][j].decode("utf8"))
decoded_sched.append(decoded_line)
for row in decoded_sched:
print(''.join(map(str,row)))
# read saved .csv schedule (utf8 encoded)
def read_sched(file):
file = open(file, "rb")
schedule = []
for line in file:
i = []
entries = (line.replace(("\n").encode("utf8"), ("").encode("utf8"))).split((",").encode("utf8"))
for j in entries:
i.append(bytes(j))
schedule.append(i)
file.close()
return(schedule)
# save function (utf8 encoded)
def save(schedule, file):
with open(file, "wb") as f:
for row in schedule:
for entry in row:
f.write(entry + (",").encode("utf"))
f.write(("\n").encode("utf8"))
# add/edit entry in schedule
def edit(schedule):
if len(weekdays)+1 != len(schedule[0]) or len(hours)+1 != len(schedule):
print("Imported and configured layouts don't match! Can't edit, only print.")
return 0
day = menu(weekdays, schedule, 0)
hour = menu(hours, schedule, 0)
print_sched(schedule)
print(styles[1]+"\nType what the activity should be:"+styles[0])
entry = input("-> ")
if len(entry) > cell_width-2:
print("Entry is too long for cell_width!")
return 0
color = menu(colors, schedule, 1)
style = menu(styles, schedule, 1)
entry = formatting(entry, color, style, entry_align)
schedule[hour+1][day+1] = entry.encode("utf8")
# menu function for opt-lists
def menu(array, schedule, nopt):
while True:
print_sched(schedule)
print(styles[1]+"\nChoose an option:"+styles[0])
if nopt == 1:
for i in range(len(array)):
print(array[i]+str(i)+array[0])
elif nopt == 0:
for i in range(len(array)):
print(styles[1]+str(i)+styles[0]+" - "+array[i])
try:
opt = int(input("-> "))
if 0 <= opt <= len(array):
return(opt)
else:
print("\nOut of range!")
input("Try again...")
except:
print("\nInvalid input! Should be integer.")
input("Try again...")
# read arguments
if (len(sys.argv)) < 2:
print(help)
sys.exit(0)
# main execution
mode = sys.argv[1]
if mode == "new" or mode == "edit":
if mode == "new":
schedule = gen_layout()
print_sched(schedule)
elif mode == "edit":
try:
schedule = read_sched(sys.argv[2])
except:
print("Invalid input file!")
opts = ["print", "edit", "save", "exit"]
while True:
print_sched(schedule)
opt = menu(opts, schedule, 0)
if opt == 0: # print
print_sched(schedule)
elif opt == 1: # edit
print_sched(schedule)
edit(schedule)
elif opt == 2: # save
print("Type the name of the schedule file (recommended .txt extension):")
file = input("-> ")
save(schedule, file)
elif opt == 3: # exit
break
elif mode == "print":
try:
schedule = read_sched(sys.argv[2])
except:
print("Invalid input file!")
print_sched(schedule)

View file

@ -1,11 +0,0 @@
#!/bin/sh
# Look for ifconfig
[ -e "/sbin/ifconfig" ] && CMD="/sbin/ifconfig"
[ -e "$(which ifconfig)" ] && CMD="ifconfig"
[ -n "$CMD" ] || error "ifconfig not found"
# Use ifconfig to get ip address
ADDR="$($CMD | grep -o '192\.168\.[0-9]*\.[0-9]*' | head -n 1)"
php -S "$ADDR":8000 -t .

View file

@ -1,11 +0,0 @@
#!/bin/sh
# Look for ifconfig
[ -e "/sbin/ifconfig" ] && CMD="/sbin/ifconfig"
[ -e "$(which ifconfig)" ] && CMD="ifconfig"
[ -n "$CMD" ] || error "ifconfig not found"
# Use ifconfig to get ip address
ADDR="$($CMD | grep -o '192\.168\.[0-9]*\.[0-9]*' | head -n 1)"
python -m http.server -b "$ADDR"

View file

@ -1,24 +0,0 @@
#!/bin/sh
# Snippets directory
snippets=~/Documents/snippets
# Navigate using fzf
fzf_nav() {
[ -d "$1" ] && cd "$1"
while true ; do
opt=$(/usr/bin/ls -AF1 --group-directories-first)
opt=$(printf "../\n$opt" | fzf --cycle --reverse --padding 2% --preview 'batcat --decorations never --color always {}')
[ -d "$opt" ] && cd "$opt" > /dev/null 2>&1 || break
done
[ -n "$opt" ] && echo "$opt"
}
# Select using menu
snippet=$(fzf_nav "$snippets")
# Exit if empty
[ -z "$snippet" ] && exit
# Copy to clipboard and notify
cat "$snippets"/"$snippet" | xsel -ib && notify-send "Snippet" "'$snippet' copied to clipboard!"
"$EDITOR" "$snippets"/"$snippet"

View file

@ -1,25 +0,0 @@
#!/bin/sh
# Depends on sxiv, dmenu and hsetroot
# Will display background chooser
# and set it using hsetroot
img=$(find ~/Pictures/Backgrounds/* | shuf | sxiv -itoq | tail -1)
# Exit if none chosen
[ -z "$img" ] && exit
# Find previous startup background command
prev=$(grep hsetroot "$XINITRC")
# Define wether or not hsetroot should
# set per monitor or treat multiple monitors as one
option=$(printf "Set per monitor\nTreat multiple monitors as one" | dmenu -i -p "Layout:")
case "$option" in
"Set per monitor") new="hsetroot -cover $img" ;;
"Treat multiple monitors as one") new="hsetroot -root -cover $img" ;;
*) exit 1 ;;
esac
# Set background and change
# startup configuration with new one
$new && sed -i "s|$prev|$new|g" "$XINITRC"

View file

@ -1,8 +0,0 @@
#!/bin/sh
sitedir=$(pwd)
cd $sitedir
git pull
rm -rf $sitedir/public
hugo -D
rsync -uvrP --delete-after $sitedir/public ceo@216.238.79.235: