feat: switch to spot instead of official spotify client

This commit is contained in:
matt1432 2023-08-20 14:26:47 -04:00
parent 74d5373d48
commit 914a6950e3
5 changed files with 25 additions and 24 deletions

View file

@ -1,13 +1,13 @@
(defpoll player :interval "1s" "echo spotify") (defpoll player :interval "1s" "echo Spot")
(defpoll music_cover :interval "1s" "$EWW_PATH/music.sh cover") ;done (defpoll music_cover :interval "1s" "$EWW_PATH/music.sh cover") ;done
(defvar music_accent "rgb(0,0,0)") ;done (defvar music_accent "rgb(0,0,0)") ;done
(defvar button_accent "rgb(0,0,0)") ;done (defvar button_accent "rgb(0,0,0)") ;done
(defvar button_text "rgb(255,255,255)") ;done (defvar button_text "rgb(255,255,255)") ;done
(defpoll music_status :interval "1s" "playerctl -p spotify status") (defpoll music_status :interval "1s" "playerctl -p Spot status")
(defpoll title :interval "1s" "playerctl -p spotify metadata title") (defpoll title :interval "1s" "playerctl -p Spot metadata title")
(defpoll artist :interval "1s" "playerctl -p spotify metadata artist") (defpoll artist :interval "1s" "playerctl -p Spot metadata artist")
(defvar button_height "42") (defvar button_height "42")
(defpoll shuffle_status :interval "1s" "playerctl -p spotify shuffle") (defpoll shuffle_status :interval "1s" "playerctl -p Spot shuffle")
(defpoll repeat_icon :interval "1s" "$EWW_PATH/music.sh loop_status") (defpoll repeat_icon :interval "1s" "$EWW_PATH/music.sh loop_status")
(defvar song_pos "0") (defvar song_pos "0")
(defpoll song_length :interval "1s" "$EWW_PATH/music.sh length") (defpoll song_length :interval "1s" "$EWW_PATH/music.sh length")
@ -23,7 +23,7 @@
:halign "start" :halign "start"
:valign "start" :valign "start"
:style "color: ${button_accent};" :style "color: ${button_accent};"
"${player == 'spotify' ? '' : '爵' }" "${player == 'Spot' ? '' : '爵' }"
) )
(box :class "center" (box :class "center"
:orientation "h" :orientation "h"
@ -42,7 +42,7 @@
:halign "left" :halign "left"
:style "background-color: ${button_accent}; :style "background-color: ${button_accent};
color: ${button_text};" color: ${button_text};"
:onclick "playerctl -p spotify play-pause" :onclick "playerctl -p Spot play-pause"
:cursor "pointer" :cursor "pointer"
:onhover "eww update button_height=41" :onhover "eww update button_height=41"
:onhoverlost "eww update button_height=42" :onhoverlost "eww update button_height=42"
@ -61,7 +61,7 @@
:spacing 0 :spacing 0
(eventbox :valign "end" (eventbox :valign "end"
:halign "start" :halign "start"
:onclick "playerctl -p spotify previous & $EWW_PATH/music.sh cover" :onclick "playerctl -p Spot previous & $EWW_PATH/music.sh cover"
:class "previousbutton" :class "previousbutton"
:width 40 :width 40
:cursor "pointer" :cursor "pointer"
@ -76,7 +76,7 @@
:min 0 :min 0
:max song_length :max song_length
:orientation "h" :orientation "h"
:onchange "playerctl -p spotify position {}" :onchange "playerctl -p Spot position {}"
:css "highlight { background-color: ${button_accent}; } :css "highlight { background-color: ${button_accent}; }
slider { background-color: ${button_accent}; } slider { background-color: ${button_accent}; }
trough { background-color: rgba(${button_accent}, 0.4); }" trough { background-color: rgba(${button_accent}, 0.4); }"
@ -85,13 +85,13 @@
(box :valign "end" (box :valign "end"
:halign "end" :halign "end"
(eventbox :onclick "playerctl -p spotify next & $EWW_PATH/music.sh cover" (eventbox :onclick "playerctl -p Spot next & $EWW_PATH/music.sh cover"
:class "nextbutton" :class "nextbutton"
:width 40 :width 40
:cursor "pointer" :cursor "pointer"
"󰒭" "󰒭"
) )
(eventbox :onclick "playerctl -p spotify shuffle toggle" (eventbox :onclick "playerctl -p Spot shuffle toggle"
:class "shuffle" :class "shuffle"
:width 40 :width 40
:cursor "pointer" :cursor "pointer"

View file

@ -1,19 +1,19 @@
#!/usr/bin/env bash #!/usr/bin/env bash
loop() { loop() {
loop_status=$(playerctl -p spotify loop) loop_status=$(playerctl -p Spot loop)
case $loop_status in case $loop_status in
"None" ) "None" )
playerctl -p spotify loop Playlist playerctl -p Spot loop Playlist
eww update repeat_icon="󰑖" eww update repeat_icon="󰑖"
;; ;;
"Track" ) "Track" )
playerctl -p spotify loop None playerctl -p Spot loop None
eww update repeat_icon="󰑗" eww update repeat_icon="󰑗"
;; ;;
"Playlist" ) "Playlist" )
playerctl -p spotify loop Track playerctl -p Spot loop Track
eww update repeat_icon="󰑘" eww update repeat_icon="󰑘"
;; ;;
* ) * )
@ -23,7 +23,7 @@ loop() {
} }
loop_status() { loop_status() {
loop_status=$(playerctl -p spotify loop) loop_status=$(playerctl -p Spot loop)
case $loop_status in case $loop_status in
"None" ) "None" )
@ -43,9 +43,9 @@ loop_status() {
get_length() { get_length() {
if [[ $(eww get get_pos) == "true" ]]; then if [[ $(eww get get_pos) == "true" ]]; then
eww update song_pos="$(playerctl -p spotify position)" eww update song_pos="$(playerctl -p Spot position)"
fi fi
eww update song_length="$(echo "$(playerctl -p spotify metadata mpris:length)/1000000" | bc -l)" eww update song_length="$(echo "$(playerctl -p Spot metadata mpris:length)/1000000" | bc -l)"
} }
get_accents() { get_accents() {
@ -62,7 +62,7 @@ get_accents() {
get_cover() { get_cover() {
existing_file="/tmp/cover.jpg" existing_file="/tmp/cover.jpg"
new_image_url=$(playerctl -p spotify metadata mpris:artUrl) new_image_url=$(playerctl -p Spot metadata mpris:artUrl)
existing_hash=$(md5sum "$existing_file" | awk '{print $1}') existing_hash=$(md5sum "$existing_file" | awk '{print $1}')
# Download the new image only if the hashes are different # Download the new image only if the hashes are different

View file

@ -14,10 +14,9 @@ function run() {
sleep 0.1 sleep 0.1
input-emulator mouse button left input-emulator mouse button left
fi fi
echo "cant_run" > "$FILE" exit 0
} }
while IFS='$\n' read -r line; do while IFS='$\n' read -r line; do
[[ $(grep "can_run" "$FILE") != "" ]] && run [[ $(grep "can_run" "$FILE") != "" ]] && run
[[ $(grep "cant_run" "$FILE") != "" ]] && exit 0
done < <(stdbuf -oL tail -f "$FILE") done < <(stdbuf -oL tail -f "$FILE")

View file

@ -46,6 +46,8 @@ exec-once = swayosd
# Change HandleLidSwitch to lock in logind.conf # Change HandleLidSwitch to lock in logind.conf
exec-once = swayidle -w lock $LOCK_PATH/lock.sh exec-once = swayidle -w lock $LOCK_PATH/lock.sh
exec-once = spot
# Some default env vars. # Some default env vars.
env = XCURSOR_SIZE,24 env = XCURSOR_SIZE,24
@ -139,6 +141,7 @@ gestures {
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more # See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
windowrule = noborder,^(wofi)$ windowrule = noborder,^(wofi)$
windowrule = workspace special:spot,^(dev.alextren.Spot)$
windowrule = float,^(org.kde.polkit-kde-authentication-agent-1)$ windowrule = float,^(org.kde.polkit-kde-authentication-agent-1)$
windowrule = size 741 288,^(org.kde.polkit-kde-authentication-agent-1)$ windowrule = size 741 288,^(org.kde.polkit-kde-authentication-agent-1)$
@ -170,6 +173,7 @@ bind = $mainMod, V, exec, cliphist list | wofi --dmenu | cliphist decode | wl-co
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more # Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
bind = $mainMod, Q, exec, alacritty bind = $mainMod, Q, exec, alacritty
bind = $mainMod, S, togglespecialworkspace, spot
bind = $mainMod, C, killactive, bind = $mainMod, C, killactive,
bind = $mainMod, L, exec, $LOCK_PATH/lock.sh bind = $mainMod, L, exec, $LOCK_PATH/lock.sh

View file

@ -70,6 +70,7 @@
tutanota-desktop tutanota-desktop
input-emulator input-emulator
bc bc
spot
swayosd swayosd
blueberry blueberry
libayatana-appindicator libayatana-appindicator
@ -100,9 +101,6 @@
gimp-with-plugins gimp-with-plugins
jdk19_headless jdk19_headless
bluez-tools bluez-tools
spotify
#spotifywm # fails to build
spicetify-cli # TODO
vlc vlc
discord discord
brightnessctl brightnessctl