Merge remote-tracking branch 'refs/remotes/origin/master'

This commit is contained in:
2022-11-01 16:09:17 -04:00
committed by Kevin Mok
84 changed files with 4269 additions and 374 deletions

View File

@@ -1,6 +1,7 @@
#!/bin/bash
mount_dir="/run/media/kevin/backup-hd"
# mount_dir="/run/media/kevin/backup-hd"
mount_dir="/mnt/linux-files-2"
# Backup destination
case $1 in
nzxt )
@@ -23,9 +24,9 @@ case $2 in
sudo tar -czpvf "$backup_file" --exclude-from="$exclude_dirs_list" --exclude=/home /
;;
full )
sudo rsync -PraAX --exclude-from="$exclude_dirs_list_full" / "$backup_dest/full"
;;
# full )
# sudo rsync -PraAX --exclude-from="$exclude_dirs_list_full" / "$backup_dest/full"
# ;;
home )
sudo rsync -PraAX --exclude-from="$exclude_dirs_list_full" /home "$backup_dest/full"
esac

View File

@@ -0,0 +1,3 @@
#!/bin/bash
cat ~/Documents/twitch-emotes.md | dmenu -i | sed -z 's/\n/ /' | xclip -selection clipboard

View File

@@ -0,0 +1,3 @@
#!/bin/dash
sqlite3 ~/.cache/spotify/mercury.db 'VACUUM;' && spotify

101
scripts/executable_ticker Executable file
View File

@@ -0,0 +1,101 @@
#!/usr/bin/env bash
set -e
LANG=C
LC_NUMERIC=C
SYMBOLS=("$@")
if ! $(type jq > /dev/null 2>&1); then
echo "'jq' is not in the PATH. (See: https://stedolan.github.io/jq/)"
exit 1
fi
if [ -z "$SYMBOLS" ]; then
echo "Usage: ./ticker.sh AAPL MSFT GOOG BTC-USD"
exit
fi
FIELDS=(symbol marketState regularMarketPrice regularMarketChange regularMarketChangePercent \
preMarketPrice preMarketChange preMarketChangePercent postMarketPrice postMarketChange postMarketChangePercent)
API_ENDPOINT="https://query1.finance.yahoo.com/v7/finance/quote?lang=en-US&region=US&corsDomain=finance.yahoo.com"
if [ -z "$NO_COLOR" ]; then
: "${COLOR_BOLD:=\e[1;37m}"
: "${COLOR_GREEN:=\e[32m}"
: "${COLOR_RED:=\e[31m}"
: "${COLOR_RESET:=\e[00m}"
fi
symbols=$(IFS=,; echo "${SYMBOLS[*]}")
fields=$(IFS=,; echo "${FIELDS[*]}")
results=$(curl --silent "$API_ENDPOINT&fields=$fields&symbols=$symbols" \
| jq '.quoteResponse .result')
query () {
echo $results | jq -r ".[] | select(.symbol == \"$1\") | .$2"
}
for symbol in $(IFS=' '; echo "${SYMBOLS[*]}" | tr '[:lower:]' '[:upper:]'); do
marketState="$(query $symbol 'marketState')"
if [ -z $marketState ]; then
printf 'No results for symbol "%s"\n' $symbol
continue
fi
preMarketChange="$(query $symbol 'preMarketChange')"
postMarketChange="$(query $symbol 'postMarketChange')"
if [ $marketState == "PRE" ] \
&& [ $preMarketChange != "0" ] \
&& [ $preMarketChange != "null" ]; then
nonRegularMarketSign='*'
price=$(query $symbol 'preMarketPrice')
diff=$preMarketChange
percent=$(query $symbol 'preMarketChangePercent')
elif [ $marketState != "REGULAR" ] \
&& [ $postMarketChange != "0" ] \
&& [ $postMarketChange != "null" ]; then
nonRegularMarketSign='*'
price=$(query $symbol 'postMarketPrice')
diff=$postMarketChange
percent=$(query $symbol 'postMarketChangePercent')
else
nonRegularMarketSign=''
price=$(query $symbol 'regularMarketPrice')
diff=$(query $symbol 'regularMarketChange')
percent=$(query $symbol 'regularMarketChangePercent')
fi
if [ "$diff" == "0" ]; then
color=
elif ( echo "$diff" | grep -q ^- ); then
color=$COLOR_RED
else
color=$COLOR_GREEN
fi
if [ "$price" != "null" ]; then
# printf "%-10s$COLOR_BOLD%8.2f$COLOR_RESET" $symbol $price
# printf "$color%10.2f%12s$COLOR_RESET" $diff $(printf "(%.2f%%)" $percent)
# printf " %s\n" "$nonRegularMarketSign"
# echo \$$price
# echo $price
hour=$(date +"%H")
if [[ "$symbol" == "USDCAD=X" ]]; then
printf "%0.4f\n" "$price"
elif [[ "$symbol" == "BTC-USD" || "$symbol" == "ETH-USD" ]]; then
# echo "$price" | cut -c 2-3
echo "$price" | cut -c -3
elif (( $(echo "$price > 10000" | bc -l) )); then
printf "%'0.0f\n" "$price" | cut -c 2-4
# elif (( $(echo "$price < 1" | bc -l) )); then
# printf "%0.3f\n" "$price"
else
printf "%0.2f\n" "$price" | cut -c 3-
# printf "%0.2f\n" "$price"
fi
fi
done

View File

@@ -1,7 +1,13 @@
#!/bin/bash
#!/bin/dash
# for i in {1..4} ; do
# xdotool key Left
# done
sleep .3
xdotool type 'https://twem.gq/.png'
for i in {1..4} ; do
i=0
while [ "$i" -ne 4 ]
do
xdotool key Left
i=$((i + 1))
done

View File

@@ -0,0 +1,8 @@
#!/usr/bin/fish
set TEMP_CSV /tmp/twitchy-fortnite.csv
set HEADER "Game,Channel,Viewers,Uptime,Title"
echo $HEADER > $TEMP_CSV
twitchy --non-interactive >> $TEMP_CSV
xsv search -is1 $argv[1] $TEMP_CSV | xsv sort -NRs3 | xsv table