Add battery, clock and window widget in eww

This commit is contained in:
2023-02-14 01:02:51 +09:00
parent dc7fdfe785
commit ff5f7b482b
7 changed files with 116 additions and 13 deletions
+10
View File
@@ -0,0 +1,10 @@
(defpoll icon :interval "1s" "./bar/battery/get-battery.sh icon")
(defpoll percent :interval "1s" "./bar/battery/get-battery.sh percent")
(defwidget battery []
(box :class "battery module floating"
:spacing 6
(label :valign "center" :class "icon" :text "${icon}")
(label :valign "center" :class "percent" :text "${percent}%"))
)
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
bat=/sys/class/power_supply/BAT0/
per="$(cat "$bat/capacity")"
icon() {
[ $(cat "$bat/status") = Charging ] && echo "" && exit
if [ "$per" -gt "90" ]; then
icon=""
elif [ "$per" -gt "80" ]; then
icon=""
elif [ "$per" -gt "70" ]; then
icon=""
elif [ "$per" -gt "60" ]; then
icon=""
elif [ "$per" -gt "50" ]; then
icon=""
elif [ "$per" -gt "40" ]; then
icon=""
elif [ "$per" -gt "30" ]; then
icon=""
elif [ "$per" -gt "20" ]; then
icon=""
elif [ "$per" -gt "10" ]; then
icon=""
elif [ "$per" -gt "0" ]; then
icon=""
else
icon=""
fi
echo "$icon"
}
percent() {
echo $per
}
[ "$1" = "icon" ] && icon && exit
[ "$1" = "percent" ] && percent
+13
View File
@@ -0,0 +1,13 @@
(defpoll time :interval "5s" `date +'{"date": "%b %m", "hour": "%H", "minute": "%M", "day": "%A"}'`)
(defwidget clock []
(box
:class "module accent bold"
(label
:text "${time.hour}:${time.minute}"
:class "hour")))
(defwidget date []
(box
:class "module bold"
(label :text "${time.date}")))
+30 -4
View File
@@ -1,15 +1,41 @@
@import 'colors';
* {
font-family: "monospace";
}
.bar {
background-color: $base00;
color: $base05;
};
}
.module {
margin: 0 5px;
};
padding: 0 10px;
}
.accent {
background-color: $base0C;
color: $base00;
};
}
.bold {
font-weight: bold;
}
.floating {
background: $base01;
border-radius: 10px;
margin: 5px;
}
.battery {
.icon {
font-size: 20px;
}
.percent {
margin-left: -5px;
font-size: 16px;
font-weight: 500;
}
}
+9 -9
View File
@@ -1,22 +1,22 @@
(include "./bar/workspaces/eww.yuck")
(include "./bar/window/eww.yuck")
(include "./bar/clock.yuck")
(include "./bar/battery/eww.yuck")
(defwidget left []
(box
:space-evenly false
:halign "start"
(workspaces)))
(workspaces)
(window)))
(defwidget right []
(box
:space-evenly false
;align "end"
;(volume-module)
;(bluetooth)
;(net)
;(label :class "seperator" :text "|")
;(sys)
;(label :class "seperator" :text "|")
;(clock_module)
:halign "end"
(battery)
(date)
(clock)
))
(defwidget center []
+8
View File
@@ -0,0 +1,8 @@
(deflisten title :initial "..." "./bar/window/get-window-title.sh")
(defwidget window []
(box
:class "floating module"
(label :text "${title}"
)
))
+5
View File
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
hyprctl activewindow -j | jq --raw-output .title
socat -u UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock - | stdbuf -o0 grep '^activewindow>>' | stdbuf -o0 awk -F '>>|,' '{print $3}'