Initial commit.

This commit is contained in:
Nicolás A. Ortega Froysa 2021-08-31 08:25:02 +02:00
commit 07d5e4092a
12 changed files with 248 additions and 0 deletions

54
audio-control Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
CACHE_DIR="$HOME/.cache/audio-control"
[ "$#" -eq 0 ] &&
echo "Requires a command. Run with 'help' for a list of commands." &&
exit 1
[ "$#" -gt 1 ] &&
echo "Too many arguments. Run with 'help' for a list of commands." &&
exit 1
[ -d $CACHE_DIR ] ||
mkdir -p $CACHE_DIR
query_outport() {
active_port="$(pactl list sinks | grep 'Active Port')"
if [[ $active_port == *"speaker"* ]]
then
echo "SPK" > $CACHE_DIR/port
else
echo "HDF" > $CACHE_DIR/port
fi
pactl list sinks | awk '/Mute/ { if ($2 == "no") print "VOL"; else print "MUT"; }' > $CACHE_DIR/vol_status
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' > $CACHE_DIR/vol_level
}
case $1 in
"mute")
pactl set-sink-mute 0 toggle
pactl list sinks | awk '/Mute/ { if ($2 == "no") print "VOL"; else print "MUT"; }' > $CACHE_DIR/vol_status;;
"vol-up")
pactl set-sink-volume 0 +5%
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' > $CACHE_DIR/vol_level;;
"vol-down")
pactl set-sink-volume 0 -5%
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' > $CACHE_DIR/vol_level;;
"reset")
pactl set-sink-volume 0 50%
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' > $CACHE_DIR/vol_level;;
"toggle-port")
query_outport;;
"help")
echo "USAGE: audio-control <command>
Commands:
mute toggle mute
vol-up raise the volume
vol-down lower the volume
reset reset volume (to round number)
toggle-port toggle the output port
help show this help information";;
*)
echo "Invalid command. Run with 'help' for a list of commands."
exit 1;;
esac

2
backup Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
rsync -aAXv / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/usr/local/share/music/*"} $1

2
clearmem Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
sync && echo 1 > /proc/sys/vm/drop_caches

2
install-script Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
install -m 755 $1 $HOME/.local/bin

2
iplocate Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
curl ipinfo.io/$1

22
monero-client Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
[ "$#" -eq 0 ] &&
echo "Requires a command. Run with 'help' for a list of commands." &&
exit 1
case $1 in
"wallet")
monero-wallet-cli --daemon-address node.monero.net:13666;;
"address")
echo "42espNaUqPdJK4vTir4NDfH4gT6brFR4F5KPRADrg5t98LkzHnQfFnUDZZEetp3Zw5K8V4v364tN3TMxfg4eXEN9RpnrNBG";;
"mine")
xmr-stak-cpu $XDG_CONFIG_HOME/xmr-stak/cpu-config.txt;;
"help")
echo "USAGE: monero-client [command]
Commands:
address print out the monero public address
mine start the miner
wallet open the monero wallet
help show this help information";;
*)
echo "Invalid command '$1'. Please run with the 'help' option.";;
esac

131
play-lofi Executable file
View File

@ -0,0 +1,131 @@
#!/bin/sh
# Copyright (C) 2020 Ortega Froysa, Nicolás <nicolas@ortegas.org> All rights reserved.
# Author: Ortega Froysa, Nicolás <nicolas@ortegas.org>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
#
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
#
# 3. This notice may not be removed or altered from any source
# distribution.
link_file="$XDG_CONFIG_HOME/lofi-link"
print_help() {
echo "USAGE: play-lofi [commands]
A program to play a lofi stream from Invidious (a YouTube proxy). When
given no options, it plays from the stream URL in '\$XDG_CONFIG_HOME/
lofi-link'. If the file does not exist it will give you a selection of
streams to choose from.
Commands:
new choose a new stream URL
set <url> set stream URL
help show this help information"
}
new_link() {
local results=$(curl -s "https://invidio.us/search?q=lofi+radio" |
grep "<p>.*watch" | tr -d "\n" | tr -s " ")
results=${results//\<p\>\<a href\=\"/\"https:\/\/invidio.us}
results=${results//\"\>/\" \"}
results=${results//\<\/a\>\<\/p\>/\" þ }
results=${results::-2} # remove that last separator
# NOTE: I chose þ because never in a million years will that
# character be in the title of a lofi video stream.
IFS="þ" read -r -a streams <<< $results
echo "Streams:"
local id=1
for i in "${streams[@]}"
do
title=${i//*\" \"/\"}
echo "$id) ${title:1:-2}"
((id++))
done
opt=0
while [ "$opt" -gt "${#streams[@]}" ] || [ "$opt" -lt "1" ]
do
printf "Selection: "
read opt
done
link=${streams[$opt]}
link=${link//\" \"*/}
link=${link//*\"/}
echo $link > $link_file
}
# argument parsing
if [ "$#" -eq "1" ]
then
case $1 in
"help")
print_help
exit 0;;
"new")
new_link;;
*)
echo "Unknown command '$1'. Run 'play-lofi help' for a list of commands."
exit 1;;
esac
elif [ "$#" -eq "2" ]
then
if [ "$1" = "set" ]
then
echo "$2" > $link_file
exit 0
else
echo "Unknown command '$1 $2'. Run 'play-lofi help' for a list of commands."
exit 1
fi
elif [ "$#" -gt "2" ]
then
echo "Too many arguments. Run 'play-lofi help' for a list of commands."
exit 1
fi
# check for link file
if ! [ -e "$link_file" ]
then
echo "No link file found in '$link_file'."
while [ "$option" != "y" ] && [ "$option" != "n" ]
do
printf "Would you like to create one? [y/n] "
read option
done
[ "$option" = "n" ] && exit 1
new_link
echo "New link file created."
fi
link=$(cat $link_file)
# check if video is available
output=$(curl -s $link | grep "This video is unavailable.")
if [ -n "$output" ]
then
echo "The stream link '$link' is unavailable."
while [ "$option" != "y" ] && [ "$option" != "n" ]
do
printf "Would you like to find a new one? [y/n] "
read option
done
[ "$option" = "n" ] && exit 1
new_link
echo "New link saved."
fi
mpv --no-video --msg-level=ffmpeg=no $link

8
setbg Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
[ $# -ne 1 ] &&
echo "Requires an image argument." &&
exit 1
cp $1 $HOME/.local/share/wallpaper.jpg
xwallpaper --zoom $HOME/.local/share/wallpaper.jpg

2
space-usage-update Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
df -h | awk '{ if ($6 == "/") printf "/: " $4; if ($6 == "/home") printf " home: " $4; if ($6 == "/usr/local/share/music") printf " music: " $4; }' > $HOME/.cache/free-space

9
ssh-tunnel Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
# TODO:
# - Add options for port
# - Automatically get password from `pass`
PORT=12800
ssh -N -D $PORT nortega@themusicinnoise.net

12
status-update Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
#DATE="$(date +"%F %H:%M:%S" )"
DATE="$(date +"%F %H:%M" )"
NETWORK="eth2: $(cat /sys/class/net/eth2/operstate)"
SPACE="$(cat $HOME/.cache/free-space)"
#vol_out_port="$(cat $HOME/.cache/audio-control/port)"
vol_status="$(cat $HOME/.cache/audio-control/vol_status)"
vol_level="$(cat $HOME/.cache/audio-control/vol_level)%"
#VOLUME="$vol_out_port $vol_status $vol_level"
VOLUME="$vol_status $vol_level"
xsetroot -name "$VOLUME | $NETWORK | $SPACE | $DATE"

2
weather Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
curl "wttr.in/$1?m"