commit 07d5e4092a806f78084fbf14aa04cc94d10c6cc1 Author: Nicolás Ortega Froysa Date: Tue Aug 31 08:25:02 2021 +0200 Initial commit. diff --git a/audio-control b/audio-control new file mode 100755 index 0000000..ce64f6f --- /dev/null +++ b/audio-control @@ -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 + +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 diff --git a/backup b/backup new file mode 100755 index 0000000..4cb5e82 --- /dev/null +++ b/backup @@ -0,0 +1,2 @@ +#!/bin/bash +rsync -aAXv / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/usr/local/share/music/*"} $1 diff --git a/clearmem b/clearmem new file mode 100755 index 0000000..6fe4cca --- /dev/null +++ b/clearmem @@ -0,0 +1,2 @@ +#!/bin/bash +sync && echo 1 > /proc/sys/vm/drop_caches diff --git a/install-script b/install-script new file mode 100755 index 0000000..0d50a7b --- /dev/null +++ b/install-script @@ -0,0 +1,2 @@ +#!/bin/sh +install -m 755 $1 $HOME/.local/bin diff --git a/iplocate b/iplocate new file mode 100755 index 0000000..18778aa --- /dev/null +++ b/iplocate @@ -0,0 +1,2 @@ +#!/bin/bash +curl ipinfo.io/$1 diff --git a/monero-client b/monero-client new file mode 100755 index 0000000..c26c036 --- /dev/null +++ b/monero-client @@ -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 diff --git a/play-lofi b/play-lofi new file mode 100755 index 0000000..0c616e4 --- /dev/null +++ b/play-lofi @@ -0,0 +1,131 @@ +#!/bin/sh +# Copyright (C) 2020 Ortega Froysa, Nicolás All rights reserved. +# Author: Ortega Froysa, Nicolás +# +# 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 set stream URL + help show this help information" +} + +new_link() { + local results=$(curl -s "https://invidio.us/search?q=lofi+radio" | + grep "

.*watch" | tr -d "\n" | tr -s " ") + 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 diff --git a/setbg b/setbg new file mode 100755 index 0000000..42300af --- /dev/null +++ b/setbg @@ -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 diff --git a/space-usage-update b/space-usage-update new file mode 100755 index 0000000..c2c7497 --- /dev/null +++ b/space-usage-update @@ -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 diff --git a/ssh-tunnel b/ssh-tunnel new file mode 100755 index 0000000..c540da0 --- /dev/null +++ b/ssh-tunnel @@ -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 diff --git a/status-update b/status-update new file mode 100755 index 0000000..e1aaff3 --- /dev/null +++ b/status-update @@ -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" diff --git a/weather b/weather new file mode 100755 index 0000000..bb92b69 --- /dev/null +++ b/weather @@ -0,0 +1,2 @@ +#!/bin/sh +curl "wttr.in/$1?m"