This commit is contained in:
soraefir
2026-06-13 19:21:33 +02:00
parent 6117dca845
commit aace131a0e
12 changed files with 374 additions and 244 deletions

View File

@@ -1,111 +1,82 @@
(deflisten radio :initial '{"is_paused":1,"song":{"artist":"","song":"","image600":"https://www.radiorecord.ru/upload/stations_images/record_image600_white_fill.png"},"stations":[]}' "scripts/radio")
(defvar radio_rev false)
(defwindow radio
:monitor 0
:geometry (geometry
:x "0%"
:y "0%"
:anchor "bottom right"
:width "0px"
:height "0px")
(window (radio-win)))
(deflisten radio
:initial '{"is_paused":1,"song":{"artist":"","song":"","image600":""},"radio":0,"stations":[],"media":{"player":"","status":"Stopped","artist":"","title":"","art":""}}'
"scripts/radio")
(defvar radio-vol 80)
(defvar radio-muted false)
(defwidget radio-win []
(box :class "sys-win" :orientation "v" :space-evenly false
(defwidget radio-win []
(box
:space-evenly false
:orientation "h"
(revealer
:visible radio_rev
:reveal radio_rev
:transition "slideleft"
(radio-selector))
(box
:space-evenly false
:orientation "v"
; --- Now Playing ---
(box :orientation "v" :space-evenly false :class "sys-section"
(section-header :title "Media" :accent "radio-accent")
(box :orientation "h" :space-evenly false :valign "center" :spacing 10 :class "radio-now-playing"
(box :class "radio-art"
:style "background-image: url('${radio.is_paused == 0 ? radio.song.image600 : (radio.media.status != 'Stopped' ? radio.media.art : radio.song.image600)}'); background-size: cover; background-position: center;"
(label :class "radio-art-icon" :halign "center" :valign "center"
:visible {radio.is_paused == 0
? radio.song.image600 == ""
: (radio.media.status != "Stopped"
? radio.media.art == ""
: radio.song.image600 == "")}
:text "󰝚"))
(box :orientation "v" :space-evenly false :hexpand true :valign "center"
(label :class "radio-song" :halign "start" :wrap true :limit-width 20
:text {radio.is_paused == 0
? (radio.song.song != "" ? radio.song.song : "Tuning in...")
: (radio.media.status != "Stopped"
? (radio.media.title != "" ? radio.media.title : "Playing")
: (radio.song.song != "" ? radio.song.song : "Nothing playing"))})
(label :class "radio-artist" :halign "start" :wrap true :limit-width 22
:text {radio.is_paused == 0
? radio.song.artist
: (radio.media.status != "Stopped"
? (radio.media.artist != "" ? radio.media.artist : radio.media.player)
: "")})))
(box
:class "album_art"
:style "background-size:cover; background-image: url('${radio.song.image600?:'https://www.radiorecord.ru/upload/stations_images/record_image600_white_fill.png'}');")
(box
:space-evenly false
:orientation "v"
(label
:halign "center"
:class "song"
:wrap "true"
:limit-width 18
:text "${radio.song.song?:'...'}")
(label
:halign "center"
:class "artist"
:wrap "true"
:limit-width 22
:text "${radio.song.artist?:'...'}")
(box
:space-evenly true
:orientation "h"
:halign "center"
:class "btn_bar"
; Controls - hidden only in placeholder state
(box :visible {radio.is_paused == 0 || radio.radio > 0 || radio.media.status != "Stopped"}
:orientation "v" :space-evenly false :class "radio-controls"
(box :orientation "h" :space-evenly true :halign "center"
(button :visible {radio.is_paused == 1 && radio.media.status != "Stopped"}
:class "radio-ctrl-btn" :timeout "2s" :onclick "playerctl previous"
(label :text "󰒮"))
(button :class "radio-ctrl-btn" :timeout "2s"
:onclick {radio.is_paused == 1 && radio.media.status != "Stopped" ? "playerctl play-pause" : "scripts/radio toggle"}
(label :text {radio.is_paused == 0 ? "󰏥" : (radio.media.status == "Playing" ? "󰏥" : "󰐌")}))
(button :visible {radio.is_paused == 1 && radio.media.status != "Stopped"}
:class "radio-ctrl-btn" :timeout "2s" :onclick "playerctl next"
(label :text "󰒭")))
(vol-row
:icon "󰕾"
:value {radio-vol}
:onchange "scripts/radio vol {}"
:onclick "scripts/radio mute"
:muted {radio-muted})))
(button
:class "btn_left"
:onclick "${EWW_CMD} update radio_rev=${!radio_rev}"
(box "󰷐"))
(box :class "section-sep")
(button
:class "btn_play"
:timeout "2s"
:onclick "scripts/radio toggle"
"${radio.is_paused==1 ? "󰐌" : "󰏥"}")
(button
:class "btn_right"
:onclick ""
(box :visible false "󰔶"))
)
)
)
)
)
(defwidget radio-selector []
(scroll
:active true
:vscroll true
:hscroll false
(box
:class "station_list"
:space-evenly false
:orientation "v"
(for station in {radio.stations}
; --- Stations ---
(box :orientation "v" :space-evenly false :class "sys-section"
(section-header :title "Radio Stations" :accent "radio-accent")
(scroll :vscroll true :hscroll false :height 130
(box :class "station-list" :space-evenly false :orientation "v"
(for station in {radio.stations}
(button
:class "station_art ${(radio.radio == station.id)?'station_sel':''}"
:timeout "2s"
:onclick "scripts/radio start ${station.id}"
:tooltip "${station.title}"
:style "background-size:cover; background-image: url('${station.icon_fill_white}');"
)
)
)
)
)
:class "station-row ${radio.radio == station.id ? 'station-row-active' : ''}"
:timeout "2s"
:onclick "scripts/radio start ${station.id}"
:tooltip {station.title}
(box :orientation "h" :space-evenly false :valign "center"
(box :class "station-icon"
:style "background-image: url('${station.icon_fill_white}'); background-size: contain; background-position: center;")
(label :class "station-name" :text {station.title}
:hexpand true :halign "start" :limit-width 16)))))))))
(defwidget radio-mod []
(module
(box
:orientation "v"
(button
:onclick "(sleep 0.1 && eww-open-on-current-screen radio --toggle --no-daemonize)"
(label
:show-truncated false
:class "icon-text"
:text "󰝚")
)
)
)
)
(eventbox
:onclick "(sleep 0.1 && scripts/panel-toggle radio)"
(box :orientation "v"
(label :show-truncated false :class "icon-text" :text "󰝚")))))