Compare commits

...

35 Commits

Author SHA1 Message Date
e1ba233753 sync-camera: copy MOV file and *then* convert.
This is important to at least not keep files on the device for too long.
2025-04-11 12:53:14 +02:00
cbb8d1a9e8 launch-sway: Add script. 2025-04-11 12:53:01 +02:00
66b4328a30 Update play-lofi 2025-01-17 14:40:55 +01:00
9bb3049dd8 Remove ssh-tunnel. 2025-01-17 14:34:28 +01:00
e1295615d7 Remove setbg.
I don't need it anymore. It was used for DWM.
2025-01-17 14:33:28 +01:00
4ab77fd309 Remove monero-client.
I just use the GUI client now.
2025-01-17 14:32:39 +01:00
6eb456e667 sync-camera: Remove executable permission from file.
This happens because the device is a FAT32 formatted SD card, thus by
default everything is executable. But when transferring to my computer
this isn't necessary.
2025-01-16 09:43:34 +01:00
191784d1f2 sync-camera: require arguments. 2025-01-16 09:42:50 +01:00
e132462e5c sync-camera: clarify output path in info message. 2025-01-16 09:40:51 +01:00
7768df55a6 install-script: remove filename extension before installing. 2024-12-31 17:57:23 +01:00
0f439be1f9 README: Add a general license. 2024-12-31 11:15:40 +01:00
b1a3e5d72e monero-client: remove mining option.
I don't really have a reason to use this anymore.
2024-12-31 11:09:58 +01:00
1a618bb0c1 Add double-quotes to avoid string splitting. 2024-12-31 11:09:36 +01:00
45375ccf9a monero-client: Fix formatting 2024-12-31 11:09:04 +01:00
81af13a1ae Add bash strict options. 2024-12-31 11:03:56 +01:00
46376f9242 setbg: simplify conditional statements. 2024-12-31 11:02:43 +01:00
58fdbe307f audio-control: add bash strict options. 2024-12-31 10:59:48 +01:00
094430c1f7 audio-control: remove commands to update status files.
These were only necessary when I held files for status updates in DWM.
2024-12-31 10:58:59 +01:00
48ef0718cc audio-control unnecessary '$' for arithmetic variables. 2024-12-30 18:51:37 +01:00
a2b2ff9441 audio-control: remove references to CACHE_DIR
No longer used.
2024-12-30 18:51:01 +01:00
82b8648ff6 audio-control: make conditionals more readable. 2024-12-30 18:48:59 +01:00
766f64c4a6 Remove status-update, space-usage-update, and count-updates
These scripts were primarily used in conjunction with DWM, which I no
longer use.
2024-12-30 18:44:34 +01:00
a361543acf Add sync-camera
A script to automatically copy files from the camera. It will also
automatically convert MOV to MP4.
2024-12-30 18:41:15 +01:00
2ee3e3c322 backup: Allow selecting path to back up. 2024-12-30 13:56:24 +01:00
6e60755a15 Change status-update to bash script.
Signed-off-by: Nicolás Ortega Froysa <nicolas@ortegas.org>
2023-11-22 16:21:59 +01:00
7c71b8b614 Automatically find network interfaces.
Signed-off-by: Nicolás Ortega Froysa <nicolas@ortegas.org>
2023-11-21 07:34:08 +01:00
3c883b3808 Add count-updates for ArchLinux(ARM)
Signed-off-by: Nicolás Ortega Froysa <nicolas@ortegas.org>
2023-08-18 11:01:14 +02:00
69642a9041 Add d6
Signed-off-by: Nicolás Ortega Froysa <nicolas@ortegas.org>
2023-08-18 11:01:04 +02:00
76f5fb5053 weather: use proper URL
Signed-off-by: Nicolás Ortega Froysa <nicolas@ortegas.org>
2023-08-18 11:00:43 +02:00
46d3cf2484 Merge branch 'pius-xi' of gitlab.com:naortega/my-scripts into pius-xi 2023-08-18 11:00:20 +02:00
f5c30419a8 Change music directory. 2023-04-18 10:58:21 +02:00
6c238989f8 Switch to using file. 2023-04-18 10:58:21 +02:00
326b550b2f setbg: no arguments resets wallpaper
Also with some minor improvements of the code.
2023-04-14 11:57:50 +02:00
3028b35bcd Change music directory. 2022-06-10 21:11:58 +02:00
31c11366c8 Switch to using file. 2022-05-31 22:03:27 +02:00
18 changed files with 311 additions and 97 deletions

16
LICENSE Normal file
View 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.

1
README
View File

@ -1 +0,0 @@
A collection of all my scripts.

5
README.md Normal file
View 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).

View File

@ -1,43 +1,31 @@
#!/bin/bash
CACHE_DIR="$HOME/.cache/audio-control"
[ "$#" -eq 0 ] &&
echo "Requires a command. Run with 'help' for a list of commands." &&
set -euo pipefail
if [ "$#" -eq 0 ]
then
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." &&
fi
if [ "$#" -gt 1 ]
then
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
}
fi
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>
@ -47,7 +35,8 @@ Commands:
vol-down lower the volume
reset reset volume (to round number)
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."
exit 1;;

5
backup
View File

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

View File

@ -1,2 +1,5 @@
#!/bin/bash
set -euo pipefail
sync && echo 1 > /proc/sys/vm/drop_caches

118
d6 Executable file
View File

@ -0,0 +1,118 @@
#!/bin/bash
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# 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 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.
#
# For more information, please refer to <http://unlicense.org/>
VERSION="1.0"
function print_usage() {
echo "USAGE: d6 [OPTIONS]"
}
function print_help() {
print_usage
echo "OPTIONS:
-v print program version
-h print this help information
-n <num> number of words in generated password (default 3)
-f <file> custom dictionary file (default
~/.local/share/wordlist.txt)
-d <delim> delimiter used between words (default \"\", i.e. NONE)
-c <case> the case used for the generated words, can be: upper,
lower, capital (default \"capital\")"
}
function test_case() {
if [ $1 != "lower" ] && [ $1 != "upper" ] && [ $1 != "capital" ]
then
return 1
else
return 0
fi
}
NUM_WORDS=3
WORDLIST="$HOME/.local/share/wordlist.txt"
DELIMITER=""
CASE="capital"
while getopts "vhn:f:d:c:" arg
do
case $arg in
v)
echo "d6 v$VERSION"
exit 0;;
h)
print_help
exit 0;;
n)
NUM_WORDS=$OPTARG;;
f)
WORDLIST="$OPTARG";;
d)
DELIMITER="$OPTARG";;
c)
if test_case $OPTARG
then
CASE="$OPTARG"
else
echo "'$OPTARG' is an invalid case. Use 'capital', 'lower', or 'upper'."
exit 1
fi;;
?)
print_usage
exit 2
esac
done
WORDS=""
for i in $(seq 1 $NUM_WORDS)
do
ROLLS=""
for j in {1..5}
do
ROLLS="$((1 + $RANDOM % 6))$ROLLS"
done
if [ $CASE == "upper" ]
then
WORD="$(awk "/$ROLLS/{ print toupper(\$2) }" $WORDLIST)"
elif [ $CASE == "lower" ]
then
WORD="$(awk "/$ROLLS/{ print tolower(\$2) }" $WORDLIST)"
else
WORD="$(awk "/$ROLLS/{ print \$2 }" $WORDLIST)"
WORD="${WORD^}"
fi
if [ $i -eq $NUM_WORDS ]
then
WORDS="${WORDS}${WORD}"
else
WORDS="${WORDS}${WORD}${DELIMITER}"
fi
done
echo "$WORDS"

View File

@ -1,2 +1,13 @@
#!/bin/sh
install -m 755 $1 $HOME/.local/bin
#!/bin/bash
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"

View File

@ -1,2 +1,5 @@
#!/bin/bash
curl ipinfo.io/$1
set -euo pipefail
curl "ipinfo.io/$1"

7
launch-sway Executable file
View 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

View File

@ -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

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Copyright (C) 2020 Ortega Froysa, Nicolás <nicolas@ortegas.org> All rights reserved.
# Author: Ortega Froysa, Nicolás <nicolas@ortegas.org>
#
@ -37,16 +37,17 @@ Commands:
}
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 " ")
results=${results//\<p\>\<a href\=\"/\"https:\/\/invidio.us}
results=${results//\<p\>\<a href\=\"/\"https:\/\/invidious.tube}
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
IFS="þ" read -r -a streams <<< "$results"
echo "Streams:"
local id=1
@ -60,12 +61,12 @@ new_link() {
while [ "$opt" -gt "${#streams[@]}" ] || [ "$opt" -lt "1" ]
do
printf "Selection: "
read opt
read -r opt
done
link=${streams[$opt]}
link=${link//\" \"*/}
link=${link//*\"/}
echo $link > $link_file
echo "$link" > "$link_file"
}
# argument parsing
@ -85,7 +86,7 @@ elif [ "$#" -eq "2" ]
then
if [ "$1" = "set" ]
then
echo "$2" > $link_file
echo "$2" > "$link_file"
exit 0
else
echo "Unknown command '$1 $2'. Run 'play-lofi help' for a list of commands."
@ -104,28 +105,28 @@ then
while [ "$option" != "y" ] && [ "$option" != "n" ]
do
printf "Would you like to create one? [y/n] "
read option
read -r option
done
[ "$option" = "n" ] && exit 1
new_link
echo "New link file created."
fi
link=$(cat $link_file)
link=$(cat "$link_file")
# 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" ]
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
read -r option
done
[ "$option" = "n" ] && exit 1
new_link
echo "New link saved."
fi
mpv --no-video --msg-level=ffmpeg=no $link
mpv --no-video --msg-level=ffmpeg=no "$link"

8
setbg
View File

@ -1,8 +0,0 @@
#!/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

View File

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

View File

@ -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

View File

@ -1,10 +0,0 @@
#!/bin/sh
DATE="$(date +"%F %H:%M" )"
NETWORK="eth: $(cat /sys/class/net/enp34s0/operstate)"
SPACE="$(cat $HOME/.cache/free-space)"
vol_status="$(cat $HOME/.cache/audio-control/vol_status)"
vol_level="$(cat $HOME/.cache/audio-control/vol_level)%"
VOLUME="$vol_status $vol_level"
UPDATES="Upd: $(checkupdates -n | wc -l)"
xsetroot -name "$VOLUME | $NETWORK | $SPACE | $UPDATES | $DATE"

107
sync-camera Executable file
View File

@ -0,0 +1,107 @@
#!/bin/bash
set -euo pipefail
CAMERA_DEVICE=""
MOUNT_DIR="/tmp/camera-mount"
OUTPUT_DIR=""
REMOVE_FILES=0
function print_usage() {
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
do
case "$opt" in
'd')
CAMERA_DEVICE=${OPTARG}
;;
'o')
OUTPUT_DIR=${OPTARG}
;;
't')
MOUNT_DIR="${OPTARG}"
;;
'r')
REMOVE_FILES=1
;;
'h')
print_usage
exit 0
;;
*)
print_usage
exit 1
;;
esac
done
if [ -z "$CAMERA_DEVICE" ]
then
echo "Failed to set the camera device."
exit 1
fi
if [ -z "$OUTPUT_DIR" ]
then
echo "Failed to set the output directory."
exit 1
fi
if ! mkdir "$MOUNT_DIR"
then
echo "Unable to create mount directory '$MOUNT_DIR'."
exit 1
fi
if ! sudo mount -o "uid=$(id --user),gid=$(id --group)" "$CAMERA_DEVICE" "$MOUNT_DIR"
then
rmdir "$MOUNT_DIR"
fi
while IFS= read -r -d '' INPUT_FILE
do
OUTPUT_PATH="$OUTPUT_DIR/${INPUT_FILE##*/}"
if ! [ -f "$OUTPUT_PATH" ]
then
echo "Copying ${INPUT_FILE} to ${OUTPUT_PATH::-4}.jpg ..."
cp "$INPUT_FILE" "${OUTPUT_PATH::-4}.jpg"
chmod -x "${OUTPUT_PATH::-4}.jpg"
fi
if [ $REMOVE_FILES -eq 1 ]
then
echo "Removing ${INPUT_FILE} and ${INPUT_FILE::-4}.THM ..."
rm -f "$INPUT_FILE" "${INPUT_FILE::-4}.THM"
fi
done < <(find "$MOUNT_DIR" -type f -name '*.JPG' -print0)
while IFS= read -r -d '' INPUT_FILE
do
OUTPUT_PATH="$OUTPUT_DIR/${INPUT_FILE##*/}"
if ! [ -f "$OUTPUT_PATH" ]
then
echo "Copying $INPUT_FILE to ${OUTPUT_PATH} ..."
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
if [ $REMOVE_FILES -eq 1 ]
then
echo "Removing ${INPUT_FILE} and ${INPUT_FILE::-4}.THM ..."
rm -f "$INPUT_FILE" "${INPUT_FILE::-4}.THM"
fi
done < <(find "$MOUNT_DIR" -type f -name '*.MOV' -print0)
sudo umount "$MOUNT_DIR"
rmdir "$MOUNT_DIR"

View File

@ -1,2 +1,5 @@
#!/bin/sh
curl "wttr.in/$1?m"
#!/bin/bash
set -euo pipefail
curl "http://wttr.in/$1?m"