Organized yuck files

This commit is contained in:
willifan 2024-03-19 22:38:12 +01:00
parent 7a315e3f38
commit 63904bec07
4 changed files with 163 additions and 186 deletions

179
eww.yuck
View file

@ -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 [] (defwidget time []
(eventbox (eventbox
@ -105,53 +15,72 @@
(label (label
:text "${formattime(EWW_TIME, "%H:%M:%S")}"))) :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 [] (defwidget cpu []
(icon (icon
:widgetclass "cpu" :widgetclass "cpu"
:hover "${round(EWW_CPU.avg, 1)}%" :hover "${round(EWW_CPU.avg, 1)}%"
:percentage "${round(EWW_CPU.avg, 1)}" :percentage {round(EWW_CPU.avg, 1)}
:image "images/cpu.png")) :image "images/cpu.png"))
(defwidget ram [] (defwidget ram []
(icon (icon
:widgetclass "ram" :widgetclass "ram"
:hover "${round(EWW_RAM.used_mem /(1024*1024*1024), 1)} GiB | ${round(EWW_RAM.used_mem_perc, 1)}%" :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")) :image "images/ram.png"))
(defwidget audio [] (defwidget audio []
(icon (icon
:widgetclass "${volume.muted == 1 ? "muted" : "volume"}" :widgetclass {volume.muted == 1 ? "muted" : "volume"}
:hover "${volume.volume}%" :hover "${volume.volume}%"
:percentage "${volume.volume >= 0 && volume.volume <= 100 ? volume.volume : 0}" :percentage {volume.volume >= 0 && volume.volume <= 100 ? volume.volume : 0}
:image "${volume.muted == 1 ? "images/volumeMuted.png" : "images/volume.png"}")) :image {volume.muted == 1 ? "images/volumeMuted.png" : "images/volume.png"}))
(defwidget brightness [] (defwidget brightness []
(icon (icon
:widgetclass "brightness" :widgetclass "brightness"
:hover "${brightnessValue / 960}%" :hover "${brightnessValue / 960}%"
:percentage "${brightnessValue / 960}" :percentage {brightnessValue / 960}
:image "images/brightness.png")) :image "images/brightness.png"))
(defwidget network [] (defwidget network []
(icon (icon
:widgetclass "network" :widgetclass "network"
:hover "${network.name}" :hover {network.name}
:percentage "100" :percentage "100"
:image "images/${network.image}.png")) :image "images/${network.image}.png"))
(defwidget bluetooth [] (defwidget bluetooth []
(icon (icon
:widgetclass "bluetooth" :widgetclass "bluetooth"
:hover "${bluetooth.name}" :hover {bluetooth.name}
:percentage "${bluetooth.battery}" :percentage {bluetooth.battery}
:image "images/bluetooth.png")) :image "images/bluetooth.png"))
(defwidget battery [] (defwidget battery []
(icon (icon
:widgetclass {EWW_BATTERY.BAT1.status == "Charging" ? "battery" : EWW_BATTERY.total_avg > 25 ? "battery" : "batteryLow"} :widgetclass {EWW_BATTERY.BAT1.status == "Charging" ? "battery" : EWW_BATTERY.total_avg > 25 ? "battery" : "batteryLow"}
:hover "${round(EWW_BATTERY.total_avg, 1)}%" :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"})) :image {EWW_BATTERY.BAT1.status == "Charging" ? "images/charging.png" : EWW_BATTERY.total_avg > 25 ? "images/battery.png" : "images/batteryLow.png"}))
(defwidget power [] (defwidget power []
@ -161,19 +90,7 @@
:percentage "0" :percentage "0"
:image "images/power.png")) :image "images/power.png"))
(defwidget smallSpacer []
(box
:width 2))
(defwidget space []
(box
:width 5))
(defwidget seperator []
(box
(label
:text "|"
)))
;; Widget blocks ;; Widget blocks
@ -187,8 +104,8 @@
:visible {media.status == "Playing" ? true : false} :visible {media.status == "Playing" ? true : false}
(smallSpacer) (smallSpacer)
(label (label
:text "${media.name}" :text {media.name}
:tooltip "${media.name}" :tooltip {media.name}
:limit-width 40) :limit-width 40)
(smallSpacer))) (smallSpacer)))
@ -259,7 +176,7 @@
:space-evenly false :space-evenly false
:halign "start" :halign "start"
(space) (space)
(workspaces))) (time)))
(defwidget center [monitor] (defwidget center [monitor]
(box (box
@ -267,7 +184,7 @@
:space-evenly false :space-evenly false
:halign "center" :halign "center"
(workspaces (workspaces
:monitor "${monitor}") :monitor {monitor})
)) ))
(defwidget end [] (defwidget end []
@ -294,10 +211,24 @@
(space))) (space)))
(defwidget bar [monitor]
(centerbox :orientation "h"
(start)
(center
:monitor {monitor})
(end)))
(defwindow bar [monitor width height]
;; Window definition :monitor {monitor}
:class "bar"
:geometry (geometry
(include "newbar.yuck") :x "0%"
:y "5px"
:width "${width}px"
:height "${height}px"
:anchor "top center")
:stacking "fg"
:exclusive true
(bar
:monitor {monitor}))

View file

@ -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)))

80
templates.yuck Normal file
View file

@ -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 "|"
)))

28
variables.yuck Normal file
View file

@ -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`)