Files
colorshell/eww/widgets/bar/media.yuck
T
2024-12-21 18:54:41 -03:00

59 lines
2.0 KiB
Plaintext

(defvar media_reveal_controls false)
(defwidget media []
(eventbox :onhover "${EWW_CMD} update media_reveal_controls=true"
:onhoverlost "${EWW_CMD} update media_reveal_controls=false"
:visible { json_media == "" || (json_media.title == "null" &&
json_media.artist == "null") ||
(active_window.class =~ json_media.player &&
active_window.title =~ json_media.title) ?
false : true
}
:onclick "sh scripts/eww-window.sh toggle floating-media"
:class "mediaplayer-eventbox"
(box :class "mediaplayer ${ media_reveal_controls && window_state_floating-media == "closed" ? 'revealed' : '' }"
:space-evenly false
(eventbox :class "media"
:tooltip "${json_media.title} - ${json_media.artist}"
(box :space-evenly false
(label :class "player"
:text { json_media.player == "spotify" ? " " : "󰎇 " })
(label :class "media-title"
:text "${json_media.title}"
:limit-width 40)
(box :class "separator")
(label :class "media-artist"
:text "${json_media.artist}"
:limit-width 25)
)
)
(revealer :class "media-controls-revealer"
:reveal { media_reveal_controls ? "${ window_state_floating-media == 'closed' ? true : false }" : false }
:transition "slideright"
:duration "180ms"
(box :class "media-controls"
(button :class "previous"
:onclick "playerctl previous --player=${json_media.player}"
"󰒮")
(button :class "toggle play-pause"
:onclick "playerctl play-pause --player=${json_media.player}"
{ json_media.status == "playing" ? "󰏤" : "󰐊" })
(button :class "next"
:onclick "playerctl next --player=${json_media.player}"
"󰒭")
)
)
)
)
)