Alexays / Waybar

Highly customizable Wayland bar for Sway and Wlroots based compositors. :v: :tada:
MIT License
5.86k stars 660 forks source link

Battery module not returning battery charge #3412

Closed yusi1 closed 2 days ago

yusi1 commented 2 days ago

Hi, I am using the battery module in my Waybar configuration for Hyprland and it doesn't return anything, all it shows is just 3 dots.

WAYBAR VERSION: 0.10.0

This is my config:

// -*- mode: Json;-*-

{
    "layer": "top", // Waybar at top layer
    // "position": "bottom", // Waybar position (top|bottom|left|right)
    "height": 30, // Waybar height (to be removed for auto height)
    // "width": 1280, // Waybar width
    "spacing": 4, // Gaps between modules (4px)
    // Choose the order of the modules
    "modules-left": ["hyprland/workspaces", "hyprland/window", "custom/media"],
    // "modules-center": ["hyprland/window"],
    "modules-right": ["cava", "pulseaudio", "network", "cpu", "memory", "temperature", "keyboard-state", "backlight", "battery", "clock", "tray"],
    // Modules configuration
    "hyprland/workspaces": {
        "disable-scroll": true,
        "all-outputs": true,
        "warp-on-scroll": false,
        "on-scroll-up": "hyprctl dispatch workspace e+1",
        "on-scroll-down": "hyprctl dispatch workspace e-1",
        "format": "{name}: {icon}",
        "format-icons": {
            "1": " ",
            "2": " ",
            "3": " ",
            "4": " ",
            "5": " ",
            "urgent": " ",
            "focused": " ",
            "default": " "
        }
    },
    "hyprland/window": {
        "format": "{}"
    },
    "keyboard-state": {
        "numlock": true,
        "capslock": true,
        "format": "{name} {icon} ",
        "format-icons": {
            "locked": "",
            "unlocked": ""
        }
    },
    "tray": {
        "icon-size": 24,
        "spacing": 10,
        "icon-theme": "Papirus-Dark"
    },
    "clock": {
        // "timezone": "America/New_York",
        "tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
        "format-alt": "{:%Y-%m-%d}"
    },
    "cpu": {
        "format": "{usage}%  ",
        "tooltip": false
    },
    "memory": {
        "format": "{used}GB/{total}GB {percentage}%  "
    },
    "backlight": {
        "device": "intel_backlight",
        "format": "{percent}% {icon}",
        "format-icons": [" ", " "]
    },
    "battery": {
           "bat": "BAT1",
           "interval": 60,
           "states": {
                     "warning": 15,
                     "critical": 7
           },
           "format": "{capacity}% {time} {icon}",
           "format-icons": [" ", " ", " ", " ", " "],
           "max-length": 25
    },
    "temperature": {
        // "thermal-zone": 2,
        // "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input",
        "critical-threshold": 80,
        // "format-critical": "{temperatureC}°C {icon}",
        "format": "{temperatureC}°C {icon}",
        "format-icons": ["", "", ""]
    },
    "network": {
        // "interface": "wlp2*", // (Optional) To force the use of this interface
        "format-wifi": "{essid} ({signalStrength}%)  ",
        "format-ethernet": "{ipaddr}/{cidr} ",
        "tooltip-format": "{ifname} via {gwaddr} ",
        "format-linked": "{ifname} (No IP) ",
        "format-disconnected": "Disconnected ⚠",
        "format-alt": "{ifname}: {ipaddr}/{cidr}"
    },
    "pulseaudio": {
        // "scroll-step": 1, // %, can be a float
        "format": "{volume}% {icon}  {format_source}",
        "format-bluetooth": "{volume}% {icon} {format_source}",
        "format-bluetooth-muted": " {icon} {format_source}",
        "format-muted": "{volume}%   {format_source}",
        "format-source": "{volume}% ",
        "format-source-muted": "",
        "format-icons": {
            "headphone": "",
            "hands-free": "",
            "headset": "",
            "phone": "",
            "portable": "",
            "car": "",
            "default": ["", "", ""]
        },
        "on-click": "pavucontrol"
    },

    "cava": {
        "cava_config": "$XDG_CONFIG_HOME/cava/cava.conf",
        "framerate": 144,
        "autosens": 1,
        "sensitivity": 100,
        "bars": 2,
        "lower_cutoff_freq": 50,
        "higher_cutoff_freq": 10000,
        "method": "pulse",
        "source": "auto",
        "stereo": true,
        "reverse": false,
        "bar_delimiter": 0,
        "monstercat": false,
        "waves": false,
        "noise_reduction": 0.77,
        "input_delay": 2,
        "format-icons" : ["▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" ],
        "actions": {
            "on-click-right": "mode"
        }
    },

    "custom/media": {
        "format": "{icon} {}",
        "return-type": "json",
        "max-length": 40,
        "format-icons": {
            "spotify": "",
            "default": "🎜"
        },
        "escape": true,
        "exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder
        // "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name
    }
}

Log of Waybar launching:

[2024-07-04 15:57:20.552] [info] Using configuration file /home/yaslam/.config/waybar/config.jsonc
[2024-07-04 15:57:20.555] [info] Discovered appearance 'dark'
[2024-07-04 15:57:20.555] [info] Using CSS file /home/yaslam/.config/waybar/style.css

(waybar:123580): Gtk-WARNING **: 15:57:20.555: Theme parsing error: style.css:3:20: Not using units is deprecated. Assuming 'px'.
[2024-07-04 15:57:20.565] [info] Hyprland IPC starting
[2024-07-04 15:57:20.567] [info] Loading persistent workspaces from Hyprland workspace rules
[2024-07-04 15:57:20.572] [warning] module cava: Unknown module: cava
[2024-07-04 15:57:20.573] [warning] module keyboard-state: Unknown module: keyboard-state
[2024-07-04 15:57:20.573] [error] media stopped unexpectedly, is it endless?
[2024-07-04 15:57:20.717] [warning] Requested height: 30 is less than the minimum height: 36 required by the modules
[2024-07-04 15:57:20.717] [info] Bar configured (width: 1920, height: 36) for output: eDP-1

The battery module is in the top right on the left of the clock.

I have attached a photo. 20240704_16h16m50s_grim

Thank you!

yusi1 commented 2 days ago

I just noticed that when I hover over the battery module it does give me the time left for the battery, but the charge doesn't show still.

yusi1 commented 2 days ago

LOL, the issue was with the max-length option being set too small, sorry for the waste of time.