From 14cb44c397c4c900f5c17d428ecc7cc733a6c7bc Mon Sep 17 00:00:00 2001 From: matt1432 Date: Thu, 17 Aug 2023 23:58:40 -0400 Subject: [PATCH] feat(eww): add spotify slider and bc package --- README.md | 2 +- config/eww/playerinfo/playerinfo.scss | 26 ++++++++++++++++++++++++++ config/eww/playerinfo/playerinfo.yuck | 17 +++++++++++++++++ config/eww/scripts/music.sh | 6 ++++++ nixos/home/packages.nix | 1 + 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1363a69..a41d3a6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ what is currently not working: what i want to do: - learn flakes -- add music widget in eww control center +- add auto-rotate widget in eww control center # Docs diff --git a/config/eww/playerinfo/playerinfo.scss b/config/eww/playerinfo/playerinfo.scss index e38a808..9307a69 100644 --- a/config/eww/playerinfo/playerinfo.scss +++ b/config/eww/playerinfo/playerinfo.scss @@ -62,3 +62,29 @@ padding-right: 8px; } } + +.song-pos { + scale { + highlight { + margin: 0px; + border-radius: 2em; + } + + trough { + background-color: #363847; + border-radius: 2em; + } + + slider { + margin: -8px; + min-height: 20px; + border-radius: 10px; + box-shadow: rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px; + transition: background-color 0.5s ease-in-out; + } + slider:hover { + background-color: #303240; + transition: background-color 0.5s ease-in-out; + } + } +} diff --git a/config/eww/playerinfo/playerinfo.yuck b/config/eww/playerinfo/playerinfo.yuck index c43e717..9bebd49 100644 --- a/config/eww/playerinfo/playerinfo.yuck +++ b/config/eww/playerinfo/playerinfo.yuck @@ -9,6 +9,8 @@ (defvar button_height "42") (defpoll shuffle_status :interval "1s" "playerctl -p spotify 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") (defwidget playerinfo [] (centerbox :class "playerinfo" @@ -54,6 +56,8 @@ ) (box :class "bottom" :style "color: ${button_accent};" + :space-evenly false + :spacing 0 (eventbox :valign "end" :halign "start" :onclick "playerctl -p spotify previous & $EWW_PATH/music.sh cover" @@ -62,6 +66,19 @@ :cursor "pointer" "󰒮" ) + (eventbox :cursor "pointer" + :class "song-pos" + :hexpand true + (scale :value song_pos + :min 0 + :max song_length + :orientation "h" + :onchange "playerctl -p spotify position {}" + :css "highlight { background-color: ${button_accent}; } + slider { background-color: ${button_accent}; } + trough { background-color: rgba(${button_accent}, 0.4); }" + ) + ) (box :valign "end" :halign "end" diff --git a/config/eww/scripts/music.sh b/config/eww/scripts/music.sh index 2844c06..49174b4 100755 --- a/config/eww/scripts/music.sh +++ b/config/eww/scripts/music.sh @@ -41,6 +41,11 @@ loop_status() { esac } +get_length() { + eww update song_pos="$(playerctl -p spotify position)" + eww update song_length="$(echo "$(playerctl -p spotify metadata mpris:length)/1000000" | bc -l)" +} + get_accents() { accents="$(coloryou /tmp/cover.jpg | sed 's/,//g' | sed 's/}//' | sed 's/'\''//g')" music_accent=$(echo "$accents" | awk '{ print $2 }') @@ -74,4 +79,5 @@ get_cover() { [[ "$1" == "accents" ]] && get_accents [[ "$1" == "loop" ]] && loop [[ "$1" == "loop_status" ]] && loop_status +[[ "$1" == "length" ]] && get_length [[ "$1" == "cover" ]] && get_cover diff --git a/nixos/home/packages.nix b/nixos/home/packages.nix index 65a8c7b..0d29331 100644 --- a/nixos/home/packages.nix +++ b/nixos/home/packages.nix @@ -69,6 +69,7 @@ tutanota-desktop input-emulator + bc swayosd blueberry libayatana-appindicator