From 63904bec07f0a18c37f914010af0df110b7bb965 Mon Sep 17 00:00:00 2001 From: willifan Date: Tue, 19 Mar 2024 22:38:12 +0100 Subject: [PATCH] Organized yuck files --- eww.yuck | 179 +++++++++++++++---------------------------------- newbar.yuck | 62 ----------------- templates.yuck | 80 ++++++++++++++++++++++ variables.yuck | 28 ++++++++ 4 files changed, 163 insertions(+), 186 deletions(-) delete mode 100644 newbar.yuck create mode 100644 templates.yuck create mode 100644 variables.yuck diff --git a/eww.yuck b/eww.yuck index 4ba5bcf..4172a56 100644 --- a/eww.yuck +++ b/eww.yuck @@ -1,99 +1,9 @@ -;;Input values +(include "variables.yuck") +(include "templates.yuck") -(defvar image '["kitty.svg","firefox.svg","sublime.svg","kitty.svg","","","","","","webcord.svg"]') +;; left -(deflisten brightnessValue - :initial "0" - `scripts/brightness.sh`) - -(defpoll network - :initial '{"name":"No Connection","image":"n.A."}' - :interval "2s" - `scripts/network.sh &`) - -(deflisten workspaces - :initial '' - `scripts/clients/build/clients`) - - - -(defpoll bluetooth - :initial '{"name":"","battery":"0"}' - :interval "2s" - `scripts/bluetooth.sh`) - -(deflisten volume - :initial '{"volume":"0","muted":"0"}' - `scripts/volume.sh`) - -(defpoll media - :initial '{"status":"","name":""}' - :interval "2s" - `scripts/media.sh`) - - -;; Widget templates - -(defwidget imageDPI [image size visible] - (overlay - :width "${size}" - :height "${size}" - :visible "${visible}" - (box - :width "${size}" - :height "${size}") - (transform - :scale-x "50%" - :scale-y "50%" - :halign "center" - :valign "center" - :translate-x "${size}" - :translate-y "${size}" - (image - :path "${image}" - :image-width "${size * 2}" - :image-height "${size * 2}")))) - - -(defwidget icon [widgetclass ?hover percentage image] - (box - :class "${widgetclass}" - :space-evenly false - (overlay - :tooltip "${hover}" - (circular-progress - :width 18 - :value "${percentage}" - :start-at 75 - :thickness 2 - :clockwise false) - (transform - :scale-x "50%" - :scale-y "50%" - :halign "center" - :valign "center" - :translate-x "16" - :translate-y "16" - (image - :path "${image}" - :image-width "32" - :image-height "32"))))) - - -;; Widgets - - -(defwidget workspaces [] - (box - (for workspace in workspaces - (eventbox - :onclick `/home/willifan/.config/scripts/workspaces.sh ${workspace.num}` - (label - :width "15" - :class {workspace.active == 1 ? "activeWorkspace" : workspace.occupied == 0 ? "unoccupiedWorkspace" : ""} - ;;:visible {workspace.occupied == 1 ? "true" : "false"} - :text "${workspace.num}"))))) (defwidget time [] (eventbox @@ -105,53 +15,72 @@ (label :text "${formattime(EWW_TIME, "%H:%M:%S")}"))) +;; center + + +(defwidget workspaces [monitor] + (box + :space-evenly false + :spacing 3 + (for workspace in workspaces + (workspace + :activeOn {workspace.normal.activeOn} + :occupied {workspace.normal.occupied} + :id {workspace.normal.id} + :icon {workspace.normal.icon} + :monitor {monitor})))) + + +;; right + + (defwidget cpu [] (icon :widgetclass "cpu" :hover "${round(EWW_CPU.avg, 1)}%" - :percentage "${round(EWW_CPU.avg, 1)}" + :percentage {round(EWW_CPU.avg, 1)} :image "images/cpu.png")) (defwidget ram [] (icon :widgetclass "ram" :hover "${round(EWW_RAM.used_mem /(1024*1024*1024), 1)} GiB | ${round(EWW_RAM.used_mem_perc, 1)}%" - :percentage "${round(EWW_RAM.used_mem_perc, 1)}" + :percentage {round(EWW_RAM.used_mem_perc, 1)} :image "images/ram.png")) (defwidget audio [] (icon - :widgetclass "${volume.muted == 1 ? "muted" : "volume"}" + :widgetclass {volume.muted == 1 ? "muted" : "volume"} :hover "${volume.volume}%" - :percentage "${volume.volume >= 0 && volume.volume <= 100 ? volume.volume : 0}" - :image "${volume.muted == 1 ? "images/volumeMuted.png" : "images/volume.png"}")) + :percentage {volume.volume >= 0 && volume.volume <= 100 ? volume.volume : 0} + :image {volume.muted == 1 ? "images/volumeMuted.png" : "images/volume.png"})) (defwidget brightness [] (icon :widgetclass "brightness" :hover "${brightnessValue / 960}%" - :percentage "${brightnessValue / 960}" + :percentage {brightnessValue / 960} :image "images/brightness.png")) (defwidget network [] (icon :widgetclass "network" - :hover "${network.name}" + :hover {network.name} :percentage "100" :image "images/${network.image}.png")) (defwidget bluetooth [] (icon :widgetclass "bluetooth" - :hover "${bluetooth.name}" - :percentage "${bluetooth.battery}" + :hover {bluetooth.name} + :percentage {bluetooth.battery} :image "images/bluetooth.png")) (defwidget battery [] (icon :widgetclass {EWW_BATTERY.BAT1.status == "Charging" ? "battery" : EWW_BATTERY.total_avg > 25 ? "battery" : "batteryLow"} :hover "${round(EWW_BATTERY.total_avg, 1)}%" - :percentage "${EWW_BATTERY.total_avg <= 90 ? round(EWW_BATTERY.total_avg, 1)/0.9 : 100}" + :percentage {EWW_BATTERY.total_avg <= 90 ? round(EWW_BATTERY.total_avg, 1)/0.9 : 100} :image {EWW_BATTERY.BAT1.status == "Charging" ? "images/charging.png" : EWW_BATTERY.total_avg > 25 ? "images/battery.png" : "images/batteryLow.png"})) (defwidget power [] @@ -161,19 +90,7 @@ :percentage "0" :image "images/power.png")) -(defwidget smallSpacer [] - (box - :width 2)) -(defwidget space [] - (box - :width 5)) - -(defwidget seperator [] - (box - (label - :text "|" - ))) ;; Widget blocks @@ -187,8 +104,8 @@ :visible {media.status == "Playing" ? true : false} (smallSpacer) (label - :text "${media.name}" - :tooltip "${media.name}" + :text {media.name} + :tooltip {media.name} :limit-width 40) (smallSpacer))) @@ -259,7 +176,7 @@ :space-evenly false :halign "start" (space) - (workspaces))) + (time))) (defwidget center [monitor] (box @@ -267,7 +184,7 @@ :space-evenly false :halign "center" (workspaces - :monitor "${monitor}") + :monitor {monitor}) )) (defwidget end [] @@ -294,10 +211,24 @@ (space))) +(defwidget bar [monitor] + (centerbox :orientation "h" + (start) + (center + :monitor {monitor}) + (end))) - -;; Window definition - - -(include "newbar.yuck") \ No newline at end of file +(defwindow bar [monitor width height] + :monitor {monitor} + :class "bar" + :geometry (geometry + :x "0%" + :y "5px" + :width "${width}px" + :height "${height}px" + :anchor "top center") + :stacking "fg" + :exclusive true + (bar + :monitor {monitor})) \ No newline at end of file diff --git a/newbar.yuck b/newbar.yuck deleted file mode 100644 index 4ac90ee..0000000 --- a/newbar.yuck +++ /dev/null @@ -1,62 +0,0 @@ - -;;1400 x 25 laptopWindow - -;;(defvar windows '[{"monitor":"0","width":"1400","height":"25"}]') - - -(defwindow bar [monitor width height] - :monitor "${monitor}" - :class "bar" - :geometry (geometry - :x "0%" - :y "5px" - :width "${width}px" - :height "${height}px" - :anchor "top center") - :stacking "fg" - :exclusive true - (bar - :monitor "${monitor}")) - - -(defwidget workspaces [monitor] - (box - :space-evenly false - :spacing 3 - (for workspace in workspaces - (eventbox - :onclick `/home/willifan/.config/scripts/workspaces.sh ${workspace.normal.id}` - :class {workspace.normal.activeOn == "${monitor}" ? "activeWorkspace" : "smallBox"} - :valign "center" - :halign "center" - :height 20 - :width 20 - (box - :halign "center" - :space-evenly false - (smallSpacer) - (label - :class {workspace.normal.occupied > 0 ? "" : "unoccupiedWorkspace"} - :width 16 - :text "${workspace.normal.id}") - (imageDPI - :visible "${workspace.normal.occupied > 0 ? true : false}" - :image "${workspace.normal.icon}" - :size "16") - (smallSpacer)))))) - -(defwidget start [] - (box - :orientation "h" - :space-evenly false - :halign "start" - (space) - (time))) - -(defwidget bar [monitor] - (centerbox :orientation "h" - (start) - (center - :monitor "${monitor}") - (end))) - diff --git a/templates.yuck b/templates.yuck new file mode 100644 index 0000000..6c666dc --- /dev/null +++ b/templates.yuck @@ -0,0 +1,80 @@ +(defwidget imageDPI [image size visible] + (overlay + :width "${size}" + :height "${size}" + :visible "${visible}" + (box + :width "${size}" + :height "${size}") + (transform + :scale-x "50%" + :scale-y "50%" + :halign "center" + :valign "center" + :translate-x "${size}" + :translate-y "${size}" + (image + :path "${image}" + :image-width "${size * 2}" + :image-height "${size * 2}")))) + + +(defwidget icon [widgetclass ?hover percentage image] + (box + :class "${widgetclass}" + :space-evenly false + (overlay + :tooltip "${hover}" + (circular-progress + :width 18 + :value "${percentage}" + :start-at 75 + :thickness 2 + :clockwise false) + (transform + :scale-x "50%" + :scale-y "50%" + :halign "center" + :valign "center" + :translate-x "16" + :translate-y "16" + (image + :path "${image}" + :image-width "32" + :image-height "32"))))) + +(defwidget workspace [activeOn occupied id icon monitor] + (eventbox + :onclick `/home/willifan/.config/scripts/workspaces.sh ${id}` + :class {activeOn == monitor ? "activeWorkspace" : "smallBox"} + :valign "center" + :halign "center" + :height 20 + :width 20 + (box + :halign "center" + :space-evenly false + (smallSpacer) + (label + :class {occupied > 0 ? "" : "unoccupiedWorkspace"} + :width 16 + :text {id}) + (imageDPI + :visible {occupied > 0 ? true : false} + :image {icon} + :size "16") + (smallSpacer)))) + +(defwidget smallSpacer [] + (box + :width 2)) + +(defwidget space [] + (box + :width 5)) + +(defwidget seperator [] + (box + (label + :text "|" + ))) \ No newline at end of file diff --git a/variables.yuck b/variables.yuck new file mode 100644 index 0000000..0910440 --- /dev/null +++ b/variables.yuck @@ -0,0 +1,28 @@ +(deflisten brightnessValue + :initial "0" + `scripts/brightness.sh`) + +(defpoll network + :initial '{"name":"No Connection","image":"n.A."}' + :interval "2s" + `scripts/network.sh &`) + +(deflisten workspaces + :initial '' + `scripts/clients/build/clients`) + + + +(defpoll bluetooth + :initial '{"name":"","battery":"0"}' + :interval "2s" + `scripts/bluetooth.sh`) + +(deflisten volume + :initial '{"volume":"0","muted":"0"}' + `scripts/volume.sh`) + +(defpoll media + :initial '{"status":"","name":""}' + :interval "2s" + `scripts/media.sh`) \ No newline at end of file