add: eww config (needs to be implemented)

This commit is contained in:
ooks-io 2023-11-13 12:35:36 +13:00
parent 307debc596
commit 1741639dd1
10 changed files with 318 additions and 295 deletions

View file

@ -1,295 +0,0 @@
(defwidget bar []
(centerbox :orientation "v" :hexpand false
(box :valign "start" :hexpand false :vexpand true :orientation "v" :space-evenly false
(launch)
(dashbutton)
(powerbutton)
)
(workspaces :halign "center" :vexpand true :hexpand false :orientation "v")
(box :valign "end" :hexpand false :vexpand true :orientation "v" :space-evenly false
(battery)
(wifi)
(mem :thickness 4 :icon "")
(cpu :thickness 4 :icon "")
(disk :thickness 4 :icon "")
(time)
)
)
)
(defpoll brightness :interval "999h" :initial 0 `brightnessctl -m | awk -F, '{print substr($4, 0, length($4)-1)}'`)
(defpoll volume :interval "999h" :initial 0 `pamixer --get-volume`)
(defpoll micvolume :interval "999h" :initial 0 `pamixer --get-volume --source 1`)
(defwidget dashboard []
(box :orientation "v"
(box :class "info_box" :orientation "v" :space-evenly false
(box :class "calendar_box"
(calendar :width 200 :class "cal")
)
(box :class "slider_box" :orientation "v" :vexpand false :hexpand false
(box :space-evenly false
(label :class "slider_icon" :text "")
(scale :min 1 :max 101 :width 315 :class "brightness_slider" :value brightness :onchange "brightnessctl set {}%" :height 10)
)
(box :space-evenly false
(label :class "slider_icon" :text "墳")
(scale :min 1 :max 101 :width 315 :class "volume_slider" :value volume :onchange "pamixer --set-volume $(echo {} | sed 's/[.].*$//')")
)
(box :space-evenly false
(label :class "slider_icon" :text "")
(scale :min 1 :max 101 :width 315 :class "micvolume_slider" :value micvolume :onchange "pamixer --set-volume $(echo {} | sed 's/[.].*$//') --source 1")
)
)
(box :class "sysinfo_box" :orientation "h" :vexpand true :spacing 15
(mem :thickness 12 :icon "")
(cpu :thickness 12 :icon "")
(disk :thickness 12 :icon "")
)
)
(box :class "notification_box"
)
)
)
;; Variables
(defvar time false)
(defvar cal false)
;; ━━━ WIDGETS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
;; ━━━ MEMORY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defwidget dashbutton[]
(button :class "reg-btn dashbutton" :onclick "eww open dashboard --toggle" "舘")
)
;; ━━━ MEMORY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defwidget mem [icon thickness]
(box :vexpand "false" :hexpand "false"
(circular-progress :value {EWW_RAM.used_mem_perc}
:class "membar"
:thickness {thickness}
:start-at 75
(label :class "iconmem" :text {icon})
)
)
)
;; ━━━ CPU ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defwidget cpu [icon thickness]
(box :vexpand "false" :hexpand "false"
(circular-progress :value {EWW_CPU.avg}
:class "cpubar"
:thickness {thickness}
:start-at 75
(label :class "iconcpu" :text {icon})
)
)
)
;; ━━━ DISK ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defwidget disk [icon thickness]
(box :vexpand "false" :hexpand "false"
(circular-progress :value {EWW_DISK["/"].used_perc}
:class "diskbar"
:thickness {thickness}
:start-at 75
(label :class "icondisk" :text {icon})
)
)
)
;; ━━━ WIFI ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defvar wifi "{}")
(defpoll wifi :interval "30s" "./scripts/wifi.sh")
(defwidget wifi []
(box :vexpand false :hexpand false :orientation "v"
(label :text {wifi.icon}
:limit-width 10
:tooltip {wifi.status}
:class "wifi"
)
)
)
;; ━━━ BATTERY ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defvar battery "{}")
(defpoll battery :interval "60s" "./scripts/battery.sh")
(defwidget battery []
(label :text {battery.icon}
:limit-width 10
:tooltip "${battery.status}: ${battery.percent}"
:class "battery"
)
)
;; ━━━ VOLUME ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defvar volume-level 50)
(defvar volume-muted false)
(defwindow volume
:monitor 0
:geometry (geometry :y "100px" :x "0px" :width "250px" :height "200px" :anchor "center bottom")
:windowtype "dock"
:wm-ignore true
:stacking "fg"
(box :class "volume-window"
:orientation "v"
:space-evenly "false"
(box :class "volume-widget"
:orientation "h"
:space-evenly false
:spacing 10
(label :text {volume-muted ? "" :
volume-level == 0 ? "" :
volume-level < 32 ? "" :
volume-level < 65 ? "" :
""}
:class 'volume-icon ${volume-muted ? "volume-icon-muted" : ""}'
)
(scale :class 'volume-slider ${volume-muted ? "volume-slider-muted" : ""}'
:hexpand "true"
:min 0
:max 100
:height 8
:marks true
:value volume-level
:onchange "pamixer --set-volume {}"))))
;; ━━━ TIME ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
(defpoll hour :interval "10s" "date +%H")
(defpoll minute :interval "10s" "date +%M")
(defpoll dateVar :interval "600s" "date '+%A %d.%m.%y'")
(defwidget time []
(eventbox :cursor "hand" :hexpand false :vexpand false
:tooltip "${dateVar}"
(box :orientation "v" :hexpand false :vexpand false :space-evenly false :class "clock"
(button :class "date"
:onclick "" "${hour}")
(button :class "date"
:onclick "" "${minute}")
)
)
)
(defvar bright-level 50)
(defvar bright-muted false)
(defwindow brightness
:monitor 0
:geometry (geometry :y "-60px" :x "60px" :width "300px" :height "150px" :anchor "bottom left")
:wm-ignore true
:stacking "fg"
(box :class "volume-window"
:orientation "v"
:space-evenly "false"
(box :class "volume-widget"
:orientation "h"
:space-evenly false
:spacing 10
(label :text ""
:class 'volume-icon'
)
(scale :class 'volume-slider'
:hexpand "true"
:min 0
:max 100
:height 8
:marks true
:value bright-level
:onchange "brightnessctl set {}%"))))
(defwidget launch []
(button :class "reg-btn launchbutton"
:hexpand true
:onclick "wofi --show run --xoffset=1670 --yoffset=12 --width=230px --height=984 --style=$HOME/.config/wofi.css --term=footclient --prompt=Run &" "")
)
(defwidget powerbutton []
(eventbox :cursor "hand"
(button :class "reg-btn powerbutton"
:onclick "eww open powermenu --toggle &" "")
)
)
(defwidget powermenucontent []
(box :orientation "h"
:class "powermenu-container"
(box :class "shutdown-btn-box"
:orientation "h"
(button :class "btn"
:tooltip "Shutdown"
:onclick "eww close powermenu && shutdown now"
"⏻")
)
(box :class "reboot-btn-box"
:orientation "h"
(button :class "btn"
:tooltip "Reboot"
:onclick "eww close powermenu && reboot"
"")
)
(box :class "exit-btn-box"
:orientation "h"
(button :class "btn"
:tooltip "Suspend"
:onclick "systemctl suspend"
"")
)
)
)
(defwindow powermenu
:monitor 0
:geometry (geometry :x "0%"
:y "0%"
:width "30%"
:height "15%"
:anchor "center center")
:wm-ignore true
(powermenucontent))
(deflisten workspaces_listen "./scripts/workspaces.sh")
(defwidget workspaces []
(literal :content workspaces_listen))
(defwindow dashboard
:monitor 0
:geometry (geometry
:height "1080px"
:width "350px"
:x "48px"
:y "0px"
:anchor "top left")
:stacking "fg"
:class "dashboard"
(dashboard))
(defwindow bar
:monitor 0
:exclusive false
:geometry (geometry :height "1080px" :x "-4px" :y "0px"
:width "52px"
:anchor "top left")
:stacking "fg"
(bar))

View file

@ -0,0 +1,18 @@
;;Variables
;;Clock
(defpoll TIME :interval "30s" "date +'%I:%M %p'")
;;Battery
(defpoll BATTERY-PERCENTAGE :interval "30s" "./scripts/bat.sh --percentage")
(defpoll BATTERY-COLOR :interval "5s" "./scripts/batterytest.sh --color")
(defpoll BATTERY-STATUS :interval "5s" "./scripts/bat.sh --status")
(defpoll BATTERY-ICON :interval "5s" "./scripts/battery.sh --icons")
;;Earbuds
(defpoll EARBUDS_CONNECTION :interval "5s" "./scripts/earbuds.sh --connection")
(defpoll EARBUDS_RIGHT :interval "5s" "./scripts/earbuds.sh --left")
(defpoll EARBUDS_LEFT :interval "5s" "./scripts/earbuds.sh --right")
;;Workspaces

View file

@ -0,0 +1,45 @@
;;Widgets
(deflisten workspace "./scripts/workspaces.sh")
;;Clock -------------------------------------------------------------------------------------------
(defwidget widget-clock []
(label
:text "${TIME}"
:class "text"
:halign "left"
:valign "center"
)
)
;; Battery
(defwidget widget-bat-bar []
(progress
:class "${BATTERY-COLOR}"
:value "${BATTERY-PERCENTAGE}"
:orientation "horizontal"
:valign "center"
:halign "center"
:tooltip "${BATTERY-PERCENTAGE}"
)
)
(defwidget widget-battery []
(label
:text "${BATTERY-PERCENTAGE}${BATTERY-ICON}"
:class "${BATTERY-COLOR}"
:orientation "horizontal"
:valign "center"
:halign "center"
)
)
;;Earbuds Widget
(defwidget widget-earbuds []
(label
:text "${EARBUDS_LEFT}${EARBUDS_CONNECTION}${EARBUDS_RIGHT}"
:class "${BATTERY-COLOR}"
:orientation "horizontal"
:valign "center"
:halign "center"
)
)

View file

@ -0,0 +1,62 @@
;;Clock -----------------------------------------
(defwindow window-clock
:monitor 0
:geometry (geometry
:anchor "top left"
:x "0.8%"
:y "-2.6%"
:width "0%"
:height "0%"
)
:stacking "fg"
:exclusive "true"
:focusable "false"
(widget-clock)
)
;;Battery ---------------------------------------
(defwindow window-battery
:monitor 0
:geometry (geometry
:anchor "top right"
:x "0%"
:y "-2.6%"
:width "0%"
:height "0%"
)
:stacking "fg"
:exclusive "true"
:focusable "false"
(widget-battery)
)
;;Earbuds window
(defwindow window-earbuds
:monitor 0
:geometry (geometry
:anchor "top center"
:x "0%"
:y "-2.6%"
:width "0%"
:height "0%"
)
:stacking "fg"
:exclusive "true"
:focusable "false"
(widget-earbuds)
)
;;Bar -------------------------------------------
(defwindow bar
:monitor 0
:geometry (geometry
:anchor "top center"
:x "0"
:y "0"
:width "100%"
:height "3%"
)
:stacking "bg"
:exclusive "true"
:focusable "false"
" "
)

View file

@ -0,0 +1,12 @@
* {
font-family: "JetBrains Mono Nerd Font";
}
text {
font-family: "JetBrains Mono Nerd Font";
}
.bar {
font-size: 12px;
}

View file

@ -0,0 +1,4 @@
;;Imports
(include "eww-variables.yuck")
(include "eww-windows.yuck")
(include "eww-widgets.yuck")

View file

@ -0,0 +1,31 @@
#!/bin/sh
battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
battery_status=$(cat /sys/class/power_supply/BAT0/status)
case "$1" in
"--percentage")
echo "$battery_level"
;;
"--color")
if [ $battery_level -le 20 ]; then
echo "progbarlow"
elif [ $battery_level -le 50 ]; then
echo "progbarmid"
else
echo "progbarhigh"
fi
;;
"--status")
if [ "$battery_status" = "Charging" ]; then
echo "Charging"
elif [ "$battery_status" = "Discharging" ]; then
echo "Discharging"
else
echo "we full"
fi
;;
*)
echo "Invalid argument try --color, --percentage"
;;
esac

View file

@ -0,0 +1,81 @@
#!/bin/sh
get_battery_level() {
echo $(acpi -b | sed -e "s/[A-Za-z:,-.%]\+//g" | awk 'NR == 1 {print $2}')
}
get_adapter_status() {
echo "$(acpi -b | awk 'NR == 1 {print $3}' | sed -e 's/,//g')"
}
get_battery_icons() {
battery_level=$(get_battery_level)
battery_level_trunc=$(($battery_level / 10 * 10))
if [ "$(get_adapter_status)" == "Charging" ]; then
# Charging
case "$battery_level_trunc" in
"100" ) echo " 󰂅 "
return ;;
"90" ) echo " 󰂋 "
return ;;
"80" ) echo " 󰂊 "
return ;;
"70" ) echo " 󰢞 "
return ;;
"60" ) echo " 󰂉 "
return ;;
"50" ) echo " 󰢝 "
return ;;
"40" ) echo " 󰂈 "
return ;;
"30" ) echo " 󰂇 "
return ;;
"20" ) echo " 󰂆 "
return ;;
"10" ) echo " 󰢜 "
return ;;
"0" ) echo " 󰢜 "
return ;;
esac
else
# Discharging
case "$battery_level_trunc" in
"100" ) echo " 󰁹 "
return ;;
"90" ) echo " 󰂂 "
return ;;
"80" ) echo " 󰂁 "
return ;;
"70" ) echo " 󰂀 "
return ;;
"60" ) echo " 󰁿 "
return ;;
"50" ) echo " 󰁾 "
return ;;
"40" ) echo " 󰁽 "
return ;;
"30" ) echo " 󰁼 "
return ;;
"20" ) echo " 󰁻 "
return ;;
"10" ) echo " 󰁺 "
return ;;
"0" ) echo " 󰁺 "
return ;;
esac
fi
}
# Main
if [ "$1" == "--level" ]; then
get_battery_level
elif [ "$1" == "--icons" ]; then
get_battery_icons
fi

View file

@ -0,0 +1,30 @@
#!/bin/sh
BAT_PATH="/sys/class/power_supply/BAT0"
bat_lvl=$(cat "$BAT_PATH/capacity")
bat_stat=$(cat "$BAT_PATH/status")
case "$1" in
"--level")
printf "%s\n" "$bat_lvl"
;;
"--status")
printf "%s\n" "$bat_stat"
;;
"--color")
if [ "$bat_stat" = "Charging" -o "$bat_stat" = "Not charging" ]; then
printf "batup\n"
elif [ "$bat_stat" = "Discharging" ] && [ "$bat_lvl" -le 25 ]; then
printf "batdownred\n"
elif [ "$bat_stat" = "Discharging" ] && [ "$bat_lvl" -le 50 ]; then
printf "batdown25\n"
elif [ "$bat_stat" = "Discharging" ] && [ "$bat_lvl" -gt 50 ]; then
printf "batdown50\n"
else
printf "batunknown\n"
fi
;;
*)
printf "Invalid option\n"
;;
esac

View file

@ -0,0 +1,35 @@
#!/usr/bin/env bash
BUDS_STATUS=$(earbuds status -o json -q)
# Check if the earbuds are connected
IS_CONNECTED=$(echo $BUDS_STATUS | jq -r '.status // empty')
if [ "$IS_CONNECTED" == "error" ] || [ -z "$IS_CONNECTED" ]; then
if [ "$1" = "--connection" ]; then
echo " 󱡐 "
fi
exit 0
fi
LEFT=$(echo $BUDS_STATUS | jq -r '.payload.batt_left // empty')
RIGHT=$(echo $BUDS_STATUS | jq -r '.payload.batt_right // empty')
if [ "$(echo $BUDS_STATUS | jq -r '.payload.placement_left // empty')" == "3" ] && [ -n "$LEFT" ]; then
LEFT="󱐋$LEFT"
fi
if [ "$(echo $BUDS_STATUS | jq -r '.payload.placement_right // empty')" == "3" ] && [ -n "$RIGHT" ]; then
RIGHT="󱐋$RIGHT"
fi
case "$1" in
"--left")
[ -n "$LEFT" ] && echo -n "$LEFT"
;;
"--right")
[ -n "$RIGHT" ] && echo -n "$RIGHT"
;;
"--connection")
echo -n " 󱡏 "
;;
esac