This commit is contained in:
Errol Sancaktar 2024-08-19 14:18:27 -06:00
parent 22f12f851c
commit a04d9594f3
5 changed files with 132 additions and 9 deletions

View File

@ -51,7 +51,7 @@ declare -A alias_list=(
# SPOTIFY
[spo]'spotify_player'
[spo]='spotify_player'
)

View File

@ -252,7 +252,7 @@
"timelapse": "1"
},
"recent": {
"last_opened_folder": "/home/errol/Downloads/3D Prints/Toolbox",
"last_opened_folder": "/home/errol/Downloads/3D Prints/Gridfinity",
"printhost_path": "",
"settings_folder": "/home/errol/Downloads/3D Prints/Toolbox"
},

View File

@ -14,10 +14,10 @@ bind \; command-prompt
# Set ZSH
set -g default-shell /bin/zsh
bind -r j resize-pane -D 5
bind -r k resize-pane -U 5
bind -r h resize-pane -L 5
bind -r l resize-pane -R 5
bind -r C-Down resize-pane -D 5
bind -r C-Up resize-pane -U 5
bind -r C-Left resize-pane -L 5
bind -r C-Right resize-pane -R 5
bind -r m resize-pane -Z
@ -50,12 +50,12 @@ bind-key "_" split-window -fv -c "#{pane_current_path}"
bind j choose-window 'join-pane -h -s "%%"'
bind J choose-window 'join-pane -s "%%"'
bind END kill-pane # Kill active pane
bind Bspace kill-window # Kill Active Window
bind END kill-window # Kill active window
bind Space kill-pane # Kill Active pane
bind c new-window -c "#{pane_current_path}" # Keep Path
bind Space last-window
bind -n C-Space last-window
bind - split-window -v
@ -109,7 +109,11 @@ bind -n S-Pagedown send-keys S-Pagedown
set -g status-right '#[fg=white]#(hostname)@#(host `hostname` | cut -d " " -f 4)'
# SPOTIFY
unbind s
bind s run-shell '~/.tmux/spotify_tmux.sh'
bind + run-shell '~/.tmux/spotify_tmux.sh n'
# PLUGIN Management
@ -138,6 +142,7 @@ set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'xamut/tmux-spotify
run-shell "~/.tmux/plugins/tmux-spotify/tmux-spotify.tmux"
# initialize tmux plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
run-shell '~/.tmux/plugins/tpm/tpm'

0
tmux/.tmux/0 Normal file
View File

118
tmux/.tmux/spotify-tmux.sh Executable file
View File

@ -0,0 +1,118 @@
#!/bin/bash
#CURRENT_WINDOW=$(tmux display-message -p '#I')
#WINDOW=$(tmux display-message -p '#W')
TARGET_NAME='spotify'
TARGET_COMMAND='spotify_player'
LIMIT=1000
VOLUME=65
SPOTIFY_PID=0
POSITION=$(tmux list-windows | awk -v name="$TARGET_NAME" '$0 ~ name {print $1}' | awk -F: '{print $1}')
echo "setting VOlume"
fi
exit 1
check_deps() {
if $("which $TARGET_COMMAND" 2>/dev/null); then
if $(which tmux 2>/dev/null); then
echo 1
else
echo 0
fi
fi
}
display() {
echo "$1"
tmux display-message "$1"
}
check_running() {
local output
output=$("$TARGET_COMMAND" get key playback)
if [ "$output" = "null" ]; then
echo 0
else
echo 1
SPOTIFY_PID=$(pidof spotify_player)
fi
}
get_volume() {
local volume
volume=$("$TARGET_COMMAND" get key playback 2>/dev/null | jq -r '.device.volume_percent')
if test -n "$volume"; then
echo $volume
else
display "Spotify Not Running"
fi
}
set_volume() {
local volume
volume=get_volume
if "$volume" != "$VOLUME"; then
$TARGET_COMMAND playback volume $VOLUME
fi
}
check_deps
check_running >/dev/null
if [ "$#" -lt 1 ]; then
if [ $SPOTIFY_PID != 0 ]; then
display "Spotify Already Running"
exit 12
fi
if [ -n "$POSITION" ] && [ "$POSITION" -ne 1 ]; then
tmux swap-window -s $TARGET_NAME -t 1
elif
[ -n "$POSITION" ] && [ "$POSITION" -eq 1 ]
then
tmux select-window -t $TARGET_NAME
else
display "Starting Spotify"
tmux new-window -n $TARGET_NAME $TARGET_COMMAND &&
tmux swap-window -s $TARGET_NAME -t 1
display "Window Ready"
echo check_running
until [ "$(check_running)" = "1" ]; do
display "Waiting for Spotify"
sleep 1
done
display "Starting Liked Playlist"
$TARGET_COMMAND playback start liked -r --limit=$LIMIT
until [ "$(get_volume)" != "Spotify Not Running" ]; do
display "Checking Initial Volume"
sleep 1
done
display "Checking Volume"
current_volume="$(get_volume)"
if [ "$current_volume" != "$VOLUME" ]; then
display $current_volume
$($TARGET_COMMAND playback volume $VOLUME)
fi
fi
else
if [ "$(check_running)" = "0" ]; then
display "Spotify Is Not Running"
exit 0
fi
case "$1" in
n)
$TARGET_COMMAND playback next
;;
p)
$TARGET_COMMAND playback previous
;;
s)
$TARGET_COMMAND playback play-pause
;;
v)
$TARGET_COMMAND playback volume $VOLUME
;;
*)
echo "Usage: $0 [n|p|s]"
exit 1
;;
esac
fi