Compare commits
18 Commits
48ef0718cc
...
master
Author | SHA1 | Date | |
---|---|---|---|
e1ba233753 | |||
cbb8d1a9e8 | |||
66b4328a30 | |||
9bb3049dd8 | |||
e1295615d7 | |||
4ab77fd309 | |||
6eb456e667 | |||
191784d1f2 | |||
e132462e5c | |||
7768df55a6 | |||
0f439be1f9 | |||
b1a3e5d72e | |||
1a618bb0c1 | |||
45375ccf9a | |||
81af13a1ae | |||
46376f9242 | |||
58fdbe307f | |||
094430c1f7 |
16
LICENSE
Normal file
16
LICENSE
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
MIT No Attribution
|
||||||
|
|
||||||
|
Copyright 2024 Nicolás Ortega Froysa <nicolas@ortegas.org>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
|
software and associated documentation files (the "Software"), to deal in the Software
|
||||||
|
without restriction, including without limitation the rights to use, copy, modify,
|
||||||
|
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
5
README.md
Normal file
5
README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# My Scripts
|
||||||
|
|
||||||
|
This is a collection of personal scripts I use that others may also find useful.
|
||||||
|
All scripts here are licensed under the MIT No Attribution license, unless
|
||||||
|
otherwise specified (look at the header of the script).
|
@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
if [ "$#" -eq 0 ]
|
if [ "$#" -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "Requires a command. Run with 'help' for a list of commands."
|
echo "Requires a command. Run with 'help' for a list of commands."
|
||||||
@ -14,19 +16,15 @@ fi
|
|||||||
case $1 in
|
case $1 in
|
||||||
"mute")
|
"mute")
|
||||||
pactl set-sink-mute 0 toggle
|
pactl set-sink-mute 0 toggle
|
||||||
pactl list sinks | awk '/Mute/ { if ($2 == "no") print "VOL"; else print "MUT"; }'
|
|
||||||
;;
|
;;
|
||||||
"vol-up")
|
"vol-up")
|
||||||
pactl set-sink-volume 0 +5%
|
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,'
|
|
||||||
;;
|
;;
|
||||||
"vol-down")
|
"vol-down")
|
||||||
pactl set-sink-volume 0 -5%
|
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,'
|
|
||||||
;;
|
;;
|
||||||
"reset")
|
"reset")
|
||||||
pactl set-sink-volume 0 50%
|
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,'
|
|
||||||
;;
|
;;
|
||||||
"help")
|
"help")
|
||||||
echo "USAGE: audio-control <command>
|
echo "USAGE: audio-control <command>
|
||||||
@ -37,7 +35,8 @@ Commands:
|
|||||||
vol-down lower the volume
|
vol-down lower the volume
|
||||||
reset reset volume (to round number)
|
reset reset volume (to round number)
|
||||||
toggle-port toggle the output port
|
toggle-port toggle the output port
|
||||||
help show this help information";;
|
help show this help information"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Invalid command. Run with 'help' for a list of commands."
|
echo "Invalid command. Run with 'help' for a list of commands."
|
||||||
exit 1;;
|
exit 1;;
|
||||||
|
3
backup
3
backup
@ -1,2 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
rsync -aAXv --delete "$1" --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/media/music/*"} "$2"
|
rsync -aAXv --delete "$1" --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/media/music/*"} "$2"
|
||||||
|
3
clearmem
3
clearmem
@ -1,2 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
sync && echo 1 > /proc/sys/vm/drop_caches
|
sync && echo 1 > /proc/sys/vm/drop_caches
|
||||||
|
@ -1,2 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
install -m 755 $1 $HOME/.local/bin
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SCRIPT_FILE="$1"
|
||||||
|
|
||||||
|
# Remove extension from script
|
||||||
|
if [[ $SCRIPT_FILE == *.* ]]
|
||||||
|
then
|
||||||
|
SCRIPT_FILE=${SCRIPT_FILE%.*}
|
||||||
|
fi
|
||||||
|
|
||||||
|
install -m 755 "$SCRIPT_FILE" "$HOME/.local/bin"
|
||||||
|
5
iplocate
5
iplocate
@ -1,2 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
curl ipinfo.io/$1
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
curl "ipinfo.io/$1"
|
||||||
|
7
launch-sway
Executable file
7
launch-sway
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#export SDL_VIDEODRIVER=wayland
|
||||||
|
export _JAVA_AWT_WM_NONREPARENTING=1
|
||||||
|
export QT_QPA_PLATFORM=wayland
|
||||||
|
export XDG_CURRENT_DESKTOP=sway
|
||||||
|
export XDG_SESSION_DESKTOP=sway
|
||||||
|
exec sway
|
@ -1,22 +0,0 @@
|
|||||||
#!/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
|
|
25
play-lofi
25
play-lofi
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
# Copyright (C) 2020 Ortega Froysa, Nicolás <nicolas@ortegas.org> All rights reserved.
|
# Copyright (C) 2020 Ortega Froysa, Nicolás <nicolas@ortegas.org> All rights reserved.
|
||||||
# Author: Ortega Froysa, Nicolás <nicolas@ortegas.org>
|
# Author: Ortega Froysa, Nicolás <nicolas@ortegas.org>
|
||||||
#
|
#
|
||||||
@ -37,16 +37,17 @@ Commands:
|
|||||||
}
|
}
|
||||||
|
|
||||||
new_link() {
|
new_link() {
|
||||||
local results=$(curl -s "https://invidio.us/search?q=lofi+radio" |
|
local results
|
||||||
|
results=$(curl -s "https://invidious.tube/search?q=lofi+radio" |
|
||||||
grep "<p>.*watch" | tr -d "\n" | tr -s " ")
|
grep "<p>.*watch" | tr -d "\n" | tr -s " ")
|
||||||
results=${results//\<p\>\<a href\=\"/\"https:\/\/invidio.us}
|
results=${results//\<p\>\<a href\=\"/\"https:\/\/invidious.tube}
|
||||||
results=${results//\"\>/\" \"}
|
results=${results//\"\>/\" \"}
|
||||||
results=${results//\<\/a\>\<\/p\>/\" þ }
|
results=${results//\<\/a\>\<\/p\>/\" þ }
|
||||||
results=${results::-2} # remove that last separator
|
results=${results::-2} # remove that last separator
|
||||||
|
|
||||||
# NOTE: I chose þ because never in a million years will that
|
# NOTE: I chose þ because never in a million years will that
|
||||||
# character be in the title of a lofi video stream.
|
# character be in the title of a lofi video stream.
|
||||||
IFS="þ" read -r -a streams <<< $results
|
IFS="þ" read -r -a streams <<< "$results"
|
||||||
|
|
||||||
echo "Streams:"
|
echo "Streams:"
|
||||||
local id=1
|
local id=1
|
||||||
@ -60,12 +61,12 @@ new_link() {
|
|||||||
while [ "$opt" -gt "${#streams[@]}" ] || [ "$opt" -lt "1" ]
|
while [ "$opt" -gt "${#streams[@]}" ] || [ "$opt" -lt "1" ]
|
||||||
do
|
do
|
||||||
printf "Selection: "
|
printf "Selection: "
|
||||||
read opt
|
read -r opt
|
||||||
done
|
done
|
||||||
link=${streams[$opt]}
|
link=${streams[$opt]}
|
||||||
link=${link//\" \"*/}
|
link=${link//\" \"*/}
|
||||||
link=${link//*\"/}
|
link=${link//*\"/}
|
||||||
echo $link > $link_file
|
echo "$link" > "$link_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# argument parsing
|
# argument parsing
|
||||||
@ -85,7 +86,7 @@ elif [ "$#" -eq "2" ]
|
|||||||
then
|
then
|
||||||
if [ "$1" = "set" ]
|
if [ "$1" = "set" ]
|
||||||
then
|
then
|
||||||
echo "$2" > $link_file
|
echo "$2" > "$link_file"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
echo "Unknown command '$1 $2'. Run 'play-lofi help' for a list of commands."
|
echo "Unknown command '$1 $2'. Run 'play-lofi help' for a list of commands."
|
||||||
@ -104,28 +105,28 @@ then
|
|||||||
while [ "$option" != "y" ] && [ "$option" != "n" ]
|
while [ "$option" != "y" ] && [ "$option" != "n" ]
|
||||||
do
|
do
|
||||||
printf "Would you like to create one? [y/n] "
|
printf "Would you like to create one? [y/n] "
|
||||||
read option
|
read -r option
|
||||||
done
|
done
|
||||||
[ "$option" = "n" ] && exit 1
|
[ "$option" = "n" ] && exit 1
|
||||||
new_link
|
new_link
|
||||||
echo "New link file created."
|
echo "New link file created."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
link=$(cat $link_file)
|
link=$(cat "$link_file")
|
||||||
|
|
||||||
# check if video is available
|
# check if video is available
|
||||||
output=$(curl -s $link | grep "This video is unavailable.")
|
output=$(curl -s "$link" | grep "This video is unavailable.")
|
||||||
if [ -n "$output" ]
|
if [ -n "$output" ]
|
||||||
then
|
then
|
||||||
echo "The stream link '$link' is unavailable."
|
echo "The stream link '$link' is unavailable."
|
||||||
while [ "$option" != "y" ] && [ "$option" != "n" ]
|
while [ "$option" != "y" ] && [ "$option" != "n" ]
|
||||||
do
|
do
|
||||||
printf "Would you like to find a new one? [y/n] "
|
printf "Would you like to find a new one? [y/n] "
|
||||||
read option
|
read -r option
|
||||||
done
|
done
|
||||||
[ "$option" = "n" ] && exit 1
|
[ "$option" = "n" ] && exit 1
|
||||||
new_link
|
new_link
|
||||||
echo "New link saved."
|
echo "New link saved."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mpv --no-video --msg-level=ffmpeg=no $link
|
mpv --no-video --msg-level=ffmpeg=no "$link"
|
||||||
|
12
setbg
12
setbg
@ -1,12 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if [ $# -gt 1 ]
|
|
||||||
then
|
|
||||||
echo "Too many arguments"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
[ $# -eq 1 ] &&
|
|
||||||
cp $1 $HOME/.local/share/wallpaper.jpg
|
|
||||||
|
|
||||||
xwallpaper --zoom $HOME/.local/share/wallpaper.jpg
|
|
@ -1,9 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# TODO:
|
|
||||||
# - Add options for port
|
|
||||||
# - Automatically get password from `pass`
|
|
||||||
|
|
||||||
PORT=12800
|
|
||||||
|
|
||||||
ssh -N -D $PORT nortega@themusicinnoise.net
|
|
20
sync-camera
20
sync-camera
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -eu
|
set -euo pipefail
|
||||||
|
|
||||||
CAMERA_DEVICE=""
|
CAMERA_DEVICE=""
|
||||||
MOUNT_DIR="/tmp/camera-mount"
|
MOUNT_DIR="/tmp/camera-mount"
|
||||||
@ -11,6 +11,13 @@ function print_usage() {
|
|||||||
echo "USAGE: ${0##*/} -d <device> -o <dir> [-t <dir>] [-r]"
|
echo "USAGE: ${0##*/} -d <device> -o <dir> [-t <dir>] [-r]"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]
|
||||||
|
then
|
||||||
|
>&2 echo "No arguments specified!"
|
||||||
|
print_usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
while getopts "d:o:t:rh" opt
|
while getopts "d:o:t:rh" opt
|
||||||
do
|
do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
@ -64,8 +71,9 @@ do
|
|||||||
OUTPUT_PATH="$OUTPUT_DIR/${INPUT_FILE##*/}"
|
OUTPUT_PATH="$OUTPUT_DIR/${INPUT_FILE##*/}"
|
||||||
if ! [ -f "$OUTPUT_PATH" ]
|
if ! [ -f "$OUTPUT_PATH" ]
|
||||||
then
|
then
|
||||||
echo "Copying ${INPUT_FILE} to ${OUTPUT_PATH} ..."
|
echo "Copying ${INPUT_FILE} to ${OUTPUT_PATH::-4}.jpg ..."
|
||||||
cp "$INPUT_FILE" "${OUTPUT_PATH::-4}.jpg"
|
cp "$INPUT_FILE" "${OUTPUT_PATH::-4}.jpg"
|
||||||
|
chmod -x "${OUTPUT_PATH::-4}.jpg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $REMOVE_FILES -eq 1 ]
|
if [ $REMOVE_FILES -eq 1 ]
|
||||||
@ -80,8 +88,12 @@ do
|
|||||||
OUTPUT_PATH="$OUTPUT_DIR/${INPUT_FILE##*/}"
|
OUTPUT_PATH="$OUTPUT_DIR/${INPUT_FILE##*/}"
|
||||||
if ! [ -f "$OUTPUT_PATH" ]
|
if ! [ -f "$OUTPUT_PATH" ]
|
||||||
then
|
then
|
||||||
echo "Converting ${INPUT_FILE} to MP4 at ${OUTPUT_PATH} ..."
|
echo "Copying $INPUT_FILE to ${OUTPUT_PATH} ..."
|
||||||
ffmpeg -loglevel fatal -nostdin -i "$INPUT_FILE" "${OUTPUT_PATH::-4}.mp4"
|
cp "${INPUT_FILE}" "${OUTPUT_PATH}"
|
||||||
|
echo "Converting ${INPUT_FILE} to MP4 at ${OUTPUT_PATH::-4}.mp4 ..."
|
||||||
|
ffmpeg -loglevel fatal -nostdin -i "$OUTPUT_PATH" "${OUTPUT_PATH::-4}.mp4"
|
||||||
|
echo "Removing temporary file $OUTPUT_PATH ..."
|
||||||
|
rm "$OUTPUT_PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $REMOVE_FILES -eq 1 ]
|
if [ $REMOVE_FILES -eq 1 ]
|
||||||
|
Reference in New Issue
Block a user