From 914a6950e3966bfa05777e5acd623d5fe2aa1e11 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sun, 20 Aug 2023 14:26:47 -0400 Subject: [PATCH] feat: switch to spot instead of official spotify client --- config/eww/playerinfo/playerinfo.yuck | 22 +++++++++++----------- config/eww/scripts/music.sh | 16 ++++++++-------- config/eww/scripts/run.sh | 3 +-- config/hypr/main.conf | 4 ++++ nixos/home/packages.nix | 4 +--- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/config/eww/playerinfo/playerinfo.yuck b/config/eww/playerinfo/playerinfo.yuck index f426aa6..b1fc115 100644 --- a/config/eww/playerinfo/playerinfo.yuck +++ b/config/eww/playerinfo/playerinfo.yuck @@ -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 (defvar music_accent "rgb(0,0,0)") ;done (defvar button_accent "rgb(0,0,0)") ;done (defvar button_text "rgb(255,255,255)") ;done -(defpoll music_status :interval "1s" "playerctl -p spotify status") -(defpoll title :interval "1s" "playerctl -p spotify metadata title") -(defpoll artist :interval "1s" "playerctl -p spotify metadata artist") +(defpoll music_status :interval "1s" "playerctl -p Spot status") +(defpoll title :interval "1s" "playerctl -p Spot metadata title") +(defpoll artist :interval "1s" "playerctl -p Spot metadata artist") (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") (defvar song_pos "0") (defpoll song_length :interval "1s" "$EWW_PATH/music.sh length") @@ -23,7 +23,7 @@ :halign "start" :valign "start" :style "color: ${button_accent};" - "${player == 'spotify' ? '' : '爵' }" + "${player == 'Spot' ? '' : '爵' }" ) (box :class "center" :orientation "h" @@ -42,7 +42,7 @@ :halign "left" :style "background-color: ${button_accent}; color: ${button_text};" - :onclick "playerctl -p spotify play-pause" + :onclick "playerctl -p Spot play-pause" :cursor "pointer" :onhover "eww update button_height=41" :onhoverlost "eww update button_height=42" @@ -61,7 +61,7 @@ :spacing 0 (eventbox :valign "end" :halign "start" - :onclick "playerctl -p spotify previous & $EWW_PATH/music.sh cover" + :onclick "playerctl -p Spot previous & $EWW_PATH/music.sh cover" :class "previousbutton" :width 40 :cursor "pointer" @@ -76,7 +76,7 @@ :min 0 :max song_length :orientation "h" - :onchange "playerctl -p spotify position {}" + :onchange "playerctl -p Spot position {}" :css "highlight { background-color: ${button_accent}; } slider { background-color: ${button_accent}; } trough { background-color: rgba(${button_accent}, 0.4); }" @@ -85,13 +85,13 @@ (box :valign "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" :width 40 :cursor "pointer" "󰒭" ) - (eventbox :onclick "playerctl -p spotify shuffle toggle" + (eventbox :onclick "playerctl -p Spot shuffle toggle" :class "shuffle" :width 40 :cursor "pointer" diff --git a/config/eww/scripts/music.sh b/config/eww/scripts/music.sh index acceaeb..dc63727 100755 --- a/config/eww/scripts/music.sh +++ b/config/eww/scripts/music.sh @@ -1,19 +1,19 @@ #!/usr/bin/env bash loop() { - loop_status=$(playerctl -p spotify loop) + loop_status=$(playerctl -p Spot loop) case $loop_status in "None" ) - playerctl -p spotify loop Playlist + playerctl -p Spot loop Playlist eww update repeat_icon="󰑖" ;; "Track" ) - playerctl -p spotify loop None + playerctl -p Spot loop None eww update repeat_icon="󰑗" ;; "Playlist" ) - playerctl -p spotify loop Track + playerctl -p Spot loop Track eww update repeat_icon="󰑘" ;; * ) @@ -23,7 +23,7 @@ loop() { } loop_status() { - loop_status=$(playerctl -p spotify loop) + loop_status=$(playerctl -p Spot loop) case $loop_status in "None" ) @@ -43,9 +43,9 @@ loop_status() { get_length() { if [[ $(eww get get_pos) == "true" ]]; then - eww update song_pos="$(playerctl -p spotify position)" + eww update song_pos="$(playerctl -p Spot position)" 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() { @@ -62,7 +62,7 @@ get_accents() { get_cover() { 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}') # Download the new image only if the hashes are different diff --git a/config/eww/scripts/run.sh b/config/eww/scripts/run.sh index 3f765f9..38b006d 100755 --- a/config/eww/scripts/run.sh +++ b/config/eww/scripts/run.sh @@ -14,10 +14,9 @@ function run() { sleep 0.1 input-emulator mouse button left fi - echo "cant_run" > "$FILE" + exit 0 } while IFS='$\n' read -r line; do [[ $(grep "can_run" "$FILE") != "" ]] && run - [[ $(grep "cant_run" "$FILE") != "" ]] && exit 0 done < <(stdbuf -oL tail -f "$FILE") diff --git a/config/hypr/main.conf b/config/hypr/main.conf index 29ca64f..f2c11a9 100644 --- a/config/hypr/main.conf +++ b/config/hypr/main.conf @@ -46,6 +46,8 @@ exec-once = swayosd # Change HandleLidSwitch to lock in logind.conf exec-once = swayidle -w lock $LOCK_PATH/lock.sh +exec-once = spot + # Some default env vars. env = XCURSOR_SIZE,24 @@ -139,6 +141,7 @@ gestures { # See https://wiki.hyprland.org/Configuring/Window-Rules/ for more windowrule = noborder,^(wofi)$ +windowrule = workspace special:spot,^(dev.alextren.Spot)$ windowrule = float,^(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 bind = $mainMod, Q, exec, alacritty +bind = $mainMod, S, togglespecialworkspace, spot bind = $mainMod, C, killactive, bind = $mainMod, L, exec, $LOCK_PATH/lock.sh diff --git a/nixos/home/packages.nix b/nixos/home/packages.nix index 0d29331..44bcbee 100644 --- a/nixos/home/packages.nix +++ b/nixos/home/packages.nix @@ -70,6 +70,7 @@ tutanota-desktop input-emulator bc + spot swayosd blueberry libayatana-appindicator @@ -100,9 +101,6 @@ gimp-with-plugins jdk19_headless bluez-tools - spotify - #spotifywm # fails to build - spicetify-cli # TODO vlc discord brightnessctl