add sway config

add bashrc
ignore xauthority
add autounlocking keepass desktop entry
add fonts for waybar
add alacritty config
move scripts location and adjust bashrc
use materia
theme sway and lockscreen
add list packages script
add ranger desktop item
add mpd config
add indicator ring to swaylock
remove mpd password
add global asdf tool versions
add mako config
update keys
add swaylock theme
add suspend to lock config
move ssh commands to aliases
tweak mpd section in waybar
add kanshi config for work
update bashrc
This commit is contained in:
2021-11-17 14:17:36 -05:00
commit e77854b6b5
44 changed files with 1269 additions and 0 deletions

View File

@ -0,0 +1,23 @@
#!/usr/bin/env sh
set pipefail -eou
# Old script to get json url for some reason? Don't know why I did this
# youtube-dl -j --flat-playlist -a - | \
# jq -r '.id' | \
# sed 's_^_https://youtu.be/_' | \
# wget-titles-from-urls >> titles.txt
test -f append.txt
if [[ $? -ne 0 ]]; then
echo No append.txt found! Cannot append
exit
fi
if [[ ! -s append.txt ]]; then
echo append.txt is empty
exit
fi
cat append.txt | wget-titles-from-urls >> titles.txt
cat append.txt | youtube-audio
> append.txt

View File

@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -uo pipefail #set -e causes errors since most playlist will throw errors
PARENT='/run/media/default/backup'
# audio
PARENT_AUDIO="$PARENT/audio"
(cd "$PARENT_AUDIO/anjunadeep" && echo https://www.youtube.com/playlist?list=UUbDgBFAketcO26wz-pR6OKA | youtube-archive-audio)
(cd "$PARENT_AUDIO/eeuphonious" && echo https://www.youtube.com/playlist?list=UUaHM7hKCwJ_eR-dP3c7PKHw | youtube-archive-audio)
(cd "$PARENT_AUDIO/trianglemusic" && echo https://www.youtube.com/playlist?list=UUDBdeEaSnlu-AU-ITBTRkeQ | youtube-archive-audio)
(cd "$PARENT_AUDIO/ikiru" && echo https://www.youtube.com/playlist?list=UUVg1vfzDjkT9T_F-PZGC5Mw | youtube-archive-audio)
# video
PARENT_VIDEO="$PARENT/youtube"
(cd "$PARENT_VIDEO/yotsu" && echo https://www.youtube.com/playlist?list=UU0FplT88irKbHeZucDiFplw | youtube-archive)
(cd "$PARENT_VIDEO/jeb-gardener" && echo https://www.youtube.com/playlist?list=UU5zdi4KM3ewwfYMNo_KnU0A | youtube-archive)
(cd "$PARENT_VIDEO/vagrant-holiday" && echo https://www.youtube.com/channel/UCgNqlRGqHdxNRPR6ycynWhw | youtube-archive)
(cd "$PARENT_VIDEO/fredrik-knudsen" && echo https://www.youtube.com/channel/UCbWcXB0PoqOsAvAdfzWMf0w | youtube-archive)
(cd "$PARENT_VIDEO/internet-historian" && echo https://www.youtube.com/channel/UCR1D15p_vdP3HkrH8wgjQRw | youtube-archive)
(cd "$PARENT_VIDEO/breadsword" && echo https://www.youtube.com/channel/UCcScIr2iskFm-zRo8FZ7cRw | youtube-archive)
#(cd "$PARENT_VIDEO/" && echo | youtube-archive)
# git
PARENT_GIT="$PARENT/git"
(cd "$PARENT_GIT/deluge" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/calibre" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/hydrus" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/kdeconnect-kde" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/keepassxc" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/liferea" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/mpd" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/mpv" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/quassel" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/syncthing" && git remote update && git fetch --all && git reset --hard origin/main)
(cd "$PARENT_GIT/syncthing-android" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/trackma" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/bibanon" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/deemix" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/deemix-pyweb" && git remote update && git fetch --all && git reset --hard origin/master)
(cd "$PARENT_GIT/deemix-webui" && git remote update && git fetch --all && git reset --hard origin/master)

46
home/default/scripts/booksplit Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh
# Requires ffmpeg (audio splitting) and my `tag` wrapper script.
[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit
echo "Enter the album/book title:"; read -r booktitle
echo "Enter the artist/author:"; read -r author
echo "Enter the publication year:"; read -r year
inputaudio="$1"
# Get a safe file name from the book.
#escbook="$(echo "$booktitle" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
escbook="$(echo "$booktitle" | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
! mkdir -p "$escbook" && echo "Do you have write access in this directory?" && exit 1
# As long as the extension is in the tag script, it'll work.
ext="opus"
#ext="${1#*.}"
# Get the total number of tracks from the number of lines.
total="$(wc -l < "$2")"
while read -r x;
do
end="$(echo "$x" | cut -d' ' -f1)"
[ -n "$start" ] &&
echo "From $start to $end; $track $title"
file="$escbook/$(printf "%.2d" "$track") - $author - $esctitle.$ext"
[ -n "$start" ] && echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn "$file" &&
echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
title="$(echo "$x" | cut -d' ' -f 2-)"
# esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
esctitle="$(echo "$title" | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
track="$((track+1))"
start="$end"
done < "$2"
# The last track must be done outside the loop.
echo "From $start to the end: $title"
file="$escbook/$track - $author - $esctitle.$ext"
echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn "$file" &&
echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"

View File

@ -0,0 +1,3 @@
#!/usr/bin/env sh
find . -type f -iregex ".*\.\(mp3\|opus\|flac\|aac\)" | sort > playlist.m3u

View File

@ -0,0 +1,3 @@
#/usr/bin/env bash
set -v #echo on
find . -type d -name '__MACOSX' -print -exec rm -rf {} \;

View File

@ -0,0 +1,68 @@
#!/usr/bin/env sh
set -ou pipefail
# Generates playlists for all mp3 and flac files in a directory, ignoring itself in the "parent" folder
PLAYLIST_FOLDER="/home/default/Music/playlists/mpd" # Playlist folder for mpd
PREFIX="music/playlists" # relative links to add to playlists, based on mpd virtual file structure
EXTENSIONS=("mp3" "opus" "flac" "m4a" "mkv" "webm")
# Disable nullglob and set pattern matching to fix spaces
shopt -s nullglob
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
cd $PLAYLIST_FOLDER || { echo "Could not cd into PLAYLIST_FOLDER"; exit 1; }
parent=`basename $PWD`
# Delete old generated playlists
if [[ -f "*.gen.m3u" ]]; then
rm *.gen.m3u
fi
if [[ -f ".trackNames" ]]; then
rm .trackNames
fi
# For all playlist directories to generate
for playlistDir in ../*; do
if [[ -d "$playlistDir" ]] && [[ "$playlistDir" != "../$parent" ]]; then
# playlist filename needed for mpd
playlist=`echo "$playlistDir" | sed "s/^\.\.\///g"`
# escaped version of filename needed for bash
escaped=`printf '%q\n' "$playlist"`
# echo "playlist=$playlist"
# echo "escaped=$escaped"
# touch file
> "$playlist.gen.m3u"
# write all files with newlines
> .track-names
for EXT in ${EXTENSIONS[@]}; do
# echo `find "../$playlist" -mindepth 1 -type f -name "*.$EXT" -printf x | wc -c`
if [[ `find "../$playlist" -mindepth 1 -type f -name "*.$EXT" -printf x | wc -c` != 0 ]]; then
ls -1 ../$escaped/*.$EXT >> .track-names 2> /dev/null
# echo `ls -1 ../$playlist/*.$EXT >> 2> /dev/null`
fi
done
# echo `cat .track-names`
cat .track-names | while IFS="" read -r song || [ -n "$song" ] ; do
unprefixed=`echo "$song" | sed "s/^\.\.\///g"`
# echo "$PREFIX/$unprefixed"
echo "$PREFIX/$unprefixed" >> "$playlist.gen.m3u"
done < .track-names
if [[ -f ".track-names" ]]; then
rm .track-names
fi
fi
done
# Use mpc to update mpd database
update-mpd > /dev/null
restart-music
IFS=$SAVEIFS

View File

@ -0,0 +1 @@
git log --all --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative -n 20

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -eou pipefail
read -rep $'Do you want to rename all files in this dir to their hash? [Y/n] \n> ' -n 1 REPLY
REPLY=${REPLY:-Y}
if [[ $REPLY =~ ^[Yy]$ ]]
then
for file in *; do
if [[ -f "./$file" ]]; then
sum=$(echo -n "$file" | md5sum)
echo "$file --> ${sum%% *}.${file##*.}"
mv "$file" "${sum%% *}.${file##*.}"
fi
done
fi

View File

@ -0,0 +1,6 @@
#!/bin/bash
set -eou pipefail
echo $(pacman -Qqn) $(pacman -Qqm) | \
tr " " "\n" | \
sort

View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo pipefail
for i in *.mp3; do ffmpeg -i "$i" -c:a libopus "${i%.*}.opus"; done
trash *.mp3

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -eou pipefail
echo $(pacman -Qqn) $(pacman -Qqm) | \
tr " " "\n" | \
sort

12
home/default/scripts/phoenix Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
while [ 1 ]
do
ping -c5 https://google.com
if [ $? -eq 0]; then
echo Ping check ok, waiting...
else
poweroff
fi
done

3
home/default/scripts/proverb Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
clear
fortune | cowsay -W 70

View File

@ -0,0 +1,30 @@
#!/usr/bin/env sh
# rename .JPG -> .jpg
count=`ls -1 *.JPG 2>/dev/null | wc -l`
if [ $count != 0 ]; then
rename JPG jpg *.JPG
fi
# remove exif except orientation from .jpg
count=`ls -1 *.jpg 2>/dev/null | wc -l`
if [ $count != 0 ]; then
for i in *.jpg; do
exiftool -all= -overwrite_original -tagsfromfile @ -Orientation "$i"
done
fi
# rename .PNG -> .png
count=`ls -1 *.PNG 2>/dev/null | wc -l`
if [ $count != 0 ]; then
rename PNG png *.PNG
fi
# remove exif except orientation from .png
count=`ls -1 *.png 2>/dev/null | wc -l`
if [ $count != 0 ]; then
for i in *.png; do
exiftool -all= -overwrite_original -tagsfromfile @ -Orientation "$i"
done
fi

View File

@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euo pipefail
CANTATA_RUNNING=0
if pgrep -f cantata &>/dev/null 2>&1; then
echo killing cantata...
CANTATA_RUNNING=1
pkill -f cantata
fi
# echo stopping pipewire-media-session...
# systemctl --user stop pipewire-media-session
echo stopping pipewire...
systemctl --user stop pipewire
echo starting pipewire...
systemctl --user start pipewire
# echo starting pipewire-media-session...
# systemctl --user start pipewire-media-session
echo stopping mpDris2...
systemctl --user stop mpd-mpris
echo stopping mpd...
systemctl --user stop mpd
echo starting mpd...
systemctl --user start mpd
echo starting mpDris2...
systemctl --user start mpd-mpris
if [[ $CANTATA_RUNNING == 1 ]]; then
echo starting cantata...
cantata& &>/dev/null
fi

View File

@ -0,0 +1,6 @@
#!/bin/sh
# Take a screenshot
dir=~/Downloads/temp
(cd $dir && grim -g "$(slurp)")
xdg-open $dir

16
home/default/scripts/scrub-ufw Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
echo "Stopping firewall and allowing everyone..."
ipt="/usr/bin/iptables"
## Failsafe - die if /sbin/iptables not found
[ ! -x "$ipt" ] && { echo "$0: \"${ipt}\" command not found."; exit 1; }
$ipt -P INPUT ACCEPT
$ipt -P FORWARD ACCEPT
$ipt -P OUTPUT ACCEPT
$ipt -F
$ipt -X
$ipt -t nat -F
$ipt -t nat -X
$ipt -t mangle -F
$ipt -t mangle -X
$ipt iptables -t raw -F
$ipt -t raw -X

View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -euo pipefail
cat input.txt | awk '{ print length, $0 }' | sort -n | cut -d" " -f2-

59
home/default/scripts/tag Executable file
View File

@ -0,0 +1,59 @@
#!/bin/sh
err() { echo "Usage:
tag [OPTIONS] file
Options:
-a: artist/author
-t: song/chapter title
-A: album/book title
-n: track/chapter number
-N: total number of tracks/chapters
-d: year of publication
-g: genre
-c: comment
You will be prompted for title, artist, album and track if not given." && exit 1 ;}
while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
a) artist="${OPTARG}" ;;
t) title="${OPTARG}" ;;
A) album="${OPTARG}" ;;
n) track="${OPTARG}" ;;
N) total="${OPTARG}" ;;
d) date="${OPTARG}" ;;
g) genre="${OPTARG}" ;;
c) comment="${OPTARG}" ;;
f) file="${OPTARG}" ;;
*) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
esac done
shift $((OPTIND - 1))
file="$1"
[ ! -f "$file" ] && echo "Provide file to tag." && err
[ -z "$title" ] && echo "Enter a title." && read -r title
[ -z "$artist" ] && echo "Enter an artist." && read -r artist
[ -z "$album" ] && echo "Enter an album." && read -r album
[ -z "$track" ] && echo "Enter a track number." && read -r track
case "$file" in
*.ogg) echo "Title=$title
Artist=$artist
Album=$album
Track=$track
Total=$total
Date=$date
Genre=$genre
Comment=$comment" | vorbiscomment -w "$file" ;;
*.opus) echo "Title=$title
Artist=$artist
Album=$album
Track=$track
Total=$total
Date=$date
Genre=$genre
Comment=$comment" | opustags -i -S "$file" ;;
*.mp3) eyeD3 -Q --remove-all -a "$artist" -A "$album" -t "$title" -n "$track" -N "$total" -Y "$date" "$file" ;;
*) echo "File type not implemented yet." ;;
esac

View File

@ -0,0 +1,37 @@
#!/bin/python
# From https://webapps.stackexchange.com/questions/72787/how-to-create-a-youtube-playlist-from-a-list-of-links
# Only adds youtube links!
import os, io
import webbrowser
import urllib.request, urllib.error, urllib.parse
inputFileName = 'titles.txt'
def ReadMultipleDataFrom(thisTextFile, thisPattern):
inputData = []
file = open(thisTextFile, "r")
for iLine in file:
if iLine.startswith(thisPattern):
iLine = iLine.rstrip()
# print(iLine)
if ('v=') in iLine: # https://www.youtube.com/watch?v=aBcDeFGH
iLink = iLine.split('v=')[1]
iLink = iLink.split('&')[0]
inputData.append(iLink)
# print(iLink)
if ('be/') in iLine: # https://youtu.be/aBcDeFGH
iLink = iLine.split('be/')[1]
iLink = iLink.split('&')[0]
inputData.append(iLink)
# print(iLink)
return inputData
videoLinks = ReadMultipleDataFrom(inputFileName, "https")
listOfVideos = "http://www.youtube.com/watch_videos?video_ids=" + ','.join(videoLinks)
response = urllib.request.urlopen(listOfVideos)
playListLink = response.geturl()
playListLink = playListLink.split('list=')[1]
playListURL = "https://www.youtube.com/playlist?list="+playListLink+"&disable_polymer=true"
webbrowser.open(playListURL)

View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -eoux pipefail
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup
sed -i 's/^#Server/Server/' /etc/pacman.d/mirrorlist.backup
rankmirrors -n 20 /etc/pacman.d/mirrorlist.backup > /etc/pacman.d/mirrorlist

View File

@ -0,0 +1,5 @@
#!/bin/sh
set -eoux pipefail
# uses mpc to manually trigger a mpd update
mpc -h localhost -p 6600 --password update

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -eoux pipefail
yay -Syu \
--ignore=linux \
--ignore=linux-headers \
--ignore=nvidia \
--ignore=nvidia-utils

View File

@ -0,0 +1,8 @@
#!/bin/bash
# Appends the title of a URL in the format of
# "# Title\nURL\n\n"
while read -r URL; do
TITLE=`curl -L "$URL" | grep -o "<title>.*</title>" | sed -E "s/<title>(.*)<\/title>/\1/"`
printf "# $TITLE\n$URL\n\n"
done

View File

@ -0,0 +1,17 @@
#!/usr/bin/env sh
set -eou pipefail
# --write-description \
# --write-info-json \
# --write-annotations \
# --write-all-thumbnails \
# --write-auto-sub \
youtube-dl \
--ignore-errors \
--geo-bypass \
--sub-lang en --embed-subs \
--output "%(title)s.%(ext)s" \
--add-metadata \
--embed-thumbnail \
--download-archive downloaded.txt \
-a -

View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -eou pipefail
# --write-description \
# --write-info-json \
# --write-annotations \
# --write-all-thumbnails \
# --embed-thumbnail \
# --write-auto-sub \
# --audio-format opus \
youtube-dl \
--ignore-errors \
--geo-bypass \
--sub-lang en --embed-subs \
--extract-audio \
--no-post-overwrites \
--output "%(title)s.%(ext)s" \
--add-metadata \
--download-archive downloaded.txt \
-a -

View File

@ -0,0 +1,12 @@
#!/bin/sh
# --embed-thumbnail \
# --audio-format opus \
youtube-dl \
--ignore-errors \
-f bestaudio \
--rm-cache-dir \
--extract-audio \
--output "%(title)s.%(ext)s" --add-metadata \
--download-archive downloaded.txt \
-a -