there is now osd in waybar

Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
Hadi
2026-06-30 00:12:14 +02:00
parent cdffe66d72
commit ccdf0c289a
11 changed files with 156 additions and 155 deletions
+74 -1
View File
@@ -15,6 +15,79 @@
done
printf '{"text": "󰤭", "class": "disconnected", "tooltip": "Disconnected"}\n'
'';
updateOsd = ''
[ -f /tmp/waybar-osd-pid ] && kill "$(cat /tmp/waybar-osd-pid)" 2>/dev/null
printf '%s' "$OSD_TEXT" > /tmp/waybar-osd
pkill -RTMIN+8 waybar 2>/dev/null
( sleep 2.5; rm -f /tmp/waybar-osd /tmp/waybar-osd-pid; pkill -RTMIN+8 waybar 2>/dev/null ) &
printf '%s' "$!" > /tmp/waybar-osd-pid
'';
volGetText = ''
VOL_RAW=$(${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_SINK@)
VOL=$(printf '%s' "$VOL_RAW" | awk '{printf "%d", $2*100}')
if printf '%s' "$VOL_RAW" | grep -q MUTED; then
OSD_TEXT="󰝟 $VOL%"
elif [ "$VOL" -lt 33 ]; then
OSD_TEXT="󰕿 $VOL%"
elif [ "$VOL" -lt 66 ]; then
OSD_TEXT="󰖀 $VOL%"
else
OSD_TEXT="󰕾 $VOL%"
fi
'';
brightGetText = ''
BRIGHT=$(${pkgs.brightnessctl}/bin/brightnessctl -m | awk -F, '{print int($5)}')
if [ "$BRIGHT" -lt 33 ]; then
OSD_TEXT="󰃞 $BRIGHT%"
elif [ "$BRIGHT" -lt 66 ]; then
OSD_TEXT="󰃟 $BRIGHT%"
else
OSD_TEXT="󰃠 $BRIGHT%"
fi
'';
vol-up = pkgs.writeShellScriptBin "vol-up" ''
${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_SINK@ 5%+ --limit 1.0
${volGetText}
${updateOsd}
'';
vol-down = pkgs.writeShellScriptBin "vol-down" ''
${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_SINK@ 5%-
${volGetText}
${updateOsd}
'';
vol-mute = pkgs.writeShellScriptBin "vol-mute" ''
${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_SINK@ toggle
${volGetText}
${updateOsd}
'';
mic-mute = pkgs.writeShellScriptBin "mic-mute" ''
${pkgs.wireplumber}/bin/wpctl set-mute @DEFAULT_SOURCE@ toggle
if ${pkgs.wireplumber}/bin/wpctl get-volume @DEFAULT_SOURCE@ | grep -q MUTED; then
OSD_TEXT="󰍭 Muted"
else
OSD_TEXT="󰍬 Live"
fi
${updateOsd}
'';
bright-up = pkgs.writeShellScriptBin "bright-up" ''
${pkgs.brightnessctl}/bin/brightnessctl set 5%+
${brightGetText}
${updateOsd}
'';
bright-down = pkgs.writeShellScriptBin "bright-down" ''
${pkgs.brightnessctl}/bin/brightnessctl set 5%-
${brightGetText}
${updateOsd}
'';
in {
imports = [
./settings.nix
@@ -31,7 +104,7 @@ in {
pavucontrol
blueman
iw
];
] ++ [vol-up vol-down vol-mute mic-mute bright-up bright-down];
wayland.windowManager.hyprland.settings.exec-once = [
"waybar"
+11 -3
View File
@@ -6,9 +6,9 @@ in {
{
layer = "top";
position = "top";
height = 25;
height = config.theme.bar-height;
margin = "${toString gaps-out} ${toString gaps-out} 0";
modules-center = ["clock" "tray" "hyprland/workspaces" "custom/network" "bluetooth" "battery" "group/right-hidden"];
modules-center = ["custom/osd" "clock" "tray" "hyprland/workspaces" "custom/network" "bluetooth" "battery" "group/right-hidden"];
"group/right-hidden" = {
orientation = "horizontal";
@@ -92,13 +92,21 @@ in {
on-click-right = "blueman-manager &";
};
"custom/osd" = {
exec = "cat /tmp/waybar-osd";
exec-if = "test -f /tmp/waybar-osd";
signal = 8;
interval = "once";
format = "{}";
};
pulseaudio = {
format = "{icon}";
format-bluetooth = "{icon}";
tooltip-format = "{volume}%";
format-muted = "<span size='12pt'>󰝟</span>";
scroll-step = 2;
on-click = "swayosd-client --output-volume mute-toggle";
on-click = "vol-mute";
on-click-right = "pavucontrol -t 4 &";
format-icons = {
headphone = "";
+7 -1
View File
@@ -36,7 +36,7 @@ in {
background: ${module-bg};
border-radius: 100px;
padding: 6px 14px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
box-shadow: none;
}
#clock,
@@ -201,5 +201,11 @@ in {
background-color: ${fg};
background-image: none;
}
#custom-osd {
padding: 1px 14px;
font-weight: 700;
color: ${fg};
}
'';
}