replace top bar with eww bar

This commit is contained in:
Schrottkatze 2024-08-28 09:12:28 +02:00
parent fcb7c0cd68
commit ac3df09b6b
Signed by: schrottkatze
SSH key fingerprint: SHA256:hXb3t1vINBFCiDCmhRABHX5ocdbLiKyCdKI4HK2Rbbc
8 changed files with 172 additions and 194 deletions

View file

@ -1,85 +1 @@
(defwindow topBar
:monitor 0
:stacking "fg"
:windowtype "normal"
:wm-ignore true
:exclusive true
:geometry (geometry
:width "100%"
:height "32px"
:anchor "top center")
(topBar))
(defwidget topBar []
(overlay
:class "topBar"
(centerbox
(box
:halign "start"
:spacing 12
:space-evenly false
(label :text " ")
(cpu)
(sep)
(mem)
)
(box
:halign "center"
(label :text "Hi, jade! :3")
)
(box
:halign "end"
(time)
)
)
(box
:class "transFlag"
:height 1
( flagEl :color "#5BCEFA")
( flagEl :color "#F5A9B8")
( flagEl :color "#FFFFFF")
( flagEl :color "#F5A9B8")
( flagEl :color "#5BCEFA")
)
)
)
(defwidget sep []
(label :text "|")
)
(defwidget time []
(label
:markup {
formattime(
EWW_TIME,
"<span foreground=\"#d65d0e\"></span> %Y<span foreground=\"#7c6f64\">-</span>%m<span foreground=\"#7c6f64\">-</span>%d <span foreground=\"#d65d0e\"></span> %H<span foreground=\"#7c6f64\">:</span>%M<span foreground=\"#7c6f64\">:</span>%S "
)
}
)
)
(defwidget cpu []
(box
:class "cpuIndicator"
(label
:markup "<span foreground=\"#d65d0e\"></span> ${strlength(round(EWW_CPU.avg, 0)) == 1 ? " ${round(EWW_CPU.avg, 0)}" : round(EWW_CPU.avg, 0)}<span foreground=\"#7c6f64\">%</span>"
)
)
)
(defwidget mem []
(box
:class "memIndicator"
(label
:markup "<span foreground=\"#d65d0e\"> </span> ${round(EWW_RAM.used_mem_perc, 0)}<span foreground=\"#7c6f64\">%</span>"
)
)
)
(defwidget flagEl [color]
(box
:style "border-bottom: 2px solid ${color}"
:halign "fill"
)
)
(include "topBar/topBar.yuck")

View file

@ -0,0 +1,55 @@
#!/usr/bin/env nu
const ICONS = [
[ normal charging];
[ 󰂎 󰢟 ]
[ 󰁺 󰢜 ]
[ 󰁻 󰂆 ]
[ 󰁼 󰂇 ]
[ 󰁽 󰂈 ]
[ 󰁾 󰢝 ]
[ 󰁿 󰂉 ]
[ 󰂀 󰢞 ]
[ 󰂁 󰂊 ]
[ 󰂂 󰂋 ]
[ 󰁹 󰂅 ]
];
def main [ path: string ] {
loop {
let fract = get_bat_charge_fraction $path;
let is_charging = get_bat_charging_status $path;
let percent = ($fract * 100) | math round;
print $"<span foreground=\"#d65d0e\">(get_bat_icon $fract $is_charging)</span> ($percent)<span foreground=\"#7c6f64\">%</span>";
sleep 2sec;
}
}
def get_bat_charge_fraction [
path: string
] {
let energy_full = open $"/sys/class/power_supply/($path)/energy_full" | into float;
let energy_now = open $"/sys/class/power_supply/($path)/energy_now" | into float;
$energy_now / $energy_full
}
def get_bat_charging_status [
path: string
] {
let status = open $"/sys/class/power_supply/($path)/status";
if ($status == Charging) {
true
} else {
false
}
}
def get_bat_icon [
frac: float
is_charging = false
] {
$ICONS | get (($frac * 10) | math round) | get (if ($is_charging) { "charging" } else { "normal" })
}

View file

@ -0,0 +1,27 @@
(deflisten bat0
:initial "<span foreground=\"#cc241d\">BAT0 ERR</span>"
{ "~/.config/eww/scripts/bat.nu BAT0"}
)
(deflisten bat1
:initial "<span foreground=\"#cc241d\">BAT1 ERR</span>"
{ "~/.config/eww/scripts/bat.nu BAT1"}
)
(defwidget cpu []
(box
:class "cpuIndicator"
(label
:markup "<span foreground=\"#d65d0e\"></span> ${strlength(round(EWW_CPU.avg, 0)) == 1 ? " ${round(EWW_CPU.avg, 0)}" : round(EWW_CPU.avg, 0)}<span foreground=\"#7c6f64\">%</span>"
)
)
)
(defwidget mem []
(box
:class "memIndicator"
(label
:markup "<span foreground=\"#d65d0e\"> </span> ${round(EWW_RAM.used_mem_perc, 0)}<span foreground=\"#7c6f64\">%</span>"
)
)
)

View file

@ -0,0 +1,10 @@
(defwidget time []
(label
:markup {
formattime(
EWW_TIME,
"<span foreground=\"#d65d0e\"></span> %Y<span foreground=\"#7c6f64\">-</span>%m<span foreground=\"#7c6f64\">-</span>%d <span foreground=\"#d65d0e\"></span> %H<span foreground=\"#7c6f64\">:</span>%M<span foreground=\"#7c6f64\">:</span>%S "
)
}
)
)

View file

@ -0,0 +1,56 @@
(include "topBar/time.yuck")
(include "topBar/sysinfo.yuck")
(include "util.yuck")
(defwindow topBar
:monitor 0
:stacking "fg"
:windowtype "normal"
:wm-ignore true
:exclusive true
:geometry (geometry
:width "100%"
:height "32px"
:anchor "top center")
(topBar))
(defwidget topBar []
(overlay
:class "topBar"
(centerbox
(box
:halign "start"
:spacing 12
:space-evenly false
(label :text " ")
(cpu)
(sep)
(mem)
(sep)
(label :markup bat0)
(sep)
(label :markup bat1)
)
(box
:halign "center"
(systray
:icon-size 18
:spacing 3
)
)
(box
:halign "end"
(time)
)
)
(box
:class "transFlag"
:height 1
( flagEl :color "#5BCEFA")
( flagEl :color "#F5A9B8")
( flagEl :color "#FFFFFF")
( flagEl :color "#F5A9B8")
( flagEl :color "#5BCEFA")
)
)
)

View file

@ -0,0 +1,11 @@
(defwidget flagEl [color]
(box
:style "border-bottom: 3px solid ${color}"
:halign "fill"
)
)
(defwidget sep []
(label :text "|")
)

View file

@ -1,23 +0,0 @@
#!/usr/bin/env nu
const ICONS = [
[ 󰂎 󰢟 ]
[ 󰁺 󰢜 ]
[ 󰁻 󰂆 ]
[ 󰁼 󰂇 ]
[ 󰁽 󰂈 ]
[ 󰁾 󰢝 ]
[ 󰁿 󰂉 ]
[ 󰂀 󰢞 ]
[ 󰂁 󰂊 ]
[ 󰂂 󰂋 ]
[ 󰁹 󰂅 ]
];
def get_bat_percent [path: string] {
let energy_full = open $"/sys/class/power_supply/($path)/energy_full" | into float;
let energy_now = open $"/sys/class/power_supply/($path)/energy_now" | into float;
($energy_now / $energy_full) * 100
}

View file

@ -32,98 +32,12 @@
target = "sway-session.target";
};
settings = {
infobar = {
layer = "top";
position = "top";
modules-left = ["memory" "cpu" "network" "group/bats"];
modules-center = ["sway/window"];
modules-right = ["clock"];
"group/bats" = {
orientation = "inherit";
modules = ["battery#bat0" "battery#bat1" "upower#headphones"];
};
"battery#bat0" = {
adapter = "AC";
bat = "BAT0";
interval = 2;
format = "{icon} {capacity}% {time}";
format-charging = "󱐋{icon} {capacity}% {time}";
format-time = "{h}:{m}";
format-icons = [
"󰁺"
"󰁻"
"󰁼"
"󰁽"
"󰁾"
"󰁿"
"󰂀"
"󰂁"
"󰂂"
"󰁹"
];
tooltip = true;
tooltip-format = "BAT0: {cycles} cycles";
};
"battery#bat1" = {
adapter = "AC";
bat = "BAT1";
interval = 2;
format = "󱐋{icon} {capacity}% {time}";
format-time = "{H}:{M}";
format-icons = [
"󰁺"
"󰁻"
"󰁼"
"󰁽"
"󰁾"
"󰁿"
"󰂀"
"󰂁"
"󰂂"
"󰁹"
];
tooltip = true;
tooltip-format = "BAT1: {cycles} cycles";
};
"upower#headphones" = {
native-path = "/org/bluez/hci0/dev_4C_87_5D_29_B3_76";
format = "󰋋 {percentage} {time}";
hide-if-empty = true;
show-icon = false;
};
};
interactiveBar = {
layer = "top";
position = "bottom";
modules-left = ["sway/workspaces" "sway/mode"];
modules-center = ["tray"];
modules-right = ["wlr/taskbar"];
};
# mainBar = {
# layer = "top";
# position = "top";
# height = 30;
# output = [
# "eDP-1"
# "HDMI-A-1"
# ];
# modules-left = ["sway/workspaces" "sway/mode" "wlr/taskbar"];
# modules-center = ["sway/window" "custom/hello-from-waybar"];
# modules-right = ["mpd" "custom/mymodule#with-css-id" "temperature"];
# "sway/workspaces" = {
# disable-scroll = true;
# all-outputs = true;
# };
# "custom/hello-from-waybar" = {
# format = "hello {}";
# max-length = 40;
# interval = "once";
# exec = pkgs.writeShellScript "hello-from-waybar" ''
# echo "from within waybar"
# '';
# };
# };
};
};
@ -163,6 +77,18 @@
xkb_variant = "altgr-intl";
};
};
startup = [
{
command = "eww open topBar";
}
{
command = "pkill nm-applet; sleep 1 && nm-applet";
always = true;
}
{
command = "sleep 1 && mullvad-gui";
}
];
bars = [];
menu = "wofi -d";
modifier = "Mod4";