From 651153719b1539554f3c9e35dc3459fc17f77b0a Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Tue, 6 Dec 2022 15:19:09 -0600 Subject: [PATCH] making eww work --- eww/notifications.yuck | 62 +++++++++ eww/sidebar.yuck | 298 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 360 insertions(+) create mode 100644 eww/notifications.yuck create mode 100644 eww/sidebar.yuck diff --git a/eww/notifications.yuck b/eww/notifications.yuck new file mode 100644 index 0000000..8feca7f --- /dev/null +++ b/eww/notifications.yuck @@ -0,0 +1,62 @@ +(defwindow notifications + :geometry (geometry :x "0px" + :y "0px" + :width "1px" + :height "93%" + :anchor "bottom right") + :stacking "fg" + :monitor "0" +(notif-panel)) + +(defwidget notif-panel [] + (eventbox + :halign "start" + :onhoverlost "${EWW_CMD} update rightside=false" + (revealer + :transition "slideleft" + :reveal rightside + :duration "550ms" + (rightside)))) +(defvar rightside false) + +(defwidget rightside [] + (box + :class "side" + :orientation "v" + :space-evenly "false" + :spacing "10" + :halign "center" + (box + :class "notification-header" + :orientation "h" + :space-evenly "false" + (label + :class "notification-label" + :halign "start" + :text "Notifications") + (box + :orientation "h" + :space-evenly "false" + :halign "end" + (button + :class "notification-action" + :tooltip "Refresh" + :onclick "dunstctl history > /tmp/dunst-history.json" "") + (button + :class "notification-action" + :tooltip "Pause/Resume Notifications" + :onclick "dunstctl set-paused toggle" "") + (button + :class "notification-action" + :tooltip "Dismiss All" + :onclick "pkill dunst && hyprctl dispatch exec dunst && dunstctl history > /tmp/dunst-history.json" ""))) + (scroll + :vscroll "true" + :hscroll "false" + :height 840 + :width 200 + (literal + :content notifications) +))) + +(deflisten notifications "scripts/notifications") diff --git a/eww/sidebar.yuck b/eww/sidebar.yuck new file mode 100644 index 0000000..658c264 --- /dev/null +++ b/eww/sidebar.yuck @@ -0,0 +1,298 @@ +(defwindow sidebar + :geometry (geometry :x "0px" + :y "0px" + :width "1px" + :height "1024" + :anchor "bottom left") + :stacking "fg" + :monitor "0" +(sidebar)) + +(defwidget sidebar [] + (eventbox + :halign "start" + :onhover "${EWW_CMD} update side=true" + :onhoverlost "${EWW_CMD} update side=false" + (revealer + :transition "slideright" + :reveal side + :duration "550ms" + (side)))) +(defvar side false) + +;; background +(defwidget side [] + (box + :class "side" + :orientation "v" + :space-evenly "false" + :spacing "30" + :halign "start" + (fetch) + (top) + (music-side) + (system-side) + (tray)) +) + +(defwidget top [] + (box + :orientation "h" + :space-evenly "false" + :spacing "30" + :halign "center" + (date) + (weather)) +) + +;; Music Widgets +(defwidget music-side [] + (box + :class "music-player" + :orientation "h" + :space-evenly "false" + :spacing 15 + :halign "center" + :valign "start" + :hexpand "true" + :width "" + (box + :class "album_art" + :style "background-image: url('${art}');") + (box + :orientation "v" + :space-evenly "false" + :valign "center" + :halign "center" + :spacing 10 + (label + :class "song" + :limit-width 15 + :text title) + (label + :class "artist" + :limit-width 15 + :text artist) + (box + :orientation "h" + :space-evenly "false" + :valign "center" + :halign "center" + :spacing 25 + (button :class "btn_prev" :onclick "scripts/music previous" "玲") + (button :class "btn_play" :onclick "scripts/music toggle" playpause) + (button :class "btn_next" :onclick "scripts/music next" "怜"))))) + +(defpoll art :interval "1s" "scripts/music coverloc") +(defpoll title :interval "1s" "scripts/music title") +(defpoll artist :interval "1s" "scripts/music artist") +(defpoll playpause :interval "1s" "scripts/music statusicon") + +;; weather +(defwidget weather [] + (box + :class "weather" + :orientation "v" + :spacing -2 + :space-evenly "false" + :vexpand "true" + :hexpand "false" + :valign "start" + :halign "center" + (label + :class "iconweather" + :halign "center" + :valign "center" + :style "color: ${HEX};" :text ICON) + (button + :onclick "scripts/weather --getdata && eww reload &" + :class "label_temp" + :valign "center" + :halign "center" + "${TEMP}"))) + +(defwidget date [] + (box :class "date" :orientation "v" :valign "start" :space-evenly "false" :halign "center" + (label + :text DAY) + (label + :text POO) + (label :class "foo" + :text FOO))) + +(defpoll FOO :interval "6h" "date '+%d'") +(defpoll DAY :interval "6h" "date '+%A'") +(defpoll POO :interval "6h" "date '+%B'") + + +;; Weather vars +(defpoll ICON :interval "15m" `scripts/weather --icon`) +(defpoll TEMP :interval "15m" `scripts/weather --temp`) +(defpoll HEX :interval "15m" `scripts/weather --hex`) + +;; <-- System --> +(defwidget system-side [] + (box + :class "stats-box" + :space-evenly "false" + :width "300px" + :orientation "v" + :valign "start" + :halign "center" + :spacing 12 + (box + :class "stats" + :hexpand "false" + :vexpand "false" + :space-evenly "false" + (label + :tooltip "${round(EWW_CPU.avg, 0)}%" + :class "stats-icon" :text "") + (scale + :min 0 + :max 101 + :active false + :value {EWW_CPU.avg} + :class "scale" + :width 280)) + (box + :class "stats" + :hexpand "false" + :vexpand "false" + :space-evenly "false" + (label + :tooltip "${round(EWW_RAM.used_mem_perc, 0)}%" + :class "stats-icon" + :text "﬙") + (scale + :min 0 + :max 101 + :active false + :value {EWW_RAM.used_mem_perc} + :class "scale" + :width 280)) + (box + :class "stats" + :hexpand "false" + :vexpand "false" + :space-evenly "false" + (label + :tooltip "${round(EWW_DISK["/"].used_perc, 0)}%" + :class "stats-icon" + :text "") + (scale + :min 0 + :max 101 + :active false + :value {(EWW_DISK["/"].used / EWW_DISK["/"].total) * 100} + :class "scale" + :width 280)) + (box + :class "stats" + :hexpand "false" + :vexpand "false" + :space-evenly "false" + (label + :tooltip "${gpu}%" + :class "stats-icon" + :text "調") + (scale + :min 0 + :max 101 + :active false + :value gpu + :class "scale" + :width 280)) + (box + :class "stats" + :hexpand "false" + :vexpand "false" + :space-evenly "false" + (button + :tooltip "${volume_percent}%" + :onclick "amixer set Master toggle" + :onrightclick "alsamixer &" + :class "stats-icon" "墳") + (scale + :min 0 + :max 101 + :active true + :value volume_percent + :class "scale" + :width 280 + :onchange "amixer sset Master {}%") + ))) + + (deflisten gpu "scripts/gpu") + +(defwidget tray [] + (box + :class "buttons" + :orientation "h" + :space-evenly "false" + :halign "center" + :valign "start" + :spacing "2" + (button + :class "poweroff" + :halign "center" + :tooltip "Shut Down" + :onclick "kitty poweroff &" "⏻") + (button + :class "reboot" + :halign "center" + :tooltip "Reboot" + :onclick "kitty reboot &" "") + (button + :class "firmware" + :halign "center" + :tooltip "Reboot to EFI" + :onclick "kitty systemctl reboot --firmware &" "拉") + (button + :class "exit" + :halign "center" + :tooltip "Quit Hyprland" + :onclick "hyprctl dispatch exit exit" "") + (button + :class "restart" + :halign "center" + :tooltip "edit Config" + :onclick "footclient nvim ~/.config/hypr/hyprland.conf &" ""))) + +(defpoll uptime :interval "1m" "uptime -p | sed -e 's/up //;s/ hours,/h/;s/ minutes/m/'") +(defpoll packages :interval "5m" `pacman -Q | wc -l`) +(defpoll kernal :interval "5m" `uname -r`) +(defpoll name :interval "5m" `whoami`) +(defpoll host :interval "5m" `uname -n`) +(defpoll wm :interval "5m" `echo $XDG_CURRENT_DESKTOP`) + +(defwidget fetch [] + (box + :class "fetch" + :orientation "v" + :space-evenly "false" + :halign "center" + :valign "start" + :spacing "10" + (label + :class "host" + :halign "start" + :text " : ${name}@${host}") + (label + :class "wm" + :halign "start" + :text " : ${wm}") + (label + :class "uptime" + :halign "start" + :text " : ${uptime}") + (label + :class "packages" + :halign "start" + :text " : ${packages}") + (label + :class "kernal" + :halign "start" + :text " : ${kernal}") + ) + )