#!/bin/bash
lsla() {
	if [[ $1 != "" ]]; then
		ls -la --color=auto "$1"
	else
		ls -la --color=auto
	fi
}

# hey man, just use zoxide
# pacman -S zoxide fzf

## Applications and Scripts
trizen_clean() {
	trizen -Rcns $(pacman -Qqdt)
}

ssgpg() {
	python3 ~/.scripts/ssgpg
}

compose-restart() {
	docker compose down --remove-orphans && docker compose up -d || return
}

home-server() {
	ssh home-server || return
}

laptop-server() {
	ssh laptop-server || return
}

pg-home() {
	psql -h rpsdb.devdoes.work -p 7481 -U rps_admin rps_dev
}

localpostgres() {
	sudo -u postgres psql
}

openssl-rand() {
	openssl rand -base64 32
}

email-server() {
	ssh hetzner-mail
	echo "http://localhost:8080"
}

repeat-command() {
	if [ $# -eq "0" ]; then
		return
	else
		while true; do
			"$@"
			sleep 1
		done
	fi
}

testspeaker() {
	speaker-test -t wav -c 6 || return
}

random-port-generator() {
	shuf -i 1-25565 -n 1 || return
}

clear_space() {
	sudo paccache -r
	sudo paccache -rk1
	trizen -Scc
	npm cache verify
}

findx86keys() {
	xkbcli interactive-wayland
}

find-biggest-dirs() {
	du -sx * 2>/dev/null | sort -n
}

find-current-biggest-files() {
	du -aBM 2>/dev/null | sort -nr | head -n 10
}

docker-kill-stopped() {
	docker rm $(docker ps --filter status=exited -q)
}

mp3-download() {
	# Based by cmd: `yt-dlp -x --audio-format mp3 -i https://www.youtube.com/playlist?list=PLjB_8hSS2lEMY-ap4zdPv0-mbTwxtN7KW`
	# If there is no argument...
	if [ $# -eq "0" ]; then
		echo "(Could be a video or playlist)"
		read -rp "Youtube Link To Download: " link

		yt-dlp -x --audio-format mp3 -i "$link"

	elif [ -f "$1" ]; then
		yt-dlp -x --audio-format mp3 -a "$1"

	else
		yt-dlp -x --audio-format mp3 -i "$1"
	fi
}

reset-nvim() {
	rm -rf ~/.local/state/nvim
	rm -rf ~/.local/share/nvim
	#rm -rf ~/.config/nvim
}

pivpn() {
	INTERFACES=$(ip link show)
	if [[ $INTERFACES =~ "pi-vpn" ]]; then
		sudo wg-quick down pi-vpn
	else
		sudo wg-quick up pi-vpn
	fi
}

homevpn() {
	INTERFACES=$(ip link show)
	if [[ $INTERFACES =~ "home-vpn" ]]; then
		sudo wg-quick down home-vpn
	else
		sudo wg-quick up home-vpn
	fi
}

hibernate() {
	sudo bash -c "echo -n 'mem' > /sys/power/state"
}

# Aliases
## Color Completion
alias grep="grep --color=auto"
alias ip="ip -c"
alias ls="ls --color=auto"
alias py="python3"
alias ssh="kitty +kitten ssh"
## Extra
