Compare commits

...

17 Commits

Author SHA1 Message Date
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
Nicolás A. Ortega Froysa
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
8 changed files with 238 additions and 43 deletions

View File

@ -1,43 +1,33 @@
#!/bin/bash
CACHE_DIR="$HOME/.cache/audio-control"
[ "$#" -eq 0 ] &&
echo "Requires a command. Run with 'help' for a list of commands." &&
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;;
pactl list sinks | awk '/Mute/ { if ($2 == "no") print "VOL"; else print "MUT"; }'
;;
"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;;
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,'
;;
"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;;
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,'
;;
"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;;
pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,'
;;
"help")
echo "USAGE: audio-control <command>

2
backup
View File

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

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"

10
setbg
View File

@ -1,8 +1,12 @@
#!/bin/sh
[ $# -ne 1 ] &&
echo "Requires an image argument." &&
if [ $# -gt 1 ]
then
echo "Too many arguments"
exit 1
fi
[ $# -eq 1 ] &&
cp $1 $HOME/.local/share/wallpaper.jpg
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,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"

95
sync-camera Executable file
View File

@ -0,0 +1,95 @@
#!/bin/bash
set -eu
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]"
}
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} ..."
cp "$INPUT_FILE" "${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 "Converting ${INPUT_FILE} to MP4 at ${OUTPUT_PATH} ..."
ffmpeg -loglevel fatal -nostdin -i "$INPUT_FILE" "${OUTPUT_PATH::-4}.mp4"
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,2 @@
#!/bin/sh
curl "wttr.in/$1?m"
curl "http://wttr.in/$1?m"