waybar changes 1

This commit is contained in:
cnst
2024-12-27 16:46:50 +01:00
parent 542bac2fe7
commit 10716da678
22 changed files with 1007 additions and 159 deletions

View File

@@ -0,0 +1,21 @@
#!/bin/sh
output() {
if [ -f "$HOME/decrypted/.lock" ]; then
printf '{"text": ""}\n'
else
printf '{"text": ""}\n'
fi
}
check() {
[ ! -d "$HOME/decrypted" ] && return
output
inotifywait -q "$HOME/decrypted/.lock" > /dev/null 2>&1
output
inotifywait -q "$HOME/decrypted" > /dev/null
check
}
check

View File

@@ -0,0 +1,18 @@
#!/bin/sh
check() {
[ ! -d "$HOME/.mail" ] && return
notmuch new > /dev/null
count="$(notmuch count 'tag:unread')"
tooltip="There are $count new emails"
if [ "$count" = "0" ]; then
printf '{"text": ""}\n'
else
printf '{"text": "%s", "tooltip": "%s", "alt": "icon"}\n' "$count" "$tooltip"
fi
inotifywait -q -e move -e create -e delete "$HOME/.mail/cnst/INBOX/cur" > /dev/null
check
}
check

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
output="$(progress -q)"
text="$(printf "%s" "$output" | sed 's/\[[^]]*\] //g' | awk 'BEGIN { ORS=" " } NR%3==1 { op=$1 } NR%3==2 { pct=($1+0); if (op != "gpg" && op != "coreutils" && pct > 0 && pct < 100) { print op, $1 } }')"
tooltip="$(printf "%s" "$output" | perl -pe 's/\n/\\n/g' | perl -pe 's/(?:\\n)+$//')"
printf '{"text": "%s", "tooltip": "%s"}\n' "$text" "$tooltip"

View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if pgrep -x wf-recorder >/dev/null; then
printf '{"text": "  "}\n'
else
printf '{"text": ""}\n'
fi

View File

@@ -0,0 +1,37 @@
#!/bin/bash
socket="${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-touch-detector.socket"
while true; do
touch_reasons=()
if [ ! -e "$socket" ]; then
printf '{"text": "Waiting for YubiKey socket"}\n'
while [ ! -e "$socket" ]; do sleep 1; done
fi
printf '{"text": ""}\n'
while read -n5 cmd; do
reason="${cmd:0:3}"
if [ "${cmd:4:1}" = "1" ]; then
touch_reasons+=("$reason")
else
for i in "${!touch_reasons[@]}"; do
if [ "${touch_reasons[i]}" = "$reason" ]; then
unset 'touch_reasons[i]'
break
fi
done
fi
if [ "${#touch_reasons[@]}" -eq 0 ]; then
printf '{"text": ""}\n'
else
tooltip="YubiKey is waiting for a touch, reasons: ${touch_reasons[@]}"
printf '{"text": "  ", "tooltip": "%s"}\n' "$tooltip"
fi
done < <(nc -U "$socket")
sleep 1
done

View File

@@ -11,17 +11,217 @@ in {
home.programs.waybar.enable = mkEnableOption "Enables waybar";
};
config = mkIf cfg.enable {
systemd.user.services.waybar = {
Unit.StartLimitBurst = 30;
};
programs.waybar = {
enable = true;
package = pkgs.waybar;
systemd.enable = true;
};
# style = ./style.css;
systemd.user.services.waybar = {
Unit = {
StartLimitBurst = 30;
After = lib.mkForce "graphical-session.target";
};
settings = [
{
height = 25;
modules-left = [
"group/system"
];
modules-center = [
"hyprland/workspaces"
];
modules-right = [
"custom/progress"
"custom/systemd"
# "custom/mail"
"group/tray"
"pulseaudio"
"backlight"
"battery"
"clock"
"custom/mako"
];
"hyprland/workspaces" = {
format = "{icon}";
format-icons = {
"default" = "";
"active" = "";
"empty" = "";
"persistent" = "";
};
disable-scroll = true;
rotate = 0;
all-outputs = true;
active-only = false;
on-click = "activate";
persistent-workspaces = {
"*" = 3;
};
};
"group/tray" = {
orientation = "inherit";
drawer = {
transition-left-to-right = false;
transistion-duration = 250;
click-to-reveal = true;
};
modules = [
"custom/trayicon"
"tray"
];
};
"group/system" = {
orientation = "inherit";
drawer = {
transistion-left-to-right = true;
transition-duration = 250;
click-to-reveal = true;
};
modules = [
"custom/logo"
"cpu"
"memory"
"disk"
"network"
];
};
"custom/trayicon" = {
format = "󰅁";
tooltip = false;
};
"custom/logo" = {
format = " ";
tooltip = false;
};
"custom/mako" = {
exec = "mako.sh";
on-click = "mako-toggle.sh";
restart-interval = 1;
tooltip = false;
};
"custom/progress" = {
exec = "waybar-progress.sh";
return-type = "json";
interval = 1;
};
"custom/systemd" = {
exec = "waybar-systemd.sh";
return-type = "json";
interval = 10;
};
# "custom/mail" = {
# format-icons = {
# icon = "<span foreground='#928374'> </span>";
# };
# format = "{icon}{}";
# exec = "${app}/bin/waybar-mail";
# return-type = "json";
# };
# "custom/recording" = {
# exec = "${app}/bin/waybar-recording";
# return-type = "json";
# signal = 3;
# interval = "once";
# };
tray = {
icon-size = 12;
rotate = 0;
spacing = 5;
};
clock = {
format = "<span foreground='#928374'></span> {:%a, %d %b <span foreground='#928374'></span> %H:%M}";
rotate = 0;
on-click = "calcurse-toggle.sh";
on-click-right = "calsync.sh";
tooltip = false;
};
cpu = {
format = "<span foreground='#928374'></span> {usage}%";
states = {
warning = 70;
critical = 90;
};
};
disk = {
format = "<span foreground='#928374'></span> {percentage_free}%";
states = {
warning = 70;
critical = 90;
};
};
memory = {
format = "<span foreground='#928374'></span> {}%";
states = {
warning = 70;
critical = 90;
};
};
backlight = {
format = "<span foreground='#928374'>{icon}</span> {percent}%";
format-icons = [""];
tooltip = false;
};
battery = {
states = {
warning = 30;
critical = 15;
};
format = "<span foreground='#928374'>{icon}</span> {capacity}%";
format-charging = "<span foreground='#928374'></span> {capacity}%";
format-icons = ["" "" "" "" ""];
};
network = {
interval = 2;
format-wifi = "<span foreground='#928374'></span> {essid}";
format-ethernet = "<span foreground='#928374'></span> {ifname}";
format-linked = "<span foreground='#928374'></span> {ifname}";
format-disconnected = " <span foreground='#928374'></span> ";
tooltip-format = "{ifname}: {ipaddr}/{cidr}\n {bandwidthDownBits}\n {bandwidthUpBits}";
};
pulseaudio = {
format = "<span foreground='#928374'>{icon}</span> {volume}% {format_source}";
on-scroll-up = "volume-control.sh --inc";
on-scroll-down = "volume-control.sh --dec";
format-bluetooth = "<span foreground='#928374'>{icon}</span> {volume}% {format_source}";
format-bluetooth-muted = "<span foreground='#928374'> {icon}</span> {format_source}";
format-muted = "<span foreground='#928374'></span> {format_source}";
format-source = "<span foreground='#928374'></span> {volume}%";
format-source-muted = "<span foreground='#928374'></span>";
format-icons = {
headphone = "";
hands-free = "";
headset = "";
phone = "";
portable = "";
car = "";
default = ["" "" ""];
};
on-click = lib.getExe pkgs.pavucontrol;
on-click-middle = lib.getExe pkgs.helvum;
};
}
];
};
};
}

View File

@@ -0,0 +1,167 @@
* {
all: unset;
background: #282828;
border: none;
border-radius: 0;
font-family:
Input Mono Narrow Light,
"Font Awesome 6 Free Solid";
font-size: 13px;
min-height: 0;
}
window#waybar {
background: transparent;
color: #fbf1c7;
/* transition-property: background-color; */
/* transition-duration: 0.5s; */
}
#workspaces button {
padding: 0 0px;
margin: 0 6px;
background-color: transparent;
color: #fbf1c7;
border-top: 3px solid transparent;
border-bottom: 3px solid transparent;
}
#workspaces button:hover {
background-color: #282828;
background: #282828;
color: #ebdbb2;
animation: ws_active 0s ease-in-out 1;
transition: all 0.2s cubic-bezier(0.55, -0.68, 0.48, 1.682);
}
#workspaces button.active {
color: #fbf1c7;
animation: ws_active 0s ease-in-out 1;
transition: all 0.2s cubic-bezier(0.55, -0.68, 0.48, 1.682);
}
#custom-logo {
font-size: 16px;
background-image: url("../waybar/images/button.svg");
background-position: center;
background-repeat: no-repeat;
background-size: 18px 15px;
}
#custom-trayicon {
color: #fbf1c7;
background: transparent;
opacity: 1;
margin: 1px 0px 0px 0px;
padding-left: 2px;
padding-right: 2px;
font-family: "Cantarell";
font-size: 14px;
}
#custom-usbguard,
#custom-decrypted,
#custom-mail,
#battery.warning,
#disk.warning,
#memory.warning,
#cpu.warning,
#custom-dnd.dnd-notification,
#custom-dnd.dnd-none {
border-top: 3px solid #282828;
border-bottom: 3px solid #c35e0a;
}
#custom-systemd,
#battery.critical,
#disk.critical,
#memory.critical,
#cpu.critical,
#custom-yubikey,
#custom-recording {
border-top: 3px solid #282828;
border-bottom: 3px solid #c14a4a;
}
#battery.charging {
border-top: 3px solid #282828;
border-bottom: 3px solid #4c7a5d;
}
#pulseaudio,
#custom-systemd,
#custom-mail,
#network,
#cpu,
#disk,
#memory,
#backlight,
#battery,
#clock {
padding: 0 3px;
margin: 0 3px;
}
#custom-dnd,
#custom-recording,
#language {
padding: 0;
margin: 0 6px;
}
#backlight,
#battery,
#clock,
#cpu,
#custom-mail,
#custom-progress,
#custom-recording,
#custom-systemd,
#custom-usbguard,
#custom-yubikey,
#disk,
#memory,
#mode,
#network,
#pulseaudio {
color: #fbf1c7;
}
#custom-mako {
color: #928374;
background: transparent;
opacity: 1;
margin: 1px 0px 0px 0px;
padding-right: 12px;
padding-left: 8px;
font-family: "Cantarell";
font-size: 16px;
}
#tray menu * {
color: #fbf1c7;
font-family: "Input Sans Compressed";
}
#tray {
padding: 0px 5px;
}
#tray > .passive {
-gtk-icon-effect: dim;
}
@keyframes needs-attention {
to {
background-color: rgba(235, 77, 75, 0.5);
}
}
#tray > .needs-attention {
-gtk-icon-effect: highlight;
animation-name: needs-attention;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
background-color: transparent;
}