Adds media display

This commit is contained in:
Michel Fedde 2025-10-22 01:50:22 +02:00
parent 032cab6ba8
commit ca2fa8dc62
12 changed files with 180 additions and 8 deletions

14
.config/eww/eww.scss Normal file
View file

@ -0,0 +1,14 @@
@import '../theming/library/entry.scss'
.background {
background: none;
}
.widget {
box-shadow: $box-shadow-inner-less;
background: $background;
border-radius: $border-radius;
border: 1px solid $border-color;
}
@import "./widgets/media/style.scss"

1
.config/eww/eww.yuck Normal file
View file

@ -0,0 +1 @@
(include "./widgets/media/media.yuck")

View file

@ -0,0 +1,97 @@
(deflisten media-info :initial '{}' `~/.config/scripts/playerctl-metadata-json.sh`)
(deflisten media-status :initial 'stopped' 'playerctl status --follow')
(defpoll media-playback-info :interval '1s' :initial '0' `playerctl position`)
(defvar statusIcons '{"Playing": "player_play", "Paused": "player_pause"}')
(defvar media-close-time 0)
(defwidget icon-button [icon onclick]
(button
:onclick {onclick}
:vexpand false
(image :icon {icon})
)
)
(defwidget media-label [text ?class]
(label :text {text} :xalign "0" :class {class})
)
(defwidget media-texts []
(box
:orientation "vertical"
:hexpand true
:valign "center"
:halign "start"
:space-evenly false
(media-label :class "header" :text {media-info["xesam:title"]})
(media-label :text {media-info["xesam:artist"]})
(media-label :text {media-info["xesam:album"]})
)
)
(defwidget media-control []
(box
:visible {EWW_TIME < media-close-time}
:class "widget"
:width 512
:space-evenly false
:orientation "v"
(box
:class "data-display"
:valign "center"
:halign "start"
:space-evenly false
:spacing 20
(box
:width {512 - 128}
:space-evenly false
:orientation "vertical"
:spacing 10
(media-texts)
(box
:hexpand true
:vexpand true
:spacing 10
(icon-button
:icon "player_rew"
:onclick "~/.config/scripts/media.sh previous"
)
(icon-button
:icon {statusIcons[media-status] ?: "player_stop"}
:onclick "~/.config/scripts/media.sh play-pause"
)
(icon-button
:icon "player_fwd"
:onclick "~/.config/scripts/media.sh next"
)
)
)
(image
:path {substring(media-info["mpris:artUrl"], 7, 8000)}
:image-width 128
)
)
(progress
:height 1
:value {jq(media-playback-info, "tonumber(.)") / (jq(media-info["mpris:length"] ?: 1000, "tonumber(.)") / 1000000) * 100}
)
)
)
(defwindow media
:monitor 1
:geometry (geometry
:x "10px"
:y "50px"
:width "512px"
:height "10%"
:anchor "top right")
:stacking "fg"
(media-control)
)

View file

@ -0,0 +1,25 @@
.media {
transition: opacity 0.2s ease-in-out;
opacity: 1;
.closed {
opacity: 0;
}
.data-display {
padding: 1rem;
}
label {
font-size: 1.5rem;
&.header {
font-size: 2rem;
font-weight: bolder;
}
}
progressbar {
padding: 0 1rem;
}
}

View file

@ -1,4 +1,5 @@
layerrule = blur, gtk-layer-shell
layerrule = ignorezero, gtk-layer-shell
layerrule = blur, logout_dialog
layerrule = blur, waybar

View file

@ -9,9 +9,9 @@ bindl = , xf86AudioMicMute, exec, $scriptsDir/Volume.sh --toggle-mic # mic mute
bindl = , xf86audiomute, exec, $scriptsDir/Volume.sh --toggle # mute
# media controls using keyboards
bindl = , xf86AudioPlayPause, exec, $scriptsDir/MediaCtrl.sh --pause
bindl = , xf86AudioPause, exec, $scriptsDir/MediaCtrl.sh --pause
bindl = , xf86AudioPlay, exec, $scriptsDir/MediaCtrl.sh --pause
bindl = , xf86AudioNext, exec, $scriptsDir/MediaCtrl.sh --nxt
bindl = , xf86AudioPrev, exec, $scriptsDir/MediaCtrl.sh --prv
bindl = , xf86audiostop, exec, $scriptsDir/MediaCtrl.sh --stop
bindl = , xf86AudioPlayPause, exec, $scriptsDir/media.sh play-pause
bindl = , xf86AudioPause, exec, $scriptsDir/media.sh pause
bindl = , xf86AudioPlay, exec, $scriptsDir/media.sh play-pause
bindl = , xf86AudioNext, exec, $scriptsDir/media.sh next
bindl = , xf86AudioPrev, exec, $scriptsDir/media.sh previous
bindl = , xf86audiostop, exec, $scriptsDir/media.sh stop

View file

@ -45,5 +45,6 @@
"typst.vim": { "branch": "main", "commit": "323539709e29a537ff39dfce6c05f175a8921504" },
"which-key.nvim": { "branch": "main", "commit": "904308e6885bbb7b60714c80ab3daf0c071c1492" },
"wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" },
"yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" }
"yanky.nvim": { "branch": "main", "commit": "04775cc6e10ef038c397c407bc17f00a2f52b378" },
"yuck.vim": { "branch": "master", "commit": "9b5e0370f70cc30383e1dabd6c215475915fe5c3" }
}

View file

@ -0,0 +1 @@
return { "elkowar/yuck.vim", config = function() end }

19
.config/scripts/media.sh Executable file
View file

@ -0,0 +1,19 @@
#!/bin/bash
EWW_VARIABLE_NAME="media-close-time"
EWW_DISPLAY_TIME=10
case "$1" in
"play-pause" | "stop" | "next" | "previous")
playerctl "$1"
;;
"display")
EWW_DISPLAY_TIME=${2:-10}
;;
*)
echo "Invalid Entry"
exit 1
;;
esac
eww update "$EWW_VARIABLE_NAME=$(($(date +%s) + $EWW_DISPLAY_TIME))"

View file

@ -0,0 +1,12 @@
#!/bin/bash
formatReturn() {
playerctl metadata | jq -R -s -c -r 'split("\n") | map(match("(\\w+) {1}([\\w:]+) {3,}(.+)") | {(.captures[1].string): .captures[2].string}) | add'
}
playerctl --follow metadata | while read line; do
~/.config/scripts/media.sh display 5
formatReturn
done

View file

@ -1,6 +1,6 @@
#!/bin/env sh
addApplications python-pywal sass npm
addApplications python-pywal sass npm eww
addGitInstall "image-glsl-processing" "https://github.com/Neintonine/image-glsl-processing.git" setup_image_glsl_processing

1
.gitignore vendored
View file

@ -40,6 +40,7 @@
!/.config/xdg-desktop-portal/
!/.config/xdg-desktop-portal-termfilechooser/
!/.config/scripts/
!/.config/eww/
!/.config/systemd/
/.config/systemd/*
!/.config/systemd/user/