summaryrefslogtreecommitdiff
path: root/.config/eww
diff options
context:
space:
mode:
Diffstat (limited to '.config/eww')
-rw-r--r--.config/eww/eww.scss118
-rw-r--r--.config/eww/eww.yuck18
-rw-r--r--.config/eww/pollers.yuck14
-rwxr-xr-x.config/eww/scripts/getvol9
-rwxr-xr-x.config/eww/scripts/update_workspaces34
-rwxr-xr-x.config/eww/scripts/update_x_names33
-rw-r--r--.config/eww/widgets.yuck92
7 files changed, 318 insertions, 0 deletions
diff --git a/.config/eww/eww.scss b/.config/eww/eww.scss
new file mode 100644
index 0000000..198a00b
--- /dev/null
+++ b/.config/eww/eww.scss
@@ -0,0 +1,118 @@
+*
+{
+ all: unset;
+}
+
+/* separator */
+
+.sepbar
+{
+ color: #D9E0EE;
+ font-family: Iosevka;
+ font-size: 12px;
+ margin-right: 5px;
+ margin-left: 5px;
+}
+
+/* bar */
+.bar
+{
+ background-color: rgba(#000B0E, 0.72);
+}
+
+/* time*/
+.time-cpu-mem
+{
+ margin-right: 15px;
+}
+.time-label
+{
+ color: #91d7e3;
+ font-family: Iosevka;
+ font-size: 12px;
+}
+
+/* mem cpu */
+.vol
+{
+ color: #6434ff;
+ background-color: rgba(#232323, 1.0);
+ border-radius: 0px;
+ margin-right: 6px;
+}
+.mem
+{
+ color: #ed8dff;
+ background-color: rgba(#232323, 1.0);
+ border-radius: 0px;
+ margin-right: 6px;
+}
+.cpu
+{
+ color: #606060;
+ background-color: rgba(#232323, 1.0);
+ border-radius: 0px;
+ margin-right: 6px;
+}
+.cpu-and-mem
+{
+ border-radius: 0px;
+ margin-right: 0px;
+}
+
+/* workspaces */
+.active
+{
+ color: #ed8dff;
+}
+
+.workspaces
+{
+ padding-top: 5px;
+ font-size: 12px;
+}
+
+.mail
+{
+ color: #ed8dff;
+ font-family: Iosevka;
+ font-size: 12px;
+}
+
+.t1
+{
+ color: #c6a0f6;
+ font-family: Iosevka;
+ font-size: 12px;
+}
+
+.weather
+{
+ color: #ff5300;
+ font-family: Iosevka;
+ font-size: 12px;
+}
+
+.battery
+{
+ color: #d42ea2;
+ font-family: Iosevka;
+ font-size: 12px;
+}
+
+.classes
+{
+ margin-left: 10px;
+}
+
+.class
+{
+ margin-right: 10px;
+ color: #D9E0EE;
+ padding: 4px;
+ margin-top: 0px;
+ border-radius: 0px;
+ background: rgba(#042429, 0.48);
+ font-family: Iosevka;
+ font-size: 12px;
+}
diff --git a/.config/eww/eww.yuck b/.config/eww/eww.yuck
new file mode 100644
index 0000000..335a687
--- /dev/null
+++ b/.config/eww/eww.yuck
@@ -0,0 +1,18 @@
+(include "pollers.yuck")
+(include "widgets.yuck")
+
+(defwindow bar
+ :monitor 0
+ :windowtype "dock"
+ :geometry (geometry :x "0%"
+ :y "0%"
+ :width "100%"
+ :height "20px"
+ :anchor "top center")
+ :reserve (struts :side "top" :distance "2.3%")
+ (bar))
+
+;; Local Variables:
+;; mode: scheme
+;; compile-command: "eww daemon --restart; eww open bar"
+;; End:
diff --git a/.config/eww/pollers.yuck b/.config/eww/pollers.yuck
new file mode 100644
index 0000000..c3cdecf
--- /dev/null
+++ b/.config/eww/pollers.yuck
@@ -0,0 +1,14 @@
+(defpoll volume :interval "2s" "scripts/getvol")
+(defpoll time :interval "30s" "date '+%H:%M'")
+(defpoll date :interval "30s" "date '+%b %d'")
+(defpoll ws :interval "0.15s" "scripts/update_workspaces")
+(defpoll cs :interval "0.15s" "scripts/update_x_names")
+(defpoll mail :interval "60s" "$HOME/.local/bin/mail-string")
+(defpoll t1 :interval "60s" "$HOME/.local/bin/t1-string")
+(defpoll weather :interval "1800s" "$HOME/.local/bin/string-weather")
+(defpoll batperc :interval "60s" "echo \"$(cat /sys/class/power_supply/BAT0/capacity)%\"")
+
+;; Local Variables:
+;; mode: scheme
+;; compile-command: "eww daemon --restart; eww open bar"
+;; End:
diff --git a/.config/eww/scripts/getvol b/.config/eww/scripts/getvol
new file mode 100755
index 0000000..9fbe60f
--- /dev/null
+++ b/.config/eww/scripts/getvol
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+RUNNING_SINK=$(pactl list sinks | awk '
+ /^Sink #/ {sink=$2}
+ /State: RUNNING/ {print sink}
+' | head -n1)
+
+pactl list sinks | grep -A 20 "^Sink $RUNNING_SINK" | grep '^[[:space:]]Volume:' | \
+ head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,'
diff --git a/.config/eww/scripts/update_workspaces b/.config/eww/scripts/update_workspaces
new file mode 100755
index 0000000..4fb1b1c
--- /dev/null
+++ b/.config/eww/scripts/update_workspaces
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+gib_workspace_names() {
+ wmctrl -d \
+ | awk '{ print $1 " " $2 " " $9 }' \
+ | grep -v NSP
+}
+
+gib_workspace_yuck() {
+ buffered=""
+ gib_workspace_names | while read -r id active name; do
+ name="${name#*_}"
+ if [ "$active" == '*' ]; then
+ active_class="active"
+ else
+ active_class="inactive"
+ fi
+
+ if wmctrl -l | grep --regexp '.*\s\+'"$id"'\s\+.*' >/dev/null; then
+ button_class="occupied"
+ button_name="●"
+ else
+ button_class="empty"
+ button_name="○"
+ fi
+ buffered+="(button :class \"$button_class $active_class\" :onclick \"wmctrl -s $id\" \"$button_name\")"
+ echo -n "$buffered"
+ buffered=""
+ done
+}
+
+box_attrs=':orientation "h" :class "workspaces" :space-evenly false :halign "center" :valign "center" :vexpand false :spacing 8 '
+
+echo "(box $box_attrs $(gib_workspace_yuck))"
diff --git a/.config/eww/scripts/update_x_names b/.config/eww/scripts/update_x_names
new file mode 100755
index 0000000..63117ef
--- /dev/null
+++ b/.config/eww/scripts/update_x_names
@@ -0,0 +1,33 @@
+#!/run/current-system/profile/bin/guile \
+-s
+!#
+
+(use-modules (ice-9 popen)
+ (ice-9 textual-ports)
+ (ice-9 rdelim))
+
+(define cmd "wmctrl -l | awk -v ws=\"$(wmctrl -d | awk '$2 == \"*\" {print $1}')\" '$2 == ws {print}' | cut -d ' ' -f 5-")
+
+(define box-attrs '(:class "classes"
+ :orientation "h"
+ :valign "center"
+ :halign "start"
+ :space-evenly "false"))
+
+(define titles
+ (let* ((process (open-pipe* OPEN_READ "sh" "-c" cmd))
+ (output (get-string-all process)))
+ (close-pipe process)
+ output))
+
+(define labels
+ (map (lambda (t) `(eventbox
+ :onclick ,(string-concatenate `("wmctrl -a \"" ,t "\""))
+ (label :class "class"
+ :text ,t
+ :truncate true
+ :valign "center")))
+ (filter (lambda (s) (not (string=? s "")))
+ (string-split titles #\newline))))
+
+(write `(box ,@box-attrs ,@labels))
diff --git a/.config/eww/widgets.yuck b/.config/eww/widgets.yuck
new file mode 100644
index 0000000..c7ea4d4
--- /dev/null
+++ b/.config/eww/widgets.yuck
@@ -0,0 +1,92 @@
+(defwidget bar []
+ (box :class "bar"
+ :orientation "h"
+ (classeswidget)
+ (workspaces)
+ (power-time-cpu-mem)))
+
+(defwidget power-time-cpu-mem []
+ (box :class "time-cpu-mem"
+ :halign "end"
+ :valign "center"
+ :space-evenly "false"
+ :orientation "h"
+ (cpu-and-mem)
+ (sep)
+ (weatherwidget)
+ (sep)
+ (mailwidget)
+ (sep)
+ (t1widget)
+ (sep)
+ (batterywidget)
+ (sep)
+ (label :text "${date}, "
+ :class "time-label"
+ :halign "end"
+ :valign "center"
+ :tooltip "time")
+ (label :text time
+ :class "time-label"
+ :halign "end"
+ :valign "center"
+ :tooltip "time")))
+
+(defwidget cpu-and-mem []
+ (box :class "cpu-and-mem"
+ :orientation "h"
+ :halign "end"
+ :valign "center"
+ :space-evenly "false"
+ (circular-progress :class "vol"
+ :value volume
+ :thickness 6)
+ (circular-progress :class "cpu"
+ :value {EWW_CPU.avg}
+ :thickness 6)
+ (circular-progress :class "mem"
+ :value {EWW_RAM.used_mem_perc}
+ :thickness 6)))
+
+(defwidget batterywidget []
+ (label
+ :class "battery"
+ :text batperc))
+
+(defwidget t1widget []
+ (label
+ :class "t1"
+ :text "${t1}"))
+
+(defwidget mailwidget []
+ (label
+ :class "mail"
+ :text "${mail}"))
+
+(defwidget weatherwidget []
+ (label
+ :class "weather"
+ :text "${weather}"))
+
+(defwidget classeswidget []
+ (literal :content cs))
+
+(defwidget iconwidget []
+ (image
+ :path "assets/raven.png"
+ :class "icon"
+ :image-height 20
+ :preserve-aspect-ratio true))
+
+(defwidget workspaces []
+ (literal :content ws))
+
+(defwidget sep []
+ (box :orientation "h"
+ :valign "center"
+ (label :class "sepbar" :text "|")))
+
+;; Local Variables:
+;; mode: scheme
+;; compile-command: "eww daemon --restart; eww open bar"
+;; End: