diff --git a/home/home.nix b/home/home.nix index cda6719..3608d2d 100644 --- a/home/home.nix +++ b/home/home.nix @@ -37,6 +37,11 @@ in { home.packages = with pkgs; [ # any other packages go here + # xrandr + xorg.xrandr + bspwm + yt-dlp + beets ] ++ ( with lib; let diff --git a/home/nixos-rebuild.sh b/home/nixos-rebuild.sh index 74561d9..9c63e97 100644 --- a/home/nixos-rebuild.sh +++ b/home/nixos-rebuild.sh @@ -14,6 +14,8 @@ if git --git-dir /home/synchronous/nix-cfg/.git diff-index --quiet HEAD; then exit 0 fi +nix flake check /home/synchronous/nix-cfg/ + # Autoformat your nix files alejandra . &>/dev/null \ || ( alejandra . ; echo "formatting failed!" && exit 1) diff --git a/home/programs/zsh/zshrc b/home/programs/zsh/zshrc index 23725c8..d0c80a4 100644 --- a/home/programs/zsh/zshrc +++ b/home/programs/zsh/zshrc @@ -161,7 +161,7 @@ alias polybar-restart='pkill polybar; setsid polybar mybar > /dev/null 2> /dev/n # alias ytdl='alias ytdl="youtube-dl --extract-audio --audio-format mp3 --output "downloads/%(title)s.%(ext)s"' # alias ytdl="yt-dlp --extract-audio --audio-format mp3 --output " # alias ytdl="yt-dlp --extract-audio --audio-format mp3 --output '/home/synchronous/.music-not-tagged/%(title)s.%(ext)s'" -alias ytdl="sh /home/synchronous/.scripts/music/ytdl.sh" +# alias ytdl="sh /home/synchronous/.scripts/music/ytdl.sh" alias ytdl-mp3="yt-dlp -x --audio-format mp3 --audio-quality 0 -o '/home/synchronous/music/%(title)s.%(ext)s' " alias phone-mount="sh /home/synchronous/.scripts/phone-mount/mount.sh" @@ -169,16 +169,16 @@ alias phone-unmount="sh /home/synchronous/.scripts/phone-mount/unmount.sh" alias music-move="sh /home/synchronous/.scripts/music/music-move.sh" alias ntpsync="sudo ntpdate pool.ntp.org" -alias fb="cd /home/synchronous/code/tob/fb" +# alias fb="cd /home/synchronous/code/tob/fb" alias nuid="echo 002141542" -alias gb="sh /home/synchronous/.scripts/bluetooth/gb.sh" +# alias gb="sh /home/synchronous/.scripts/bluetooth/gb.sh" alias gbdc="bluetoothctl disconnect" # alias sxhkdrc="vim /home/synchronous/.config/sxhkd/sxhkdrc" # alias bspwmrc="vim /home/synchronous/.config/bspwm/bspwmrc" # monitor stuff -alias dupe-display="sh /home/synchronous/.scripts/bspwm/dupe-display.sh" -alias undo-dupe="sh /home/synchronous/.scripts/bspwm/reset-duplicate.sh" +# alias dupe-display="sh /home/synchronous/.scripts/bspwm/dupe-display.sh" +# alias undo-dupe="sh /home/synchronous/.scripts/bspwm/reset-duplicate.sh" # termbin # alias termbin="sh /home/synchronous/.scripts/termbin/tb.sh" diff --git a/home/scripts/bluetooth/gb.sh b/home/scripts/bluetooth/gb.sh new file mode 100644 index 0000000..d4546f0 --- /dev/null +++ b/home/scripts/bluetooth/gb.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +if [[ $(bluetoothctl devices) == "No default controller available" ]]; then + echo "click the bluetooth button lol" + exit 1 +fi + +# if we are not connected to gb, try to connect +if bluetoothctl info | grep -q "Missing device address argument"; then + bluetoothctl connect F8:8F:07:E1:FA:A7 > /dev/null + exit 1 +fi + +echo "already connected to:" +bluetoothctl info | grep "Name" | cut -d ' ' -f 2- diff --git a/home/scripts/bspwm/dupe-display.sh b/home/scripts/bspwm/dupe-display.sh new file mode 100644 index 0000000..760b691 --- /dev/null +++ b/home/scripts/bspwm/dupe-display.sh @@ -0,0 +1,5 @@ +#!/bin/bash +xrandr --output HDMI-2 --mode 1920x1080 --same-as eDP-1 --scale 1x1 +bspc desktop Desktop --remove +bspc wm -r +bspc desktop Desktop --remove diff --git a/home/scripts/bspwm/fast-shift.sh b/home/scripts/bspwm/fast-shift.sh new file mode 100644 index 0000000..637f93a --- /dev/null +++ b/home/scripts/bspwm/fast-shift.sh @@ -0,0 +1,40 @@ +#!/bin/bash +shift="$1" +current=$(bspc query -D -d --names) +#echo "$(($current + 1))" +if [[ "$shift" == "left" ]]; then + iter=$(expr $current - 1) + if [[ "$iter" == 0 ]]; then + iter="20" + fi + while [[ "$iter" != "$current" ]] + do + if [[ "$(bspc query -N -d $iter)" != "" ]]; then + bspc desktop -f "$iter" + exit 0 + fi + iter=$(expr $iter - 1) + if [[ "$iter" == 0 ]]; then + iter="20" + fi + done + +elif [[ "$shift" == "right" ]]; then + iter=$(expr $current + 1) + if [[ "$iter" == 21 ]]; then + iter="1" + fi + while [[ "$iter" != "$current" ]] + do + if [[ "$(bspc query -N -d $iter)" != "" ]]; then + bspc desktop -f "$iter" + exit 0 + fi + iter=$(expr $iter + 1) + if [[ "$iter" == 21 ]]; then + iter="1" + fi + done +else + echo "incorrect arguments. sorry!" +fi diff --git a/home/scripts/bspwm/reset-duplicate.sh b/home/scripts/bspwm/reset-duplicate.sh new file mode 100644 index 0000000..8828c9c --- /dev/null +++ b/home/scripts/bspwm/reset-duplicate.sh @@ -0,0 +1,8 @@ +#!/bin/bash +xrandr --output HDMI-1 --off +xrandr --output HDMI-2 --off +xrandr --output eDP-1 --mode 1920x1080 --primary +bspc desktop Desktop --remove +bspc monitor HDMI-1 -r +bspc monitor HDMI-2 -r +bspc wm -r diff --git a/home/scripts/bspwm/swap-desktop.sh b/home/scripts/bspwm/swap-desktop.sh new file mode 100644 index 0000000..7a22231 --- /dev/null +++ b/home/scripts/bspwm/swap-desktop.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# swaps the current desktop with selected +shift="$1" +current=$(bspc query -D -d --names) + +# if same, exit +[[ $shift == $current ]] && exit 1 + +bspc desktop $shift -n t +bspc desktop $current -s t +bspc desktop $current -n $shift +bspc desktop t -n $current diff --git a/home/scripts/music/ytdl.sh b/home/scripts/music/ytdl.sh new file mode 100644 index 0000000..b87ca73 --- /dev/null +++ b/home/scripts/music/ytdl.sh @@ -0,0 +1,98 @@ +#!/bin/sh + +usage() { + echo "Usage: ./ytdl [URL] [options]" + echo "Download an mp3 from a given URL, process it, and optionally move it to the music directory." + echo "" + echo "Options:" + echo " -h, --help Show this help message and exit." + echo " -na --no-auto Does not automatically click thru." +} + +# Check if '-h' or '--help' flags are passed +if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$2" = "-h" ] || [ "$2" = "--help" ]; then + usage + exit 0 +fi + +# Ensure a URL is provided +if [ -z "$1" ]; then + echo "Error: No URL provided." + exit 1 +fi + +rm /home/synchronous/.music-not-tagged/tmp.mp3 + +url="$1" + +# Download and extract audio +if ! yt-dlp --extract-audio --audio-format mp3 --output '/home/synchronous/.music-not-tagged/tmp.mp3' "$url"; then + echo "Error downloading or extracting audio." + exit 1 +fi + +# Import into beets + +if [ "$2" = "-na" ] || [ "$2" = "--no-auto" ]; then + if ! /usr/bin/beet import -s /home/synchronous/.music-not-tagged/tmp.mp3; then + echo "Error importing into beets." + exit 1 + fi +else + if ! /usr/bin/beet import -s /home/synchronous/.music-not-tagged/tmp.mp3 <<< "A"; then + echo "Error importing into beets." + exit 1 + fi +fi + + +# Remove all entries from beets +if ! /usr/bin/beet ls | /usr/bin/beet remove -f; then + echo "Error removing entries from beets." + exit 1 +fi + +# Extract title and artist +title=$(ffprobe -show_format -v error /home/synchronous/.music-not-tagged/tmp.mp3 | grep -m 1 'TAG:title' | cut -d= -f2) +artist=$(ffprobe -show_format -v error /home/synchronous/.music-not-tagged/tmp.mp3 | grep -m 1 'TAG:artist' | cut -d= -f2) + +# Ensure title and artist were extracted successfully +if [ -z "$title" ] || [ -z "$artist" ]; then + echo "Error extracting title or artist." + exit 1 +fi + +echo "\n" + +# Echo title and artist +echo "$artist" +echo "$title" + + +# ... + +# Construct new filename +t="$artist - $title" +destination="/home/synchronous/music/$t.mp3" + +# Check if file already exists +if [ -f "$destination" ]; then + echo "Error: A file with the same name already exists." + exit 1 +fi + +# Ask user for confirmation +echo "Would you like to continue and move the file into the music directory? (y/n)" +read -r confirmation + +# Exit if user doesn't confirm +if [ "$confirmation" != "y" ]; then + echo "Operation aborted by the user." + exit 1 +fi + +# Move the file +if ! mv /home/synchronous/.music-not-tagged/tmp.mp3 "$destination"; then + echo "Error moving the file." + exit 1 +fi diff --git a/home/scripts/tb.sh b/home/scripts/tb.sh deleted file mode 100644 index f58d5a5..0000000 --- a/home/scripts/tb.sh +++ /dev/null @@ -1,2 +0,0 @@ -file=$1 -cat "$1" | nc termbin.com 9999 diff --git a/home/scripts/test/lol b/home/scripts/test/lol deleted file mode 100644 index 0898bf4..0000000 --- a/home/scripts/test/lol +++ /dev/null @@ -1 +0,0 @@ -XD diff --git a/home/scripts/test/tbq.sh b/home/scripts/test/tbq.sh deleted file mode 100644 index f58d5a5..0000000 --- a/home/scripts/test/tbq.sh +++ /dev/null @@ -1,2 +0,0 @@ -file=$1 -cat "$1" | nc termbin.com 9999