✨ eww(mediaplayer): add image path support for album art
This commit is contained in:
@@ -1,81 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
# Original Script by vimjoyer, modified by retrozinndev
|
|
||||||
# Licensed under the MIT License, as in vimjoyer's repository and also in retrozinndev's Hyprland Dots.
|
|
||||||
# This script watches for notifications to display as a popup in eww.
|
|
||||||
|
|
||||||
import threading
|
|
||||||
import time
|
|
||||||
import dbus
|
|
||||||
import dbus.service
|
|
||||||
import subprocess
|
|
||||||
import os
|
|
||||||
import sys
|
|
||||||
from dbus.mainloop.glib import DBusGMainLoop
|
|
||||||
from gi.repository import GLib
|
|
||||||
|
|
||||||
class Notification:
|
|
||||||
def __init__(self, app_name, summary, body, icon, replaces_id):
|
|
||||||
self.app_name = app_name
|
|
||||||
self.summary = summary
|
|
||||||
self.body = body
|
|
||||||
self.icon = icon
|
|
||||||
self.replaces_id = replaces_id
|
|
||||||
|
|
||||||
notifications = []
|
|
||||||
notification_timeout = 8 # In seconds
|
|
||||||
|
|
||||||
def remove_popup_notification(notification):
|
|
||||||
time.sleep(notification_timeout)
|
|
||||||
notifications.remove(notification)
|
|
||||||
reload_output()
|
|
||||||
|
|
||||||
def add_popup_notification(notification):
|
|
||||||
notifications.insert(0, notification)
|
|
||||||
reload_output()
|
|
||||||
timer_thread = threading.Thread(target=remove_popup_notification, args=(notification,))
|
|
||||||
timer_thread.start()
|
|
||||||
|
|
||||||
def reload_output():
|
|
||||||
lastItem_notifications = len(notifications) - 1
|
|
||||||
output = ""
|
|
||||||
|
|
||||||
os.popen(". /etc/profile; eww open floating-notifications >> /dev/null")
|
|
||||||
|
|
||||||
for item in notifications:
|
|
||||||
if item is not notifications[lastItem_notifications]:
|
|
||||||
output = output + f"{{ \"applicationName\": \"{item.app_name}\", \"image\": \"{item.icon}\", \"summary\": \"{item.summary}\", \"body\": \"{item.body}\", \"id\": {item.replaces_id} }}, "
|
|
||||||
|
|
||||||
else:
|
|
||||||
output = "["+ output + f"{{ \"applicationName\": \"{item.app_name}\", \"image\": \"{item.icon}\", \"summary\": \"{item.summary}\", \"body\": \"{item.body}\", \"id\": {item.replaces_id} }} ]"
|
|
||||||
|
|
||||||
|
|
||||||
# Check if notifications(var) is empty
|
|
||||||
if not notifications:
|
|
||||||
output = "[]"
|
|
||||||
os.popen(". /etc/profile; eww close floating-notifications >> /dev/null")
|
|
||||||
|
|
||||||
print(f"{output}", flush=True)
|
|
||||||
|
|
||||||
|
|
||||||
class NotificationServer(dbus.service.Object):
|
|
||||||
def __init__(self):
|
|
||||||
bus_name = dbus.service.BusName("org.freedesktop.Notifications", bus=dbus.SessionBus())
|
|
||||||
dbus.service.Object.__init__(self, bus_name, "/org/freedesktop/Notifications")
|
|
||||||
|
|
||||||
@dbus.service.method("org.freedesktop.Notifications", in_signature="susssasa{ss}i", out_signature="u")
|
|
||||||
def Notify(self, app_name, replaces_id, icon, summary, body, actions, hints, timeout):
|
|
||||||
add_popup_notification(Notification(app_name, summary, body, icon, replaces_id))
|
|
||||||
return 0
|
|
||||||
|
|
||||||
@dbus.service.method("org.freedesktop.Notifications", out_signature="ssss")
|
|
||||||
def GetServerInformation(self):
|
|
||||||
return ("Custom Notification Server", "ExampleNS", "1.0", "1.2")
|
|
||||||
|
|
||||||
|
|
||||||
DBusGMainLoop(set_as_default=True)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
server = NotificationServer()
|
|
||||||
mainloop = GLib.MainLoop()
|
|
||||||
mainloop.run()
|
|
||||||
@@ -32,6 +32,10 @@
|
|||||||
|
|
||||||
|
|
||||||
; Polls
|
; Polls
|
||||||
|
(defpoll day_name :interval "2s"
|
||||||
|
`date +"%A"`)
|
||||||
|
(defpoll month_name :interval "2s"
|
||||||
|
`date +"%B"`)
|
||||||
(defpoll hostname :initial "GNU/Linux"
|
(defpoll hostname :initial "GNU/Linux"
|
||||||
:interval "24h"
|
:interval "24h"
|
||||||
`cat /etc/hostname`)
|
`cat /etc/hostname`)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
(defwidget clock []
|
(defwidget clock []
|
||||||
(box :class "clock"
|
(box :class "clock"
|
||||||
:tooltip { formattime(EWW_TIME, "%A, %B %d") }
|
:tooltip { day_name + ", " + month_name + formattime(EWW_TIME, " %d") }
|
||||||
|
|
||||||
(eventbox :onclick "sh scripts/eww-window.sh toggle calendar-window"
|
(eventbox :onclick "sh scripts/eww-window.sh toggle calendar-window"
|
||||||
:class '${ window_state_calendar-window == "open" ? "cal-open" : "" } button'
|
:class '${ window_state_calendar-window == "open" ? "cal-open" : "" } button'
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
(label :text ""
|
(label :text ""
|
||||||
:class "icon")
|
:class "icon")
|
||||||
|
|
||||||
(label :text "${ formattime(EWW_TIME, "%A") }")
|
(label :text "${day_name}")
|
||||||
|
|
||||||
(revealer :reveal { window_state_calendar-window == "closed" }
|
(revealer :reveal { window_state_calendar-window == "closed" }
|
||||||
:transition "slideright"
|
:transition "slideright"
|
||||||
|
|||||||
@@ -6,10 +6,12 @@
|
|||||||
:space-evenly false
|
:space-evenly false
|
||||||
(box :class "cpu"
|
(box :class "cpu"
|
||||||
:visible { cpu == "" || cpu ? true : false }
|
:visible { cpu == "" || cpu ? true : false }
|
||||||
|
:tooltip { "CPU: " + arraylength(EWW_CPU?.cores) + " Threads" }
|
||||||
(label :text " ${ round(EWW_CPU?.avg, 0) }%")
|
(label :text " ${ round(EWW_CPU?.avg, 0) }%")
|
||||||
)
|
)
|
||||||
(box :class "memory"
|
(box :class "memory"
|
||||||
:visible { memory == "" || memory ? true : false }
|
:visible { memory == "" || memory ? true : false }
|
||||||
|
:tooltip { "Total Memory: " + round(EWW_RAM?.total_mem / 1000000000, 1) + " GiB(s)" }
|
||||||
(label :text " ${ round(EWW_RAM?.used_mem_perc, 0) }%")
|
(label :text " ${ round(EWW_RAM?.used_mem_perc, 0) }%")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
(button :class "url"
|
(button :class "url"
|
||||||
:onclick "wl-copy '${json_media.url}'"
|
:onclick "wl-copy '${json_media.url}'"
|
||||||
:tooltip "Copy link to Clipboard"
|
:tooltip "Copy link to Clipboard"
|
||||||
|
:visible { json_media != "" && json_media.url != "null" }
|
||||||
"")
|
"")
|
||||||
(button :class "previous"
|
(button :class "previous"
|
||||||
:onclick "playerctl previous --player=${json_media.player}"
|
:onclick "playerctl previous --player=${json_media.player}"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
(defwidget big-media [ show-album-bg show-album-image ?album-image-size ?style ?visible ]
|
(defwidget big-media [ show-album-bg show-album-image ?album-image-size ?style ?visible ]
|
||||||
(box :class "big-media ${ show-album-bg ? 'album-bg' : '' } ${ show-album-image ? 'album-image' : '' }"
|
(box :class "big-media ${ show-album-bg ? 'album-bg' : '' } ${ show-album-image ? 'album-image' : '' }"
|
||||||
:style "${ show-album-bg ? 'background-image: url(\"${json_media.artUrl}\");' : '' } ${style}"
|
:style "${ show-album-bg ? "background-image: url(\"${ json_media.artUrl =~ "^(http(.*)://(.*))$" ? json_media.artUrl : "${ "${ json_media.artUrl =~ "^(file://(.*))$" ? '' : 'file://' }" + json_media.artUrl }" }\")" : "" }; ${style}"
|
||||||
:visible { visible == "" ? true : "${ visible ? true : false }" }
|
:visible { visible == false ? false : true }
|
||||||
:space-evenly false
|
:space-evenly false
|
||||||
:orientation "vertical"
|
:orientation "vertical"
|
||||||
|
|
||||||
@@ -12,32 +12,28 @@
|
|||||||
(box :class "album-image"
|
(box :class "album-image"
|
||||||
:width { album-image-size != "" ? album-image-size : 98 }
|
:width { album-image-size != "" ? album-image-size : 98 }
|
||||||
:height { album-image-size != "" ? "${album-image-size - 11}" : 87 }
|
:height { album-image-size != "" ? "${album-image-size - 11}" : 87 }
|
||||||
:style "background-image: image(url('${json_media.artUrl}'));"
|
:style "background-image: url('${ json_media.artUrl =~ "^(http(.*)://(.*))$" ? json_media.artUrl : "${ "${ json_media.artUrl =~ "^(file://(.*))$" ? '' : 'file://' }" + json_media.artUrl }" }');"
|
||||||
:valign "center"
|
:valign "center"
|
||||||
:visible { show-album-image ? true : false })
|
:visible { json_media.artUrl == "null" || !show-album-image ? false : true })
|
||||||
|
|
||||||
(box :orientation "vertical"
|
(box :orientation "vertical"
|
||||||
:space-evenly false
|
:space-evenly false
|
||||||
:class "right"
|
:class "right"
|
||||||
:hexpand true
|
|
||||||
:valign "center"
|
:valign "center"
|
||||||
|
|
||||||
(box :class "media-info"
|
(box :class "media-info"
|
||||||
:space-evenly false
|
:space-evenly false
|
||||||
:halign "fill"
|
|
||||||
:orientation "vertical"
|
:orientation "vertical"
|
||||||
|
|
||||||
(label :class "title"
|
(label :class "title"
|
||||||
:text "${json_media.title}"
|
:text "${json_media.title}"
|
||||||
:xalign 0
|
:xalign 0
|
||||||
:wrap false
|
:limit-width 40
|
||||||
:hexpand true
|
|
||||||
:show-truncated true)
|
:show-truncated true)
|
||||||
(label :class "artist"
|
(label :class "artist"
|
||||||
:text "${json_media.artist}"
|
:text "${json_media.artist}"
|
||||||
:xalign 0
|
:xalign 0
|
||||||
:wrap false
|
:limit-width 40
|
||||||
:hexpand true
|
|
||||||
:show-truncated true)
|
:show-truncated true)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
:prepend-new false
|
:prepend-new false
|
||||||
:class "systray"
|
:class "systray"
|
||||||
)
|
)
|
||||||
|
(hardware)
|
||||||
(audio)
|
(audio)
|
||||||
(battery)
|
(battery)
|
||||||
(network)
|
(network)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
:text { formattime(EWW_TIME, "%H:%M") })
|
:text { formattime(EWW_TIME, "%H:%M") })
|
||||||
|
|
||||||
(label :class "date"
|
(label :class "date"
|
||||||
:text { formattime(EWW_TIME, "%B %d, %Y") })
|
:text { month_name + formattime(EWW_TIME, " %d, %Y") })
|
||||||
(calendar :class "month-calendar"
|
(calendar :class "month-calendar"
|
||||||
:show-details true
|
:show-details true
|
||||||
:show-heading true
|
:show-heading true
|
||||||
|
|||||||
@@ -12,14 +12,18 @@
|
|||||||
:exclusive false
|
:exclusive false
|
||||||
:namespace "eww-cc"
|
:namespace "eww-cc"
|
||||||
|
|
||||||
|
(box :orientation "horizontal"
|
||||||
|
(eventbox
|
||||||
(box :class "cc"
|
(box :class "cc"
|
||||||
:orientation "vertical"
|
:orientation "vertical"
|
||||||
:space-evenly false
|
:space-evenly false
|
||||||
|
|
||||||
(top-bar)
|
(top-bar)
|
||||||
(tiles)
|
(tiles)
|
||||||
(revealer :reveal { window_state_floating-media != "open" }
|
(revealer :reveal { window_state_floating-media != "open" }
|
||||||
:transition "slideup"
|
:transition "slideup"
|
||||||
:duration "380ms"
|
:duration "380ms"
|
||||||
|
|
||||||
(big-media :show-album-bg true
|
(big-media :show-album-bg true
|
||||||
:show-album-image true
|
:show-album-image true
|
||||||
:visible { json_media == "" || (json_media.title == "null"
|
:visible { json_media == "" || (json_media.title == "null"
|
||||||
@@ -29,10 +33,13 @@
|
|||||||
(box :class "bottom button-row"
|
(box :class "bottom button-row"
|
||||||
:halign "end"
|
:halign "end"
|
||||||
:space-evenly false
|
:space-evenly false
|
||||||
|
|
||||||
(button :class "clear-all"
|
(button :class "clear-all"
|
||||||
:onclick "sh scripts/notification-clear.sh"
|
:onclick "sh scripts/notification-clear.sh"
|
||||||
:visible { arraylength(json_notification_history["history"]) > 0 }
|
:visible { arraylength(json_notification_history["history"]) > 0 }
|
||||||
" Clear")
|
" Clear")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
(defwindow floating-media []
|
(defwindow floating-media []
|
||||||
:monitor 0
|
:monitor 0
|
||||||
:geometry (geometry :anchor "top center"
|
:geometry (geometry :anchor "top center"
|
||||||
:width "450px")
|
:width "460px")
|
||||||
:exclusive false
|
:exclusive false
|
||||||
:stacking "fg"
|
:stacking "fg"
|
||||||
:focusable false
|
:focusable false
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
&& json_media.artist == "null") ? false : true }
|
&& json_media.artist == "null") ? false : true }
|
||||||
|
|
||||||
(big-media :show-album-bg true
|
(big-media :show-album-bg true
|
||||||
:album-image-size 124
|
:album-image-size 128
|
||||||
:show-album-image true
|
:show-album-image true
|
||||||
:style "margin: 16px; margin-top: 0; box-shadow:
|
:style "margin: 16px; margin-top: 0; box-shadow:
|
||||||
0 5px 6px 1px rgba(0, 0, 0, .6),
|
0 5px 6px 1px rgba(0, 0, 0, .6),
|
||||||
|
|||||||
Reference in New Issue
Block a user